The OpenD Programming Language

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.

Inherited Members

From Thread

~this
~this()

Cleans up any remaining resources used by this object.

getThis
Thread getThis()

Provides a reference to the calling thread.

start
Thread start()

Starts the thread and invokes the function or delegate passed upon construction.

join
Throwable join(bool rethrow)

Waits for this thread to complete. If the thread terminated as the result of an unhandled exception, this exception will be rethrown.

PRIORITY_MIN
int PRIORITY_MIN [@property getter]

//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

PRIORITY_MAX
const(int) PRIORITY_MAX [@property getter]

//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

PRIORITY_DEFAULT
int PRIORITY_DEFAULT [@property getter]

//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

PRIORITY_MIN
int PRIORITY_MIN [@property getter]

The minimum scheduling priority that may be set for a thread. On systems where multiple scheduling policies are defined, this value represents the minimum valid priority for the scheduling policy of the process.

PRIORITY_MAX
const(int) PRIORITY_MAX [@property getter]

The maximum scheduling priority that may be set for a thread. On systems where multiple scheduling policies are defined, this value represents the maximum valid priority for the scheduling policy of the process.

PRIORITY_DEFAULT
int PRIORITY_DEFAULT [@property getter]

The default scheduling priority that is set for a thread. On systems where multiple scheduling policies are defined, this value represents the default priority for the scheduling policy of the process.

priority
int priority [@property getter]

Gets the scheduling priority for the associated thread.

priority
int priority [@property setter]

Sets the scheduling priority for the associated thread.

isRunning
bool isRunning [@property getter]

Tests whether this thread is running.

sleep
void sleep(Duration val)

Suspends the calling thread for at least the supplied period. This may result in multiple OS calls if period is greater than the maximum sleep duration supported by the operating system.

yield
void yield()

Forces a context switch to occur away from the calling thread.

Meta