misc/winutils/include/SDL_mixer.h
changeset 7809 7d4fb2f35f4f
parent 6560 ca07e6be08d0
child 10017 de822cd3df3a
equal deleted inserted replaced
7808:cc1805cd9138 7809:7d4fb2f35f4f
     1 /*
     1 /*
     2     SDL_mixer:  An audio mixer library based on the SDL library
     2   SDL_mixer:  An audio mixer library based on the SDL library
     3     Copyright (C) 1997-2004 Sam Lantinga
     3   Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     4 
     4 
     5     This library is free software; you can redistribute it and/or
     5   This software is provided 'as-is', without any express or implied
     6     modify it under the terms of the GNU Library General Public
     6   warranty.  In no event will the authors be held liable for any damages
     7     License as published by the Free Software Foundation; either
     7   arising from the use of this software.
     8     version 2 of the License, or (at your option) any later version.
     8 
     9 
     9   Permission is granted to anyone to use this software for any purpose,
    10     This library is distributed in the hope that it will be useful,
    10   including commercial applications, and to alter it and redistribute it
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    11   freely, subject to the following restrictions:
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    12 
    13     Library General Public License for more details.
    13   1. The origin of this software must not be misrepresented; you must not
    14 
    14      claim that you wrote the original software. If you use this software
    15     You should have received a copy of the GNU Library General Public
    15      in a product, an acknowledgment in the product documentation would be
    16     License along with this library; if not, write to the Free
    16      appreciated but is not required.
    17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    17   2. Altered source versions must be plainly marked as such, and must not be
    18 
    18      misrepresented as being the original software.
    19     Sam Lantinga
    19   3. This notice may not be removed or altered from any source distribution.
    20     slouken@libsdl.org
    20 */
    21 */
    21 
    22 
    22 /* $Id$ */
    23 /* $Id: SDL_mixer.h,v 1.30 2004/01/04 17:37:04 slouken Exp $ */
       
    24 
    23 
    25 #ifndef _SDL_MIXER_H
    24 #ifndef _SDL_MIXER_H
    26 #define _SDL_MIXER_H
    25 #define _SDL_MIXER_H
    27 
    26 
    28 #include "SDL_types.h"
    27 #include "SDL_types.h"
    29 #include "SDL_rwops.h"
    28 #include "SDL_rwops.h"
    30 #include "SDL_audio.h"
    29 #include "SDL_audio.h"
    31 #include "SDL_byteorder.h"
    30 #include "SDL_endian.h"
    32 #include "SDL_version.h"
    31 #include "SDL_version.h"
    33 #include "begin_code.h"
    32 #include "begin_code.h"
    34 
    33 
    35 /* Set up for C function definitions, even when using C++ */
    34 /* Set up for C function definitions, even when using C++ */
    36 #ifdef __cplusplus
    35 #ifdef __cplusplus
    39 
    38 
    40 /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
    39 /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
    41 */
    40 */
    42 #define SDL_MIXER_MAJOR_VERSION	1
    41 #define SDL_MIXER_MAJOR_VERSION	1
    43 #define SDL_MIXER_MINOR_VERSION	2
    42 #define SDL_MIXER_MINOR_VERSION	2
    44 #define SDL_MIXER_PATCHLEVEL	6
    43 #define SDL_MIXER_PATCHLEVEL    12
    45 
    44 
    46 /* This macro can be used to fill a version structure with the compile-time
    45 /* This macro can be used to fill a version structure with the compile-time
    47  * version of the SDL_mixer library.
    46  * version of the SDL_mixer library.
    48  */
    47  */
    49 #define SDL_MIXER_VERSION(X)						\
    48 #define SDL_MIXER_VERSION(X)						\
    62 /* This function gets the version of the dynamically linked SDL_mixer library.
    61 /* This function gets the version of the dynamically linked SDL_mixer library.
    63    it should NOT be used to fill a version structure, instead you should
    62    it should NOT be used to fill a version structure, instead you should
    64    use the SDL_MIXER_VERSION() macro.
    63    use the SDL_MIXER_VERSION() macro.
    65  */
    64  */
    66 extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void);
    65 extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void);
       
    66 
       
    67 typedef enum
       
    68 {
       
    69     MIX_INIT_FLAC        = 0x00000001,
       
    70     MIX_INIT_MOD         = 0x00000002,
       
    71     MIX_INIT_MP3         = 0x00000004,
       
    72     MIX_INIT_OGG         = 0x00000008,
       
    73     MIX_INIT_FLUIDSYNTH  = 0x00000010
       
    74 } MIX_InitFlags;
       
    75 
       
    76 /* Loads dynamic libraries and prepares them for use.  Flags should be
       
    77    one or more flags from MIX_InitFlags OR'd together.
       
    78    It returns the flags successfully initialized, or 0 on failure.
       
    79  */
       
    80 extern DECLSPEC int SDLCALL Mix_Init(int flags);
       
    81 
       
    82 /* Unloads libraries loaded with Mix_Init */
       
    83 extern DECLSPEC void SDLCALL Mix_Quit(void);
    67 
    84 
    68 
    85 
    69 /* The default mixer has 8 simultaneous mixing channels */
    86 /* The default mixer has 8 simultaneous mixing channels */
    70 #ifndef MIX_CHANNELS
    87 #ifndef MIX_CHANNELS
    71 #define MIX_CHANNELS	8
    88 #define MIX_CHANNELS	8
    80 #endif
    97 #endif
    81 #define MIX_DEFAULT_CHANNELS	2
    98 #define MIX_DEFAULT_CHANNELS	2
    82 #define MIX_MAX_VOLUME		128	/* Volume of a chunk */
    99 #define MIX_MAX_VOLUME		128	/* Volume of a chunk */
    83 
   100 
    84 /* The internal format for an audio chunk */
   101 /* The internal format for an audio chunk */
    85 typedef struct {
   102 typedef struct Mix_Chunk {
    86 	int allocated;
   103 	int allocated;
    87 	Uint8 *abuf;
   104 	Uint8 *abuf;
    88 	Uint32 alen;
   105 	Uint32 alen;
    89 	Uint8 volume;		/* Per-sample volume, 0-128 */
   106 	Uint8 volume;		/* Per-sample volume, 0-128 */
    90 } Mix_Chunk;
   107 } Mix_Chunk;
   101 	MUS_CMD,
   118 	MUS_CMD,
   102 	MUS_WAV,
   119 	MUS_WAV,
   103 	MUS_MOD,
   120 	MUS_MOD,
   104 	MUS_MID,
   121 	MUS_MID,
   105 	MUS_OGG,
   122 	MUS_OGG,
   106 	MUS_MP3
   123 	MUS_MP3,
       
   124 	MUS_MP3_MAD,
       
   125 	MUS_FLAC,
       
   126 	MUS_MODPLUG
   107 } Mix_MusicType;
   127 } Mix_MusicType;
   108 
   128 
   109 /* The internal format for a music chunk interpreted via mikmod */
   129 /* The internal format for a music chunk interpreted via mikmod */
   110 typedef struct _Mix_Music Mix_Music;
   130 typedef struct _Mix_Music Mix_Music;
   111 
   131 
   128 /* Load a wave file or a music (.mod .s3m .it .xm) file */
   148 /* Load a wave file or a music (.mod .s3m .it .xm) file */
   129 extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc);
   149 extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc);
   130 #define Mix_LoadWAV(file)	Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
   150 #define Mix_LoadWAV(file)	Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
   131 extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
   151 extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
   132 
   152 
   133 #ifdef USE_RWOPS /* This hasn't been hooked into music.c yet */
   153 /* Load a music file from an SDL_RWop object (Ogg and MikMod specific currently)
   134 /* Load a music file from an SDL_RWop object (MikMod-specific currently)
       
   135    Matt Campbell (matt@campbellhome.dhs.org) April 2000 */
   154    Matt Campbell (matt@campbellhome.dhs.org) April 2000 */
   136 extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *rw);
   155 extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *rw);
   137 #endif
   156 
       
   157 /* Load a music file from an SDL_RWop object assuming a specific format */
       
   158 extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *rw, Mix_MusicType type, int freesrc);
   138 
   159 
   139 /* Load a wave file of the mixer format from a memory buffer */
   160 /* Load a wave file of the mixer format from a memory buffer */
   140 extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem);
   161 extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem);
   141 
   162 
   142 /* Load raw audio data of the mixer format from a memory buffer */
   163 /* Load raw audio data of the mixer format from a memory buffer */
   143 extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len);
   164 extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len);
   144 
   165 
   145 /* Free an audio chunk previously loaded */
   166 /* Free an audio chunk previously loaded */
   146 extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
   167 extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
   147 extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);
   168 extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);
       
   169 
       
   170 /* Get a list of chunk/music decoders that this build of SDL_mixer provides.
       
   171    This list can change between builds AND runs of the program, if external
       
   172    libraries that add functionality become available.
       
   173    You must successfully call Mix_OpenAudio() before calling these functions.
       
   174    This API is only available in SDL_mixer 1.2.9 and later.
       
   175 
       
   176    // usage...
       
   177    int i;
       
   178    const int total = Mix_GetNumChunkDecoders();
       
   179    for (i = 0; i < total; i++)
       
   180        printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i));
       
   181 
       
   182    Appearing in this list doesn't promise your specific audio file will
       
   183    decode...but it's handy to know if you have, say, a functioning Timidity
       
   184    install.
       
   185 
       
   186    These return values are static, read-only data; do not modify or free it.
       
   187    The pointers remain valid until you call Mix_CloseAudio().
       
   188 */
       
   189 extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void);
       
   190 extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index);
       
   191 extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void);
       
   192 extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index);
   148 
   193 
   149 /* Find out the music format of a mixer music, or the currently playing
   194 /* Find out the music format of a mixer music, or the currently playing
   150    music, if 'music' is NULL.
   195    music, if 'music' is NULL.
   151 */
   196 */
   152 extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music);
   197 extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music);
   181  *  before calling your callback.
   226  *  before calling your callback.
   182  */
   227  */
   183 extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (*channel_finished)(int channel));
   228 extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (*channel_finished)(int channel));
   184 
   229 
   185 
   230 
   186 /* Special Effects API by ryan c. gordon. (icculus@linuxgames.com) */
   231 /* Special Effects API by ryan c. gordon. (icculus@icculus.org) */
   187 
   232 
   188 #define MIX_CHANNEL_POST  -2
   233 #define MIX_CHANNEL_POST  -2
   189 
   234 
   190 /* This is the format of a special effect callback:
   235 /* This is the format of a special effect callback:
   191  *
   236  *
   543 extern DECLSPEC int SDLCALL Mix_PausedMusic(void);
   588 extern DECLSPEC int SDLCALL Mix_PausedMusic(void);
   544 
   589 
   545 /* Set the current position in the music stream.
   590 /* Set the current position in the music stream.
   546    This returns 0 if successful, or -1 if it failed or isn't implemented.
   591    This returns 0 if successful, or -1 if it failed or isn't implemented.
   547    This function is only implemented for MOD music formats (set pattern
   592    This function is only implemented for MOD music formats (set pattern
   548    order number) and for OGG music (set position in seconds), at the
   593    order number) and for OGG, FLAC, MP3_MAD, and MODPLUG music (set 
   549    moment.
   594    position in seconds), at the moment.
   550 */
   595 */
   551 extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);
   596 extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);
   552 
   597 
   553 /* Check the status of a specific channel.
   598 /* Check the status of a specific channel.
   554    If the specified channel is -1, check all channels.
   599    If the specified channel is -1, check all channels.
   560 extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);
   605 extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);
   561 
   606 
   562 /* Synchro value is set by MikMod from modules while playing */
   607 /* Synchro value is set by MikMod from modules while playing */
   563 extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);
   608 extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);
   564 extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);
   609 extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);
       
   610 
       
   611 /* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */
       
   612 extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths);
       
   613 extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void);
       
   614 extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (*function)(const char*, void*), void *data);
   565 
   615 
   566 /* Get the Mix_Chunk currently associated with a mixer channel
   616 /* Get the Mix_Chunk currently associated with a mixer channel
   567     Returns NULL if it's an invalid channel, or there's no chunk associated.
   617     Returns NULL if it's an invalid channel, or there's no chunk associated.
   568 */
   618 */
   569 extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel);
   619 extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel);