d2d.audio.sound



class Sound: d2d.core.iverifiable.IVerifiable, d2d.core.idisposable.IDisposable;
Thin wrap around Mix_Chunk including loading [FLAC, MikMod, Ogg Vorbis, MP3, Wav] using SDL_Mixer.

@property Mix_Chunk* handle();
Handle to the
Mix_Chunk*
.

@property bool valid();
Checks if the handle is not null.

this(string path);
Loads a sound file

static Sound fromChunk(Mix_Chunk* chunk);
Creates sound from a
Mix_Chunk*
.

static @property string error();
Returns the latest sound related error

void dispose();
Deallocates the memory and invalidates
this
.

int play(int loops = 0, int channel = -1, int maxTicks = -1);
Plays this sound in the selected channel.

Params:
int loops -1 loops will play forever. 0 plays once.
int channel -1 loops will choose the first free unreserved channel.
int maxTicks Maximum milliseconds to play this sound. If not enough loops or the sample chunk is not long enough, then the sample may stop before this timeout occurs. -1 means play forever.

Returns:
the channel the sample is played on. On any errors, -1 is returned.

int fadeIn(int ms, int loops = 1, int channel = -1, int maxTicks = -1);
Plays this sound in the selected channel with a fade in effect.

Params:
int ms Milliseconds for the fade-in effect to complete.
int loops -1 loops will play forever. 0 plays once.
int channel -1 loops will choose the first free unreserved channel.
int maxTicks Maximum milliseconds to play this sound. If not enough loops or the sample chunk is not long enough, then the sample may stop before this timeout occurs. -1 means play forever.

Returns:
the channel the sample is played on. On any errors, -1 is returned.

static void stop(int channel = -1);
Halt playback of sound. This interrupts sound fader effects.

Params:
int channel Channel to stop playing, or -1 for all channels.

static void pause(int channel = -1);
Pause the sound playback. You may halt paused sounds.

Params:
int channel Channel to stop playing, or -1 for all channels.

Note:
Sound can only be paused if it is actively playing.

static void resume(int channel = -1);
Unpause the sound. This is safe to use on halted, paused, and already playing sounds.

Params:
int channel Channel to stop playing, or -1 for all channels.

static float getVolume(int channel = -1);
Returns the current volume as float in range 0.0 to 1.0

Params:
int channel -1 for all channels.

static void setVolume(float value, int channel = -1);
Sets the current volume as float in range 0.0 to 1.0

Params:
float value volume between 0.0 and 1.0.
int channel -1 for all channels.

static @property int isPlaying(int channel = -1);
Tells you how many channels are playing if set to -1

Params:
int channel -1 for all channels.

static @property int isPaused(int channel = -1);
Tells you how many channels are paused if set to -1

Params:
int channel -1 for all channels.

static @property FadingStatus fadingStatus(int channel);
Params:
int channel -1 is invalid.


Page generated by Ddoc.