# nodesnim/thirdparty/sdl2/mixer

Dark Mode

Search:
Group by:

# Imports

../sdl2, audio

# Types

    ChunkPtr = ptr Chunk

    Chunk = object
      allocated*: cint
      abuf*: ptr uint8
      alen*: uint32
      volume*: uint8

    Fading {...}{.size: 4.} = enum
      MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN

    MusicType {...}{.size: 4.} = enum
      MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3, MUS_MP3_MAD, MUS_FLAC,
      MUS_MODPLUG

    MusicPtr = ptr Music

    Music = object

    Mix_EffectFunc_t = proc (chan: cint; stream: pointer; len: cint; udata: pointer) {...}{.cdecl.}

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

# Consts

    LibName = "libSDL2_mixer(|-2.0).so(|.0)"

    MIX_DEFAULT_FORMAT = 0x00008010

    MIX_INIT_FLAC: cint = 0x00000001

    MIX_INIT_MOD: cint = 0x00000002

    MIX_INIT_MODPLUG: cint = 0x00000004

    MIX_INIT_MP3: cint = 0x00000008

    MIX_INIT_OGG: cint = 0x00000010

    MIX_INIT_FLUIDSYNTH: cint = 0x00000020

    MIX_CHANNELS = 8

    MIX_DEFAULT_FREQUENCY = 22050

    MIX_DEFAULT_CHANNELS = 2

    MIX_MAX_VOLUME = 128

    MIX_CHANNEL_POST = -2

    MIX_EFFECTSMAXSPEED = "MIX_EFFECTSMAXSPEED"

