Class: AudioOutput

Method and Variable Index

Public:

Protected:

Method Descriptions

AudioOutput()

Sets up and opens the host's audio device. This method may need keyboard input in order to perform its task, so the AudioOutput object should be created before the Keyboard object.

void *loadSample(char *filename)

Loads an audio sample from disk. The format will be as appropriate for the host platform, for example - the DOS version loads .wav files. You are returned a pointer which is used to reference the sample. You should not try to evaluate the pointer, as the structure of a sample will differ by implementation.

void *createSynth(int8 *waveform, uint32 length, uint32 frequency)

Creates a synthesized audio sample. The waveform pointer should point to 8 bit signed waveform data. length gives the length in bytes of the waveform data. frequency is in samples/second.

void freeSample(void *sample)

You should call this to free any memory allocated when a sample is loaded from disk. Pass the pointer returned from loadSample(). You should, obviously, not attempt to use the sample after it has been freed.

void freeSynth(void *sample)

Like freeSample(), but this frees memory allocated to a synth sample.

void *openChannel(uint8 volume, uint8 position)

Open an audio channel. Each channel can be used to play one sample at a time. volume is a value from 0..255 which give the relative volume of samples played on that channel. position goes from 0 (far left) to 255 (far right).

The return value is a pointer which is used to reference the channel.

void *closeChannel(void *channel)

Close a channel openned with openChannel().

bool channelActive(void *channel)

Returns true if a sample is currently playing on the given channel.

void stopChannel(void *channel)

Stop any sample which is currently playing on the given channel.

void playWaveform(void *waveform, void *channel)

Play a given waveform on a given channel. The waveform may be either a sample or a synth sample. It will be played using the settings given to openChannel().

void modifySynth(void *waveform, int8 *data)

Modifies the given synth sample. The length and frequency are unchanged, but the waveform data is set to the values pointed to by the data parameter.

void update(void)

Update should be called regularly (once per frame), and keeps the audio data going to the sound card.