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