gfm



class  SDLMixer;

SDL_mixer library wrapper.


this(SDL2 sdl2, int flags = MIX_INIT_FLAC | MIX_INIT_MOD | MIX_INIT_MP3 | MIX_INIT_OGG, int frequency = MIX_DEFAULT_FREQUENCY, ushort format = MIX_DEFAULT_FORMAT, int channels = MIX_DEFAULT_CHANNELS, int chunksize = 1024);

Loads the SDL_mixer library and opens audio.

Throws
SDL2Exception on error.
See Also
https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC11

int  getChannels();

Returns
The number of mixing channels currently allocated.

void  setChannels(int numChannels);

Sets the number of mixing channels.


void  pause(int channel);

Pauses the channel. Passing -1 pauses all channels.


void  unpause(int channel);

Unpauses the channel. Passing -1 unpauses all channels.


bool  isPaused(int channel);

Returns
Whether the channel is paused.

void  halt(int channel, Duration delay = 0.msecs);

Clears the channel and pauses it.

Parameters
int channel channel to  halt. -1 halts all channels.
Duration delay time after which to perform the  halt.

void  fade(int channel, Duration time);

Fades out the channel and then halts it.

Parameters
int channel channel to halt. -1 fades all channels.
Duration time time over which the channel is faded out.

Mix_Fading  getFading(int channel);

Returns
Fading status of the channel.

bool  isPlaying(int channel);

Returns
Whether the channel is currently playing.

int  getVolume(int channel);

Returns
The volume of the channel.

void  setVolume(int channel, int volume);

Sets the volume of the channel. Passing -1 sets volume of all channels.


void  setPanning(int channel, ubyte volumeLeft, ubyte volumeRight);

Sets stereo panning on the channel. The library must have been opened with two output channels.

See Also
https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC80

void  setDistance(int channel, ubyte distance);

Sets distance from the listener on the channel, used to simulate attenuation.

See Also
https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC81

void  setPosition(int channel, short angle, ubyte distance);

Set panning and distance on the channel to simulate positional audio.

See Also
https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC82

void  setReverseStereo(int channel, bool reverse);

Sets whether reverse stereo is enabled on the channel.


void  clearEffects(int channel);

Clears all effects from the channel.


class  SDLSample;

SDL_mixer audio chunk wrapper.


this(SDLMixer sdlmixer, string filename);

Loads a sample from a file.

Parameters
SDLMixer sdlmixer library object.
string filename path to the audio sample.
Throws
SDL2Exception on error.

Mix_Chunk*  handle();

Returns
SDL  handle.

int  play(int channel, int loops = 0, Duration fadeInTime = 0.seconds);

Plays this sample.

Parameters
int channel channel to  play on. -1 plays on first inactive channel.
int loops number of times to loop this sample.
Duration fadeInTime time over which this sample is faded in.
Returns
channel the sample is now playing on.

int  playTimed(int channel, Duration timeLimit, int loops = 0, Duration fadeInTime = 0.seconds);

Plays this sample only within a certain time limit.

Parameters
int channel channel to play on. -1 plays on first inactive channel.
Duration timeLimit time after which the sample stops playing.
int loops number of times to loop this sample.
Duration fadeInTime time over which this sample is faded in.
Returns
channel the sample is now playing on.

int  getVolume();

Returns
The volume this sample plays at.

void  setVolume(int volume);

Sets the volume this sample plays at.