AudioPcmOutThreadImplementation

Makes an audio thread for you that you can make various sounds on and it will mix them with good enough latency for simple games.

DO NOT USE THIS DIRECTLY. Instead, access it through AudioOutputThread.

auto audio = AudioOutputThread(true);
audio.beep();

// you need to keep the main program alive long enough
// to keep this thread going to hear anything
Thread.sleep(1.seconds);

Members

Functions

addChannel
void addChannel(bool delegate(short[] buffer) dg)

The delegate returns false when it is finished (true means keep going). It must fill the buffer with waveform data on demand and must be latency sensitive; as fast as possible.

beep
void beep(int freq, int dur, int volume, int balance)
blip
void blip(float attack, int freqBase, int dur, int volume, int balance)
boop
void boop(float attack, int freqBase, int dur, int volume, int balance)

Makes some old-school style sound effects. Play with them to see what they actually sound like.

exit
Throwable exit(bool rethrow)

Stops playback and unsupends if necessary and exits.

noise
void noise(int dur, int volume, int balance)

Makes some old-school style sound effects. Play with them to see what they actually sound like.

pause
void pause()

Asks the device to pause/unpause. This may not actually do anything on some systems. You should probably use suspend and unsuspend instead.

playEmulatedOpl3Midi
SampleController playEmulatedOpl3Midi(string filename, bool loop)
SampleController playEmulatedOpl3Midi(immutable(ubyte)[] data, bool loop)

Plays the given midi files with the nuked opl3 emulator.

playMp3
SampleController playMp3(string filename)
SampleController playMp3(immutable(ubyte)[] data)

Requires mp3.d to be compiled in (module arsd.mp3).

playOgg
SampleController playOgg(string filename, bool loop)
SampleController playOgg(immutable(ubyte)[] data, bool loop)

Requires vorbis.d to be compiled in (module arsd.vorbis)

playWav
SampleController playWav(R filename_or_data)

Requires arsd.wav. Only supports simple 8 or 16 bit wav files, no extensible or float formats at this time.

rawStop
void rawStop()

Stops the output thread. Using the object after it is stopped is not recommended which is why this is now deprecated.

stop
deprecated void stop()

Stops the output thread. Using the object after it is stopped is not recommended which is why this is now deprecated.

suspend
void suspend()
suspended
bool suspended()

Stops playing and closes the audio device, but keeps the worker thread alive and waiting for a call to unsuspend, which will re-open everything and pick up (close to; a couple buffers may be discarded) where it left off.

synth
SynthBuilder synth()

A helper object to create synthesized sound samples.

unpause
void unpause()

Asks the device to pause/unpause. This may not actually do anything on some systems. You should probably use suspend and unsuspend instead.

unsuspend
void unsuspend()

Stops playing and closes the audio device, but keeps the worker thread alive and waiting for a call to unsuspend, which will re-open everything and pick up (close to; a couple buffers may be discarded) where it left off.

Structs

SynthBuilder
struct SynthBuilder

A helper object to create synthesized sound samples.

Suggestion Box / Bug Report