music.h
author Ozkan Sezer <sezeroz@gmail.com>
Wed, 03 Oct 2018 21:55:00 +0300
changeset 863 b81eb791d10d
parent 855 a7dee77dd60f
child 901 253f50984a9a
permissions -rw-r--r--
readmidi.c (groom_list): avoid integer overflow when recomputing time.

from libtimidity -- see:
https://sourceforge.net/p/libtimidity/libtimidity/ci/11be98a89eac229111420e6a3d521edbfddb0dbc/
     1 /*
     2   SDL_mixer:  An audio mixer library based on the SDL library
     3   Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 #include "SDL_mixer.h"
    22 
    23 #ifndef MUSIC_H_
    24 #define MUSIC_H_
    25 
    26 /* Supported music APIs, in order of preference */
    27 
    28 typedef enum
    29 {
    30     MIX_MUSIC_CMD,
    31     MIX_MUSIC_WAVE,
    32     MIX_MUSIC_MODPLUG,
    33     MIX_MUSIC_MIKMOD,
    34     MIX_MUSIC_FLUIDSYNTH,
    35     MIX_MUSIC_TIMIDITY,
    36     MIX_MUSIC_NATIVEMIDI,
    37     MIX_MUSIC_OGG,
    38     MIX_MUSIC_MPG123,
    39     MIX_MUSIC_MAD,
    40     MIX_MUSIC_SMPEG,
    41     MIX_MUSIC_FLAC,
    42     MIX_MUSIC_OPUS,
    43     MIX_MUSIC_LAST
    44 } Mix_MusicAPI;
    45 
    46 
    47 /* Music API implementation */
    48 
    49 typedef struct
    50 {
    51     const char *tag;
    52     Mix_MusicAPI api;
    53     Mix_MusicType type;
    54     SDL_bool loaded;
    55     SDL_bool opened;
    56 
    57     /* Load the library */
    58     int (*Load)(void);
    59 
    60     /* Initialize for the audio output */
    61     int (*Open)(const SDL_AudioSpec *spec);
    62 
    63     /* Create a music object from an SDL_RWops stream
    64      * If the function returns NULL, 'src' will be freed if needed by the caller.
    65      */
    66     void *(*CreateFromRW)(SDL_RWops *src, int freesrc);
    67 
    68     /* Create a music object from a file, if SDL_RWops are not supported */
    69     void *(*CreateFromFile)(const char *file);
    70 
    71     /* Set the volume */
    72     void (*SetVolume)(void *music, int volume);
    73 
    74     /* Start playing music from the beginning with an optional loop count */
    75     int (*Play)(void *music, int play_count);
    76 
    77     /* Returns SDL_TRUE if music is still playing */
    78     SDL_bool (*IsPlaying)(void *music);
    79 
    80     /* Get music data, returns the number of bytes left */
    81     int (*GetAudio)(void *music, void *data, int bytes);
    82 
    83     /* Seek to a play position (in seconds) */
    84     int (*Seek)(void *music, double position);
    85 
    86     /* Pause playing music */
    87     void (*Pause)(void *music);
    88 
    89     /* Resume playing music */
    90     void (*Resume)(void *music);
    91 
    92     /* Stop playing music */
    93     void (*Stop)(void *music);
    94 
    95     /* Delete a music object */
    96     void (*Delete)(void *music);
    97 
    98     /* Close the library and clean up */
    99     void (*Close)(void);
   100 
   101     /* Unload the library */
   102     void (*Unload)(void);
   103 
   104 } Mix_MusicInterface;
   105 
   106 
   107 extern int get_num_music_interfaces(void);
   108 extern Mix_MusicInterface *get_music_interface(int index);
   109 extern Mix_MusicType detect_music_type_from_magic(const Uint8 *magic);
   110 extern SDL_bool load_music_type(Mix_MusicType type);
   111 extern SDL_bool open_music_type(Mix_MusicType type);
   112 extern SDL_bool has_music(Mix_MusicType type);
   113 extern void open_music(const SDL_AudioSpec *spec);
   114 extern int music_pcm_getaudio(void *context, void *data, int bytes, int volume,
   115                               int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done));
   116 extern void SDLCALL music_mixer(void *udata, Uint8 *stream, int len);
   117 extern void close_music(void);
   118 extern void unload_music(void);
   119 
   120 extern char *music_cmd;
   121 extern SDL_AudioSpec music_spec;
   122 
   123 #endif /* MUSIC_H_ */
   124 
   125 /* vi: set ts=4 sw=4 expandtab: */