# Module sdl_mixer

# Imports

sdl, smpeg

# Types

    PMusicCMD = ptr TMusicCMD

    TMusicCMD = object
      filename*: array[0 .. 255 - 1, char]
      cmd*: array[0 .. 255 - 1, char]
      pid*: TSYS_ThreadHandle

    PWAVStream = ptr TWAVStream

    TWAVStream = object
      wavefp*: pointer
      start*: int32
      stop*: int32
      cvt*: TAudioCVT

    PMidiEvent = ptr TMidiEvent

    TMidiEvent = object
      time*: int32
      channel*: Byte
      typ*: Byte
      a*: Byte
      b*: Byte

    PMidiSong = ptr TMidiSong

    TMidiSong = object
      samples*: int32
      events*: PMidiEvent

    POGG_Music = ptr TOGG_Music

    TOGG_Music = object
      playing*: int32
      volume*: int32
      section*: int32
      cvt*: TAudioCVT
      len_available*: int32
      snd_available*: pointer

    TErrorEnum = enum
      MMERR_OPENING_FILE, MMERR_OUT_OF_MEMORY, MMERR_DYNAMIC_LINKING,
      MMERR_SAMPLE_TOO_BIG, MMERR_OUT_OF_HANDLES, MMERR_UNKNOWN_WAVE_TYPE,
      MMERR_LOADING_PATTERN, MMERR_LOADING_TRACK, MMERR_LOADING_HEADER,
      MMERR_LOADING_SAMPLEINFO, MMERR_NOT_A_MODULE, MMERR_NOT_A_STREAM,
      MMERR_MED_SYNTHSAMPLES, MMERR_ITPACK_INVALID_DATA, MMERR_DETECTING_DEVICE,
      MMERR_INVALID_DEVICE, MMERR_INITIALIZING_MIXER, MMERR_OPENING_AUDIO,
      MMERR_8BIT_ONLY, MMERR_16BIT_ONLY, MMERR_STEREO_ONLY, MMERR_ULAW,
      MMERR_NON_BLOCK, MMERR_AF_AUDIO_PORT, MMERR_AIX_CONFIG_INIT,
      MMERR_AIX_CONFIG_CONTROL, MMERR_AIX_CONFIG_START, MMERR_GUS_SETTINGS,
      MMERR_GUS_RESET, MMERR_GUS_TIMER, MMERR_HP_SETSAMPLESIZE, MMERR_HP_SETSPEED,
      MMERR_HP_CHANNELS, MMERR_HP_AUDIO_OUTPUT, MMERR_HP_AUDIO_DESC,
      MMERR_HP_BUFFERSIZE, MMERR_OSS_SETFRAGMENT, MMERR_OSS_SETSAMPLESIZE,
      MMERR_OSS_SETSTEREO, MMERR_OSS_SETSPEED, MMERR_SGI_SPEED, MMERR_SGI_16BIT,
      MMERR_SGI_8BIT, MMERR_SGI_STEREO, MMERR_SGI_MONO, MMERR_SUN_INIT,
      MMERR_OS2_MIXSETUP, MMERR_OS2_SEMAPHORE, MMERR_OS2_TIMER, MMERR_OS2_THREAD,
      MMERR_DS_PRIORITY, MMERR_DS_BUFFER, MMERR_DS_FORMAT, MMERR_DS_NOTIFY,
      MMERR_DS_EVENT, MMERR_DS_THREAD, MMERR_DS_UPDATE, MMERR_WINMM_HANDLE,
      MMERR_WINMM_ALLOCATED, MMERR_WINMM_DEVICEID, MMERR_WINMM_FORMAT,
      MMERR_WINMM_UNKNOWN, MMERR_MAC_SPEED, MMERR_MAC_START, MMERR_MAX

    PMODULE = ptr TMODULE

    TMODULE = object

    PUNIMOD = ptr TUNIMOD

    TUNIMOD = TMODULE

    PChunk = ptr TChunk

    TChunk = object
      allocated*: cint
      abuf*: pointer
      alen*: uint32
      volume*: Byte

    TFading = enum
      MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN

    TMusicType = enum
      MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3

    PMusic = ptr TMusic

    TMusic = object
      mixtype*: TMusicType

    TMixFunction = proc (udata, stream: pointer; length: cint): pointer {.cdecl.}

    TChannel_finished = proc (channel: cint) {.cdecl.}

    TEffectFunc = proc (chan: cint; stream: pointer; length: cint; udata: pointer): pointer {.
        cdecl.}

    TEffectDone = proc (chan: cint; udata: pointer): pointer {.cdecl.}