# Procs

    proc linkedVersion(): ptr SDL_Version {...}{.importc: "Mix_Linked_Version".}

    proc init(flags: cint): cint {...}{.importc: "Mix_Init".}

    proc quit() {...}{.importc: "Mix_Quit".}

    proc openAudio(frequency: cint; format: uint16; channels: cint; chunksize: cint): cint {...}{.
        importc: "Mix_OpenAudio".}

    proc allocateChannels(numchans: cint): cint {...}{.importc: "Mix_AllocateChannels".}

    proc querySpec(frequency: ptr cint; format: ptr uint16; channels: ptr cint): cint {...}{.
        importc: "Mix_QuerySpec".}

    proc loadWAV_RW(src: RWopsPtr; freesrc: cint): ptr Chunk {...}{.importc: "Mix_LoadWAV_RW".}

    proc loadMUS(file: cstring): ptr Music {...}{.importc: "Mix_LoadMUS".}

    proc loadMUS_RW(src: RWopsPtr; freesrc: cint): ptr Music {...}{.importc: "Mix_LoadMUS_RW".}

    proc loadMUSType_RW(src: RWopsPtr; `type`: MusicType; freesrc: cint): ptr Music {...}{.
        importc: "Mix_LoadMUSType_RW".}

    proc quickLoad_WAV(mem: ptr uint8): ptr Chunk {...}{.importc: "Mix_QuickLoad_WAV".}

    proc quickLoad_RAW(mem: ptr uint8; len: uint32): ptr Chunk {...}{.
        importc: "Mix_QuickLoad_RAW".}

    proc freeChunk(chunk: ptr Chunk) {...}{.importc: "Mix_FreeChunk".}

    proc freeMusic(music: ptr Music) {...}{.importc: "Mix_FreeMusic".}

    proc getNumChunkDecoders(): cint {...}{.importc: "Mix_GetNumChunkDecoders".}

    proc getChunkDecoder(index: cint): cstring {...}{.importc: "Mix_GetChunkDecoder".}

    proc getNumMusicDecoders(): cint {...}{.importc: "Mix_GetNumMusicDecoders".}

    proc getMusicDecoder(index: cint): cstring {...}{.importc: "Mix_GetMusicDecoder".}

    proc getMusicType(music: ptr Music): MusicType {...}{.importc: "Mix_GetMusicType".}

    proc setPostMix(mix_func: proc (udata: pointer; stream: ptr uint8; len: cint) {...}{.cdecl.};
                   arg: pointer) {...}{.importc: "Mix_SetPostMix".}

    proc hookMusic(mix_func: proc (udata: pointer; stream: ptr uint8; len: cint) {...}{.cdecl.};
                  arg: pointer) {...}{.importc: "Mix_HookMusic".}

    proc hookMusicFinished(music_finished: proc () {...}{.cdecl.}) {...}{.
        importc: "Mix_HookMusicFinished".}

    proc getMusicHookData(): pointer {...}{.importc: "Mix_GetMusicHookData".}

    proc channelFinished(channel_finished: proc (channel: cint) {...}{.cdecl.}) {...}{.
        importc: "Mix_ChannelFinished".}

    proc registerEffect(chan: cint; f: Mix_EffectFunc_t; d: Mix_EffectDone_t; arg: pointer): cint {...}{.
        importc: "Mix_RegisterEffect".}

    proc unregisterEffect(channel: cint; f: Mix_EffectFunc_t): cint {...}{.
        importc: "Mix_UnregisterEffect".}

    proc unregisterAllEffects(channel: cint): cint {...}{.importc: "Mix_UnregisterAllEffects".}

    proc setPanning(channel: cint; left: uint8; right: uint8): cint {...}{.
        importc: "Mix_SetPanning".}

    proc setPosition(channel: cint; angle: int16; distance: uint8): cint {...}{.
        importc: "Mix_SetPosition".}

    proc setDistance(channel: cint; distance: uint8): cint {...}{.importc: "Mix_SetDistance".}

    proc setReverseStereo(channel: cint; flip: cint): cint {...}{.
        importc: "Mix_SetReverseStereo".}

    proc reserveChannels(num: cint): cint {...}{.importc: "Mix_ReserveChannels".}

    proc groupChannel(which: cint; tag: cint): cint {...}{.importc: "Mix_GroupChannel".}

    proc groupChannels(`from`: cint; to: cint; tag: cint): cint {...}{.
        importc: "Mix_GroupChannels".}

    proc groupAvailable(tag: cint): cint {...}{.importc: "Mix_GroupAvailable".}

    proc groupCount(tag: cint): cint {...}{.importc: "Mix_GroupCount".}

    proc groupOldest(tag: cint): cint {...}{.importc: "Mix_GroupOldest".}

    proc groupNewer(tag: cint): cint {...}{.importc: "Mix_GroupNewer".}

    proc playChannelTimed(channel: cint; chunk: ptr Chunk; loops: cint; ticks: cint): cint {...}{.
        importc: "Mix_PlayChannelTimed".}

    proc playMusic(music: ptr Music; loops: cint): cint {...}{.importc: "Mix_PlayMusic".}

    proc fadeInMusic(music: ptr Music; loops: cint; ms: cint): cint {...}{.
        importc: "Mix_FadeInMusic".}

    proc fadeInMusicPos(music: ptr Music; loops: cint; ms: cint; position: cdouble): cint {...}{.
        importc: "Mix_FadeInMusicPos".}

    proc fadeInChannelTimed(channel: cint; chunk: ptr Chunk; loops: cint; ms: cint;
                           ticks: cint): cint {...}{.importc: "Mix_FadeInChannelTimed".}

    proc volume(channel: cint; volume: cint): cint {...}{.importc: "Mix_Volume".}

    proc volumeChunk(chunk: ptr Chunk; volume: cint): cint {...}{.importc: "Mix_VolumeChunk".}

    proc volumeMusic(volume: cint): cint {...}{.importc: "Mix_VolumeMusic".}

    proc haltChannel(channel: cint): cint {...}{.importc: "Mix_HaltChannel".}

    proc haltGroup(tag: cint): cint {...}{.importc: "Mix_HaltGroup".}

    proc haltMusic(): cint {...}{.importc: "Mix_HaltMusic".}

    proc expireChannel(channel: cint; ticks: cint): cint {...}{.importc: "Mix_ExpireChannel".}

    proc fadeOutChannel(which: cint; ms: cint): cint {...}{.importc: "Mix_FadeOutChannel".}

    proc fadeOutGroup(tag: cint; ms: cint): cint {...}{.importc: "Mix_FadeOutGroup".}

    proc fadeOutMusic(ms: cint): cint {...}{.importc: "Mix_FadeOutMusic".}

    proc fadingMusic(): Fading {...}{.importc: "Mix_FadingMusic".}

    proc fadingChannel(which: cint): Fading {...}{.importc: "Mix_FadingChannel".}

    proc pause(channel: cint) {...}{.importc: "Mix_Pause".}

    proc resume(channel: cint) {...}{.importc: "Mix_Resume".}

    proc paused(channel: cint): cint {...}{.importc: "Mix_Paused".}

    proc pauseMusic() {...}{.importc: "Mix_PauseMusic".}

    proc resumeMusic() {...}{.importc: "Mix_ResumeMusic".}

    proc rewindMusic() {...}{.importc: "Mix_RewindMusic".}

    proc pausedMusic(): cint {...}{.importc: "Mix_PausedMusic".}

    proc setMusicPosition(position: cdouble): cint {...}{.importc: "Mix_SetMusicPosition".}

    proc playing(channel: cint): cint {...}{.importc: "Mix_Playing".}

    proc playingMusic(): cint {...}{.importc: "Mix_PlayingMusic".}

    proc setMusicCMD(command: cstring): cint {...}{.importc: "Mix_SetMusicCMD".}

    proc setSynchroValue(value: cint): cint {...}{.importc: "Mix_SetSynchroValue".}

    proc getSynchroValue(): cint {...}{.importc: "Mix_GetSynchroValue".}

    proc setSoundFonts(paths: cstring): cint {...}{.importc: "Mix_SetSoundFonts".}

    proc getSoundFonts(): cstring {...}{.importc: "Mix_GetSoundFonts".}

    proc eachSoundFont(function: proc (a2: cstring; a3: pointer): cint {...}{.cdecl.};
                      data: pointer): cint {...}{.importc: "Mix_EachSoundFont".}

    proc getChunk(channel: cint): ptr Chunk {...}{.importc: "Mix_GetChunk".}

    proc closeAudio() {...}{.importc: "Mix_CloseAudio".}

# Templates

    template loadWAV(file: untyped): untyped

    template playChannel(channel, chunk, loops: untyped): untyped

    template fadeInChannel(channel, chunk, loops, ms: untyped): untyped