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
- Returns
- The number of mixing channels currently allocated.
Sets the number of mixing channels.
Pauses the channel. Passing -1 pauses all channels.
Unpauses the channel. Passing -1 unpauses all channels.
- 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. |
- Returns
- Fading status of the channel.
- Returns
- Whether the channel is currently playing.
- Returns
- The volume of the channel.
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
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
Sets whether reverse stereo is enabled on the channel.
Clears all effects from the channel.
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.
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.
- Returns
- The volume this sample plays at.
Sets the volume this sample plays at.