# Consts

    MAJOR_VERSION = 1

    MINOR_VERSION = 2

    PATCHLEVEL = 7

    CHANNELS = 8

    DEFAULT_FREQUENCY = 22050

    DEFAULT_FORMAT = 0x00009010

    DEFAULT_CHANNELS = 2

    MAX_VOLUME = 128

    PATH_MAX = 255

    LIBMIKMOD_VERSION_MAJOR = 3

    LIBMIKMOD_VERSION_MINOR = 1

    LIBMIKMOD_REVISION = 8

    LIBMIKMOD_VERSION = 196872

    CHANNEL_POST = -2

    EFFECTSMAXSPEED = "MIX_EFFECTSMAXSPEED"

# Procs

    proc Linked_Version(): Pversion {.cdecl, importc: "Mix_Linked_Version",
                                      dynlib: MixerLibName.}

    proc OpenAudio(frequency: cint; format: uint16; channels: cint; chunksize: cint): cint {.
        cdecl, importc: "Mix_OpenAudio", dynlib: MixerLibName.}

    proc AllocateChannels(numchannels: cint): cint {.cdecl,
        importc: "Mix_AllocateChannels", dynlib: MixerLibName.}

    proc QuerySpec(frequency: var cint; format: var uint16; channels: var cint): cint {.
        cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.}

    proc LoadWAV_RW(src: PRWops; freesrc: cint): PChunk {.cdecl,
        importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.}

    proc LoadMUS(filename: cstring): PMusic {.cdecl, importc: "Mix_LoadMUS",
        dynlib: MixerLibName.}

    proc QuickLoad_WAV(mem: pointer): PChunk {.cdecl, importc: "Mix_QuickLoad_WAV",
        dynlib: MixerLibName.}

    proc FreeChunk(chunk: PChunk) {.cdecl, importc: "Mix_FreeChunk",
                                    dynlib: MixerLibName.}

    proc FreeMusic(music: PMusic) {.cdecl, importc: "Mix_FreeMusic",
                                    dynlib: MixerLibName.}

    proc GetMusicType(music: PMusic): TMusicType {.cdecl,
        importc: "Mix_GetMusicType", dynlib: MixerLibName.}

    proc SetPostMix(mix_func: TMixFunction; arg: pointer) {.cdecl,
        importc: "Mix_SetPostMix", dynlib: MixerLibName.}

    proc HookMusic(mix_func: TMixFunction; arg: pointer) {.cdecl,
        importc: "Mix_HookMusic", dynlib: MixerLibName.}

    proc HookMusicFinished(music_finished: pointer) {.cdecl,
        importc: "Mix_HookMusicFinished", dynlib: MixerLibName.}

    proc GetMusicHookData(): pointer {.cdecl, importc: "Mix_GetMusicHookData",
                                       dynlib: MixerLibName.}

    proc ChannelFinished(channel_finished: TChannel_finished) {.cdecl,
        importc: "Mix_ChannelFinished", dynlib: MixerLibName.}

    proc RegisterEffect(chan: cint; f: TEffectFunc; d: TEffectDone; arg: pointer): cint {.
        cdecl, importc: "Mix_RegisterEffect", dynlib: MixerLibName.}

    proc UnregisterEffect(channel: cint; f: TEffectFunc): cint {.cdecl,
        importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}

    proc UnregisterAllEffects(channel: cint): cint {.cdecl,
        importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}

    proc SetPanning(channel: cint; left: Byte; right: Byte): cint {.cdecl,
        importc: "Mix_SetPanning", dynlib: MixerLibName.}

    proc SetPosition(channel: cint; angle: int16; distance: Byte): cint {.cdecl,
        importc: "Mix_SetPosition", dynlib: MixerLibName.}

    proc SetDistance(channel: cint; distance: Byte): cint {.cdecl,
        importc: "Mix_SetDistance", dynlib: MixerLibName.}

    proc SetReverseStereo(channel: cint; flip: cint): cint {.cdecl,
        importc: "Mix_SetReverseStereo", dynlib: MixerLibName.}

    proc ReserveChannels(num: cint): cint {.cdecl, importc: "Mix_ReserveChannels",
                                            dynlib: MixerLibName.}

    proc GroupChannel(which: cint; tag: cint): cint {.cdecl,
        importc: "Mix_GroupChannel", dynlib: MixerLibName.}

    proc GroupChannels(`from`: cint; `to`: cint; tag: cint): cint {.cdecl,
        importc: "Mix_GroupChannels", dynlib: MixerLibName.}

    proc GroupAvailable(tag: cint): cint {.cdecl, importc: "Mix_GroupAvailable",
                                           dynlib: MixerLibName.}

    proc GroupCount(tag: cint): cint {.cdecl, importc: "Mix_GroupCount",
                                       dynlib: MixerLibName.}

    proc GroupOldest(tag: cint): cint {.cdecl, importc: "Mix_GroupOldest",
                                        dynlib: MixerLibName.}

    proc GroupNewer(tag: cint): cint {.cdecl, importc: "Mix_GroupNewer",
                                       dynlib: MixerLibName.}

    proc PlayChannelTimed(channel: cint; chunk: PChunk; loops: cint; ticks: cint): cint {.
        cdecl, importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.}

    proc PlayMusic(music: PMusic; loops: cint): cint {.cdecl,
        importc: "Mix_PlayMusic", dynlib: MixerLibName.}

    proc FadeInMusic(music: PMusic; loops: cint; ms: cint): cint {.cdecl,
        importc: "Mix_FadeInMusic", dynlib: MixerLibName.}

    proc FadeInChannelTimed(channel: cint; chunk: PChunk; loops: cint; ms: cint;
                            ticks: cint): cint {.cdecl,
        importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.}

    proc Volume(channel: cint; volume: cint): cint {.cdecl, importc: "Mix_Volume",
        dynlib: MixerLibName.}

    proc VolumeChunk(chunk: PChunk; volume: cint): cint {.cdecl,
        importc: "Mix_VolumeChunk", dynlib: MixerLibName.}

    proc VolumeMusic(volume: cint): cint {.cdecl, importc: "Mix_VolumeMusic",
                                           dynlib: MixerLibName.}

    proc HaltChannel(channel: cint): cint {.cdecl, importc: "Mix_HaltChannel",
                                            dynlib: MixerLibName.}

    proc HaltGroup(tag: cint): cint {.cdecl, importc: "Mix_HaltGroup",
                                      dynlib: MixerLibName.}

    proc HaltMusic(): cint {.cdecl, importc: "Mix_HaltMusic", dynlib: MixerLibName.}

    proc ExpireChannel(channel: cint; ticks: cint): cint {.cdecl,
        importc: "Mix_ExpireChannel", dynlib: MixerLibName.}

    proc FadeOutChannel(which: cint; ms: cint): cint {.cdecl,
        importc: "Mix_FadeOutChannel", dynlib: MixerLibName.}

    proc FadeOutGroup(tag: cint; ms: cint): cint {.cdecl,
        importc: "Mix_FadeOutGroup", dynlib: MixerLibName.}

    proc FadeOutMusic(ms: cint): cint {.cdecl, importc: "Mix_FadeOutMusic",
                                        dynlib: MixerLibName.}

    proc FadingMusic(): TFading {.cdecl, importc: "Mix_FadingMusic",
                                  dynlib: MixerLibName.}

    proc FadingChannel(which: cint): TFading {.cdecl, importc: "Mix_FadingChannel",
        dynlib: MixerLibName.}

    proc Pause(channel: cint) {.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.}

    proc Resume(channel: cint) {.cdecl, importc: "Mix_Resume", dynlib: MixerLibName.}

    proc Paused(channel: cint): cint {.cdecl, importc: "Mix_Paused",
                                       dynlib: MixerLibName.}

    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(): cint {.cdecl, importc: "Mix_PausedMusic",
                               dynlib: MixerLibName.}

    proc SetMusicPosition(position: float64): cint {.cdecl,
        importc: "Mix_SetMusicPosition", dynlib: MixerLibName.}

    proc Playing(channel: cint): cint {.cdecl, importc: "Mix_Playing",
                                        dynlib: MixerLibName.}

    proc PlayingMusic(): cint {.cdecl, importc: "Mix_PlayingMusic",
                                dynlib: MixerLibName.}

    proc SetMusicCMD(command: cstring): cint {.cdecl, importc: "Mix_SetMusicCMD",
        dynlib: MixerLibName.}

    proc SetSynchroValue(value: cint): cint {.cdecl, importc: "Mix_SetSynchroValue",
        dynlib: MixerLibName.}

    proc GetSynchroValue(): cint {.cdecl, importc: "Mix_GetSynchroValue",
                                   dynlib: MixerLibName.}

    proc GetChunk(channel: cint): PChunk {.cdecl, importc: "Mix_GetChunk",
                                           dynlib: MixerLibName.}

    proc CloseAudio() {.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}

    proc VERSION(X: var Tversion) {.raises: [], tags: [].}

    proc LoadWAV(filename: cstring): PChunk {.raises: [], tags: [].}

    proc PlayChannel(channel: cint; chunk: PChunk; loops: cint): cint {.raises: [],
        tags: [].}

    proc FadeInChannel(channel: cint; chunk: PChunk; loops: cint; ms: cint): cint {.
        raises: [], tags: [].}

Generated: 2013-05-21 09:55:06 UTC