diff options
Diffstat (limited to 'lib/newwrap/sdl/sdl_mixer_nosmpeg.nim')
-rwxr-xr-x | lib/newwrap/sdl/sdl_mixer_nosmpeg.nim | 471 |
1 files changed, 112 insertions, 359 deletions
diff --git a/lib/newwrap/sdl/sdl_mixer_nosmpeg.nim b/lib/newwrap/sdl/sdl_mixer_nosmpeg.nim index 571263014..3fe7cac14 100755 --- a/lib/newwrap/sdl/sdl_mixer_nosmpeg.nim +++ b/lib/newwrap/sdl/sdl_mixer_nosmpeg.nim @@ -3,7 +3,7 @@ #****************************************************************************** import - + sdl when defined(windows): const @@ -15,29 +15,24 @@ else: const MixerLibName = "libSDL_mixer.so" const - MIXER_MAJOR_VERSION* = 1'i8 - MIXER_MINOR_VERSION* = 2'i8 - MIXER_PATCHLEVEL* = 7'i8 # Backwards compatibility - MIX_MAJOR_VERSION* = MIXER_MAJOR_VERSION - MIX_MINOR_VERSION* = MIXER_MINOR_VERSION - MIX_PATCHLEVEL* = MIXER_PATCHLEVEL # SDL_Mixer.h constants - # The default mixer has 8 simultaneous mixing channels - MIX_CHANNELS* = 8 # Good default values for a PC soundcard - MIX_DEFAULT_FREQUENCY* = 22050 + MAJOR_VERSION* = 1'i8 + MINOR_VERSION* = 2'i8 + PATCHLEVEL* = 7'i8 # Backwards compatibility + + CHANNELS* = 8 # Good default values for a PC soundcard + DEFAULT_FREQUENCY* = 22050 when defined(IA32): const - MIX_DEFAULT_FORMAT* = AUDIO_S16LSB + DEFAULT_FORMAT* = AUDIO_S16LSB else: const - MIX_DEFAULT_FORMAT* = AUDIO_S16MSB + DEFAULT_FORMAT* = AUDIO_S16MSB const - MIX_DEFAULT_CHANNELS* = 2 - MIX_MAX_VOLUME* = 128 # Volume of a chunk - PATH_MAX* = 255 # mikmod.h constants - #* - # * Library version - # * + DEFAULT_CHANNELS* = 2 + MAX_VOLUME* = 128 # Volume of a chunk + PATH_MAX* = 255 + LIBMIKMOD_VERSION_MAJOR* = 3 LIBMIKMOD_VERSION_MINOR* = 1 LIBMIKMOD_REVISION* = 8 @@ -108,35 +103,33 @@ type #music_cmd.h types PUNIMOD* = ptr TUNIMOD TUNIMOD* = TMODULE #SDL_mixer.h types # The internal format for an audio chunk - PMix_Chunk* = ptr TMix_Chunk - TMix_Chunk*{.final.} = object + PChunk* = ptr TChunk + TChunk*{.final.} = object allocated*: int abuf*: PUint8 alen*: Uint32 volume*: Uint8 # Per-sample volume, 0-128 - Mix_Chunk* = TMix_Chunk # The different fading types supported - TMix_Fading* = enum + TFading* = enum MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN - Mix_Fading* = TMix_Fading - TMix_MusicType* = enum + TMusicType* = enum MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG - PMix_Music* = ptr TMix_Music - TMix_Music*{.final.} = object - type_*: TMix_MusicType + PMusic* = ptr TMusic + TMusic*{.final.} = object + type_*: TMusicType TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{. cdecl.} # This macro can be used to fill a version structure with the compile-time # version of the SDL_mixer library. -proc MIXER_VERSION*(X: var TVersion) +proc VERSION*(X: var sdl.TVersion) # This function gets the version of the dynamically linked SDL_mixer library. # It should NOT be used to fill a version structure, instead you should use the # SDL_MIXER_VERSION() macro. -proc Mix_Linked_Version*(): Pversion{.cdecl, importc: "Mix_Linked_Version", +proc Linked_Version*(): sdl.Pversion{.cdecl, importc: "Mix_Linked_Version", dynlib: MixerLibName.} # Open the mixer with a certain audio format -proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int, +proc OpenAudio*(frequency: int, format: Uint16, channels: int, chunksize: int): int{.cdecl, importc: "Mix_OpenAudio", dynlib: MixerLibName.} # Dynamically change the number of channels managed by the mixer. @@ -144,402 +137,170 @@ proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int, # stopped. # This function returns the new number of allocated channels. # -proc Mix_AllocateChannels*(numchannels: int): int{.cdecl, +proc AllocateChannels*(numchannels: int): int{.cdecl, importc: "Mix_AllocateChannels", dynlib: MixerLibName.} # Find out what the actual audio device parameters are. # This function returns 1 if the audio has been opened, 0 otherwise. # -proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{. +proc QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{. cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.} # Load a wave file or a music (.mod .s3m .it .xm) file -proc Mix_LoadWAV_RW*(src: PRWops, freesrc: int): PMix_Chunk{.cdecl, +proc LoadWAV_RW*(src: PRWops, freesrc: int): PChunk{.cdecl, importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.} -proc Mix_LoadWAV*(filename: cstring): PMix_Chunk -proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl, importc: "Mix_LoadMUS", +proc LoadWAV*(filename: cstring): PChunk +proc LoadMUS*(filename: cstring): PMusic{.cdecl, importc: "Mix_LoadMUS", dynlib: MixerLibName.} # Load a wave file of the mixer format from a memory buffer -proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl, +proc QuickLoad_WAV*(mem: PUint8): PChunk{.cdecl, importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.} # Free an audio chunk previously loaded -proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc: "Mix_FreeChunk", +proc FreeChunk*(chunk: PChunk){.cdecl, importc: "Mix_FreeChunk", dynlib: MixerLibName.} -proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc: "Mix_FreeMusic", +proc FreeMusic*(music: PMusic){.cdecl, importc: "Mix_FreeMusic", dynlib: MixerLibName.} # Find out the music format of a mixer music, or the currently playing # music, if 'music' is NULL. -proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl, +proc GetMusicType*(music: PMusic): TMusicType{.cdecl, importc: "Mix_GetMusicType", dynlib: MixerLibName.} # Set a function that is called after all mixing is performed. # This can be used to provide real-time visual display of the audio stream # or add a custom mixer filter for the stream data. # -proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl, +proc SetPostMix*(mixfunc: TMixFunction, arg: Pointer){.cdecl, importc: "Mix_SetPostMix", dynlib: MixerLibName.} # Add your own music player or additional mixer function. # If 'mix_func' is NULL, the default music player is re-enabled. # -proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl, +proc HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl, importc: "Mix_HookMusic", dynlib: MixerLibName.} # Add your own callback when the music has finished playing. # -proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl, +proc HookMusicFinished*(music_finished: Pointer){.cdecl, importc: "Mix_HookMusicFinished", dynlib: MixerLibName.} # Get a pointer to the user data for the current music hook -proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc: "Mix_GetMusicHookData", +proc GetMusicHookData*(): Pointer{.cdecl, importc: "Mix_GetMusicHookData", dynlib: MixerLibName.} #* Add your own callback when a channel has finished playing. NULL # * to disable callback.* type TChannel_finished* = proc (channel: int){.cdecl.} -proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl, +proc ChannelFinished*(channel_finished: TChannel_finished){.cdecl, importc: "Mix_ChannelFinished", dynlib: MixerLibName.} const - MIX_CHANNEL_POST* = - 2 #* This is the format of a special effect callback: - # * - # * myeffect(int chan, void *stream, int len, void *udata); - # * - # * (chan) is the channel number that your effect is affecting. (stream) is - # * the buffer of data to work upon. (len) is the size of (stream), and - # * (udata) is a user-defined bit of data, which you pass as the last arg of - # * Mix_RegisterEffect(), and is passed back unmolested to your callback. - # * Your effect changes the contents of (stream) based on whatever parameters - # * are significant, or just leaves it be, if you prefer. You can do whatever - # * you like to the buffer, though, and it will continue in its changed state - # * down the mixing pipeline, through any other effect functions, then finally - # * to be mixed with the rest of the channels and music for the final output - # * stream. - # * - + CHANNEL_POST* = - 2 + type - TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int, - udata: Pointer): Pointer{.cdecl.} # * This is a callback that signifies that a channel has finished all its - # * loops and has completed playback. This gets called if the buffer - # * plays out normally, or if you call Mix_HaltChannel(), implicitly stop - # * a channel via - # Mix_AllocateChannels(), or unregister a callback while - # * it's still playing. - TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.} #* Register a special effect function. At mixing time, the channel data is - # * copied into a buffer and passed through each registered effect function. - # * After it passes through all the functions, it is mixed into the final - # * output stream. The copy to buffer is performed once, then each effect - # * function performs on the output of the previous effect. Understand that - # * this extra copy to a buffer is not performed if there are no effects - # * registered for a given chunk, which saves CPU cycles, and any given - # * effect will be extra cycles, too, so it is crucial that your code run - # * fast. Also note that the data that your function is given is in the - # * format of the sound device, and not the format you gave to Mix_OpenAudio(), - # * although they may in reality be the same. This is an unfortunate but - # * necessary speed concern. Use Mix_QuerySpec() to determine if you can - # * handle the data before you register your effect, and take appropriate - # * actions. - # * You may also specify a callback (Mix_EffectDone_t) that is called when - # * the channel finishes playing. This gives you a more fine-grained control - # * than Mix_ChannelFinished(), in case you need to free effect-specific - # * resources, etc. If you don't need this, you can specify NULL. - # * You may set the callbacks before or after calling Mix_PlayChannel(). - # * Things like Mix_SetPanning() are just internal special effect functions, - # * so if you are using that, you've already incurred the overhead of a copy - # * to a separate buffer, and that these effects will be in the queue with - # * any functions you've registered. The list of registered effects for a - # * channel is reset when a chunk finishes playing, so you need to explicitly - # * set them with each call to Mix_PlayChannel*(). - # * You may also register a special effect function that is to be run after - # * final mixing occurs. The rules for these callbacks are identical to those - # * in Mix_RegisterEffect, but they are run after all the channels and the - # * music have been mixed into a single stream, whereas channel-specific - # * effects run on a given channel before any other mixing occurs. These - # * global effect callbacks are call "posteffects". Posteffects only have - # * their Mix_EffectDone_t function called when they are unregistered (since - # * the main output stream is never "done" in the same sense as a channel). - # * You must unregister them manually when you've had enough. Your callback - # * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the - # * processing is considered a posteffect. - # * - # * After all these effects have finished processing, the callback registered - # * through Mix_SetPostMix() runs, and then the stream goes to the audio - # * device. - # * - # * returns zero if error (no such channel), nonzero if added. - # * Error messages can be retrieved from Mix_GetError(). + TEffectFunc* = proc (chan: int, stream: Pointer, length: int, + udata: Pointer): Pointer{.cdecl.} + TEffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.} -proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone, +proc RegisterEffect*(chan: int, f: TEffectFunc, d: TEffectDone, arg: Pointer): int{.cdecl, importc: "Mix_RegisterEffect", dynlib: MixerLibName.} - #* You may not need to call this explicitly, unless you need to stop an - # * effect from processing in the middle of a chunk's playback. - # * Posteffects are never implicitly unregistered as they are for channels, - # * but they may be explicitly unregistered through this function by - # * specifying MIX_CHANNEL_POST for a channel. - # * returns zero if error (no such channel or effect), nonzero if removed. - # * Error messages can be retrieved from Mix_GetError(). - # * -proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl, + +proc UnregisterEffect*(channel: int, f: TEffectFunc): int{.cdecl, importc: "Mix_UnregisterEffect", dynlib: MixerLibName.} - #* You may not need to call this explicitly, unless you need to stop all - # * effects from processing in the middle of a chunk's playback. Note that - # * this will also shut off some internal effect processing, since - # * Mix_SetPanning( ) and others may use this API under the hood.This is - # * called internally when a channel completes playback. - # * Posteffects are never implicitly unregistered as they are for channels, - # * but they may be explicitly unregistered through this function by - # * specifying MIX_CHANNEL_POST for a channel. - # * returns zero if error( no such channel ), nonzero if all effects removed. - # * Error messages can be retrieved from Mix_GetError( ). - # * -proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl, + +proc UnregisterAllEffects*(channel: int): int{.cdecl, importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.} -const - MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED" # * These are the internally - defined mixing effects.They use the same API that - # * effects defined in the application use, but are provided here as a - # * convenience.Some effects can reduce their quality or use more memory in - # * the name of speed; to enable this, make sure the environment variable - # * MIX_EFFECTSMAXSPEED( see above ) is defined before you call - # * Mix_OpenAudio( ). - # * - #* set the panning of a channel.The left and right channels are specified - # * as integers between 0 and 255, quietest to loudest, respectively. - # * - # * Technically, this is just individual volume control for a sample with - # * two( stereo )channels, so it can be used for more than just panning. - # * if you want real panning, call it like this : - # * - # * Mix_SetPanning( channel, left, 255 - left ); - # * - # * ...which isn't so hard. - # * - # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and - # * the panning will be done to the final mixed stream before passing it on - # * to the audio device. - # * - # * This uses the Mix_RegisterEffect( )API internally, and returns without - # * registering the effect function if the audio device is not configured - # * for stereo output.Setting both( left ) and ( right ) to 255 causes this - # * effect to be unregistered, since that is the data's normal state. - # * - # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), - # * nonzero if panning effect enabled.Note that an audio device in mono - # * mode is a no - op, but this call will return successful in that case . - # * Error messages can be retrieved from Mix_GetError( ). -proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl, +const + EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED" + +proc SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl, importc: "Mix_SetPanning", dynlib: MixerLibName.} - # * set the position ofa channel.( angle ) is an integer from 0 to 360, that - # * specifies the location of the sound in relation to the listener.( angle ) - # * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ). - # * Angle 0 is due north, and rotates clockwise as the value increases. - # * for efficiency, the precision of this effect may be limited( angles 1 - # * through 7 might all produce the same effect, 8 through 15 are equal, etc ). - # * ( distance ) is an integer between 0 and 255 that specifies the space - # * between the sound and the listener.The larger the number, the further - # * away the sound is .Using 255 does not guarantee that the channel will be - # * culled from the mixing process or be completely silent.For efficiency, - # * the precision of this effect may be limited( distance 0 through 5 might - # * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle ) - # * and ( distance ) to 0 unregisters this effect, since the data would be - # * unchanged. - # * - # * if you need more precise positional audio, consider using OpenAL for - # * spatialized effects instead of SDL_mixer.This is only meant to be a - # * basic effect for simple "3D" games. - # * - # * if the audio device is configured for mono output, then you won't get - # * any effectiveness from the angle; however, distance attenuation on the - # * channel will still occur.While this effect will function with stereo - # * voices, it makes more sense to use voices with only one channel of sound, - # * so when they are mixed through this effect, the positioning will sound - # * correct.You can convert them to mono through SDL before giving them to - # * the mixer in the first place if you like. - # * - # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and - # * the positioning will be done to the final mixed stream before passing it - # * on to the audio device. - # * - # * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ). - # * - # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), - # * nonzero if position effect is enabled. - # * Error messages can be retrieved from Mix_GetError( ). - # * -proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl, + +proc SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl, importc: "Mix_SetPosition", dynlib: MixerLibName.} - #* set the "distance" of a channel.( distance ) is an integer from 0 to 255 - # * that specifies the location of the sound in relation to the listener. - # * Distance 0 is overlapping the listener, and 255 is as far away as possible - # * A distance of 255 does not guarantee silence; in such a case , you might - # * want to try changing the chunk's volume, or just cull the sample from the - # * mixing process with Mix_HaltChannel( ). - # * for efficiency, the precision of this effect may be limited( distances 1 - # * through 7 might all produce the same effect, 8 through 15 are equal, etc ). - # * ( distance ) is an integer between 0 and 255 that specifies the space - # * between the sound and the listener.The larger the number, the further - # * away the sound is . - # * Setting( distance ) to 0 unregisters this effect, since the data would be - # * unchanged. - # * if you need more precise positional audio, consider using OpenAL for - # * spatialized effects instead of SDL_mixer.This is only meant to be a - # * basic effect for simple "3D" games. - # * - # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and - # * the distance attenuation will be done to the final mixed stream before - # * passing it on to the audio device. - # * - # * This uses the Mix_RegisterEffect( )API internally. - # * - # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), - # * nonzero if position effect is enabled. - # * Error messages can be retrieved from Mix_GetError( ). - # * -proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl, + +proc SetDistance*(channel: int, distance: Uint8): int{.cdecl, importc: "Mix_SetDistance", dynlib: MixerLibName.} - # * - # * !!! FIXME : Haven't implemented, since the effect goes past the - # * end of the sound buffer.Will have to think about this. - # * - -ryan. - # * / - # { if 0 - # { * Causes an echo effect to be mixed into a sound.( echo ) is the amount - # * of echo to mix.0 is no echo, 255 is infinite( and probably not - # * what you want ). - # * - # * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and - # * the reverbing will be done to the final mixed stream before passing it on - # * to the audio device. - # * - # * This uses the Mix_RegisterEffect( )API internally.If you specify an echo - # * of zero, the effect is unregistered, as the data is already in that state. - # * - # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), - # * nonzero if reversing effect is enabled. - # * Error messages can be retrieved from Mix_GetError( ). - # * - # extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo ); - # #E ndif - # * Causes a channel to reverse its stereo.This is handy if the user has his - # * speakers hooked up backwards, or you would like to have a minor bit of - # * psychedelia in your sound code. : )Calling this function with ( flip ) - # * set to non - zero reverses the chunks's usual channels. If (flip) is zero, - # * the effect is unregistered. - # * - # * This uses the Mix_RegisterEffect( )API internally, and thus is probably - # * more CPU intensive than having the user just plug in his speakers - # * correctly.Mix_SetReverseStereo( )returns without registering the effect - # * function if the audio device is not configured for stereo output. - # * - # * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used - # * on the final mixed stream before sending it on to the audio device( a - # * posteffect ). - # * - # * returns zero if error( no such channel or Mix_RegisterEffect( )fails ), - # * nonzero if reversing effect is enabled.Note that an audio device in mono - # * mode is a no - op, but this call will return successful in that case . - # * Error messages can be retrieved from Mix_GetError( ). - # * -proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl, + +proc SetReverseStereo*(channel: int, flip: int): int{.cdecl, importc: "Mix_SetReverseStereo", dynlib: MixerLibName.} - # end of effects API. - -ryan. * - # Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate - # them dynamically to the next sample if requested with a -1 value below. - # Returns the number of reserved channels. - # -proc Mix_ReserveChannels*(num: int): int{.cdecl, importc: "Mix_ReserveChannels", + +proc ReserveChannels*(num: int): int{.cdecl, importc: "Mix_ReserveChannels", dynlib: MixerLibName.} - # Channel grouping functions - # Attach a tag to a channel. A tag can be assigned to several mixer - # channels, to form groups of channels. - # If 'tag' is -1, the tag is removed (actually -1 is the tag used to - # represent the group of all the channels). - # Returns true if everything was OK. - # -proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl, + +proc GroupChannel*(which: int, tag: int): int{.cdecl, importc: "Mix_GroupChannel", dynlib: MixerLibName.} # Assign several consecutive channels to a group -proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl, +proc GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl, importc: "Mix_GroupChannels", dynlib: MixerLibName.} # Finds the first available channel in a group of channels -proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc: "Mix_GroupAvailable", +proc GroupAvailable*(tag: int): int{.cdecl, importc: "Mix_GroupAvailable", dynlib: MixerLibName.} # Returns the number of channels in a group. This is also a subtle # way to get the total number of channels when 'tag' is -1 # -proc Mix_GroupCount*(tag: int): int{.cdecl, importc: "Mix_GroupCount", +proc GroupCount*(tag: int): int{.cdecl, importc: "Mix_GroupCount", dynlib: MixerLibName.} # Finds the "oldest" sample playing in a group of channels -proc Mix_GroupOldest*(tag: int): int{.cdecl, importc: "Mix_GroupOldest", +proc GroupOldest*(tag: int): int{.cdecl, importc: "Mix_GroupOldest", dynlib: MixerLibName.} # Finds the "most recent" (i.e. last) sample playing in a group of channels -proc Mix_GroupNewer*(tag: int): int{.cdecl, importc: "Mix_GroupNewer", +proc GroupNewer*(tag: int): int{.cdecl, importc: "Mix_GroupNewer", dynlib: MixerLibName.} # The same as above, but the sound is played at most 'ticks' milliseconds -proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int, +proc PlayChannelTimed*(channel: int, chunk: PChunk, loops: int, ticks: int): int{.cdecl, importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.} - # Play an audio chunk on a specific channel. - # If the specified channel is -1, play on the first free channel. - # If 'loops' is greater than zero, loop the sound that many times. - # If 'loops' is -1, loop inifinitely (~65000 times). - # Returns which channel was used to play the sound. - # -proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int -proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl, + +proc PlayChannel*(channel: int, chunk: PChunk, loops: int): int +proc PlayMusic*(music: PMusic, loops: int): int{.cdecl, importc: "Mix_PlayMusic", dynlib: MixerLibName.} # Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions -proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl, +proc FadeInMusic*(music: PMusic, loops: int, ms: int): int{.cdecl, importc: "Mix_FadeInMusic", dynlib: MixerLibName.} -proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int, +proc FadeInChannelTimed*(channel: int, chunk: PChunk, loops: int, ms: int, ticks: int): int{.cdecl, importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.} -proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int +proc FadeInChannel*(channel: int, chunk: PChunk, loops: int, ms: int): int # Set the volume in the range of 0-128 of a specific channel or chunk. # If the specified channel is -1, set volume for all channels. # Returns the original volume. # If the specified volume is -1, just return the current volume. # -proc Mix_Volume*(channel: int, volume: int): int{.cdecl, importc: "Mix_Volume", +proc Volume*(channel: int, volume: int): int{.cdecl, importc: "Mix_Volume", dynlib: MixerLibName.} -proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl, +proc VolumeChunk*(chunk: PChunk, volume: int): int{.cdecl, importc: "Mix_VolumeChunk", dynlib: MixerLibName.} -proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc: "Mix_VolumeMusic", +proc VolumeMusic*(volume: int): int{.cdecl, importc: "Mix_VolumeMusic", dynlib: MixerLibName.} # Halt playing of a particular channel -proc Mix_HaltChannel*(channel: int): int{.cdecl, importc: "Mix_HaltChannel", +proc HaltChannel*(channel: int): int{.cdecl, importc: "Mix_HaltChannel", dynlib: MixerLibName.} -proc Mix_HaltGroup*(tag: int): int{.cdecl, importc: "Mix_HaltGroup", +proc HaltGroup*(tag: int): int{.cdecl, importc: "Mix_HaltGroup", dynlib: MixerLibName.} -proc Mix_HaltMusic*(): int{.cdecl, importc: "Mix_HaltMusic", +proc HaltMusic*(): int{.cdecl, importc: "Mix_HaltMusic", dynlib: MixerLibName.} - # Change the expiration delay for a particular channel. - # The sample will stop playing after the 'ticks' milliseconds have elapsed, - # or remove the expiration if 'ticks' is -1 - # -proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl, + +proc ExpireChannel*(channel: int, ticks: int): int{.cdecl, importc: "Mix_ExpireChannel", dynlib: MixerLibName.} - # Halt a channel, fading it out progressively till it's silent - # The ms parameter indicates the number of milliseconds the fading - # will take. - # -proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl, + +proc FadeOutChannel*(which: int, ms: int): int{.cdecl, importc: "Mix_FadeOutChannel", dynlib: MixerLibName.} -proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl, +proc FadeOutGroup*(tag: int, ms: int): int{.cdecl, importc: "Mix_FadeOutGroup", dynlib: MixerLibName.} -proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc: "Mix_FadeOutMusic", +proc FadeOutMusic*(ms: int): int{.cdecl, importc: "Mix_FadeOutMusic", dynlib: MixerLibName.} # Query the fading status of a channel -proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc: "Mix_FadingMusic", +proc FadingMusic*(): TFading{.cdecl, importc: "Mix_FadingMusic", dynlib: MixerLibName.} -proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl, +proc FadingChannel*(which: int): TFading{.cdecl, importc: "Mix_FadingChannel", dynlib: MixerLibName.} # Pause/Resume a particular channel -proc Mix_Pause*(channel: int){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.} -proc Mix_Resume*(channel: int){.cdecl, importc: "Mix_Resume", +proc Pause*(channel: int){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.} +proc Resume*(channel: int){.cdecl, importc: "Mix_Resume", dynlib: MixerLibName.} -proc Mix_Paused*(channel: int): int{.cdecl, importc: "Mix_Paused", +proc Paused*(channel: int): int{.cdecl, importc: "Mix_Paused", dynlib: MixerLibName.} # Pause/Resume the music stream -proc Mix_PauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.} -proc Mix_ResumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.} -proc Mix_RewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.} -proc Mix_PausedMusic*(): int{.cdecl, importc: "Mix_PausedMusic", +proc PauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.} +proc ResumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.} +proc RewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.} +proc PausedMusic*(): int{.cdecl, importc: "Mix_PausedMusic", dynlib: MixerLibName.} # Set the current position in the music stream. # This returns 0 if successful, or -1 if it failed or isn't implemented. @@ -547,52 +308,44 @@ proc Mix_PausedMusic*(): int{.cdecl, importc: "Mix_PausedMusic", # order number) and for OGG music (set position in seconds), at the # moment. # -proc Mix_SetMusicPosition*(position: float64): int{.cdecl, +proc SetMusicPosition*(position: float64): int{.cdecl, importc: "Mix_SetMusicPosition", dynlib: MixerLibName.} # Check the status of a specific channel. # If the specified channel is -1, check all channels. # -proc Mix_Playing*(channel: int): int{.cdecl, importc: "Mix_Playing", +proc Playing*(channel: int): int{.cdecl, importc: "Mix_Playing", dynlib: MixerLibName.} -proc Mix_PlayingMusic*(): int{.cdecl, importc: "Mix_PlayingMusic", +proc PlayingMusic*(): int{.cdecl, importc: "Mix_PlayingMusic", dynlib: MixerLibName.} # Stop music and set external music playback command -proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc: "Mix_SetMusicCMD", +proc SetMusicCMD*(command: cstring): int{.cdecl, importc: "Mix_SetMusicCMD", dynlib: MixerLibName.} # Synchro value is set by MikMod from modules while playing -proc Mix_SetSynchroValue*(value: int): int{.cdecl, +proc SetSynchroValue*(value: int): int{.cdecl, importc: "Mix_SetSynchroValue", dynlib: MixerLibName.} -proc Mix_GetSynchroValue*(): int{.cdecl, importc: "Mix_GetSynchroValue", +proc GetSynchroValue*(): int{.cdecl, importc: "Mix_GetSynchroValue", dynlib: MixerLibName.} # # Get the Mix_Chunk currently associated with a mixer channel # Returns nil if it's an invalid channel, or there's no chunk associated. # -proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc: "Mix_GetChunk", +proc GetChunk*(channel: int): PChunk{.cdecl, importc: "Mix_GetChunk", dynlib: MixerLibName.} # Close the mixer, halting all playing audio -proc Mix_CloseAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.} +proc CloseAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.} # We'll use SDL for reporting errors -proc Mix_SetError*(fmt: cstring) -proc Mix_GetError*(): cstring -# implementation - -proc MIXER_VERSION(X: var Tversion) = - X.major = MIXER_MAJOR_VERSION - X.minor = MIXER_MINOR_VERSION - X.patch = MIXER_PATCHLEVEL -proc Mix_LoadWAV(filename: cstring): PMix_Chunk = - result = Mix_LoadWAV_RW(RWFromFile(filename, "rb"), 1) +proc VERSION(X: var Tversion) = + X.major = MAJOR_VERSION + X.minor = MINOR_VERSION + X.patch = PATCHLEVEL -proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int = - result = Mix_PlayChannelTimed(channel, chunk, loops, - 1) +proc LoadWAV(filename: cstring): PChunk = + result = LoadWAV_RW(RWFromFile(filename, "rb"), 1) -proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int = - result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1) +proc PlayChannel(channel: int, chunk: PChunk, loops: int): int = + result = PlayChannelTimed(channel, chunk, loops, - 1) -proc Mix_SetError(fmt: cstring) = - SetError(fmt) +proc FadeInChannel(channel: int, chunk: PChunk, loops: int, ms: int): int = + result = FadeInChannelTimed(channel, chunk, loops, ms, - 1) -proc Mix_GetError(): cstring = - result = GetError() |