The OpenD Programming Language

AudioInput

Gives PCM input access (such as a microphone).

struct AudioInput {
version(ALSA)
snd_pcm_t* handle;
version(!ALSA && WinMM)
HWAVEIN handle;
version(!ALSA && WinMM)
HANDLE event;
int channels;
int SampleRate;
}

Constructors

this
this(int card, int SampleRate, int channels)

Always pass card == 0.

this
this(string device, int SampleRate, int channels)

device is a device name. On Linux, it is the ALSA string. On Windows, it is currently ignored, so you should pass "default" or null so when it does get implemented your code won't break.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Postblit

A postblit is present on this object, but not explicitly documented in the source.

Members

Functions

read
short[] read(short[] buffer)

Data is delivered as interleaved stereo, LE 16 bit, 44.1 kHz Each item in the array thus alternates between left and right channel and it takes a total of 88,200 items to make one second of sound.

record
void record()

First, set receiveData, then call this.

stop
void stop()

Variables

receiveData
void delegate(short[]) receiveData;

passes a buffer of data to fill

Meta

History

Windows support added May 10, 2020 and the API got overhauled too.