Comprehensive audio processing and playback system with professional-grade mixing capabilities.
The Audio module provides a robust, cross-platform audio infrastructure that manages the complete audio pipeline from sample loading through to hardware output. The module's architecture supports both high-level convenience interfaces and low-level professional audio control, making it suitable for applications ranging from simple media playback to sophisticated audio production environments.
The module implements a client-server design pattern with two complementary class interfaces:
The internal mixer is a floating-point engine that processes all audio internally at 32-bit precision regardless of output bit depth. The mixer supports features that include:
Audio implementation is optimised for each supported platform to maximise performance and minimise latency:
The module implements streaming technology that automatically adapts to sample characteristics and system resources:
For optimal results, choose the appropriate interface based on application requirements:
MixContinue | MixEndSequence | MixFrequency | MixMute | MixPan | MixPlay | MixRate | MixSample | MixStartSequence | MixStop | MixStopLoop | MixVolume
Continue playing a stopped channel.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The target channel. |
This function will continue playback on a channel that has previously been stopped.
| Okay | Operation successful. |
|---|---|
| NullArgs | Function call missing argument value(s) |
Ends the buffering of mix commands.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The target channel. |
Use this function to end a buffered command sequence that was started by MixStartSequence().
| Okay | Operation successful. |
|---|---|
| NullArgs | Function call missing argument value(s) |
Sets a channel's playback rate.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The target channel. |
| Frequency | The desired frequency. |
Use this function to set the playback rate of a mixer channel.
| Okay | Operation successful. |
|---|---|
| Failed | General failure |
| OutOfRange | A value is outside of the valid range |
| NullArgs | Function call missing argument value(s) |
Mutes the audio of a channel.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The target channel. |
| Mute | Set to true to mute the channel. A value of 0 will undo the mute setting. |
Use this function to mute the audio of a mixer channel.
| Okay | Operation successful. |
|---|---|
| OutOfRange | A value is outside of the valid range |
| NullArgs | Function call missing argument value(s) |
Sets a channel's panning value.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The target channel. |
| Pan | The desired pan value between -1.0 and 1.0. |
Use this function to set a mixer channel's panning value. Accepted values are between -1.0 (left) and 1.0 (right).
| Okay | Operation successful. |
|---|---|
| NullArgs | Function call missing argument value(s) |
Commences channel playback at a set frequency.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The target channel. |
| Position | The new playing position, measured in bytes. |
This function will start playback of the sound sample associated with the target mixer channel. If the channel is already in playback mode, it will be stopped to facilitate the new playback request.
| Okay | Playback successfully initiated. |
|---|---|
| NoData | The referenced sample is unconfigured. |
| OutOfRange | Position exceeds sample boundaries. |
| FieldNotSet | Channel not associated with a valid sample. |
| NullArgs | Required parameters are null or missing. |
Sets a new update rate for a channel.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The channel set allocated from OpenChannels(). |
| Rate | The new update rate in milliseconds. |
This function will set a new update rate for all channels, measured in milliseconds. The default update rate is 125, which is equivalent to 5000Hz.
| Okay | Operation successful. |
|---|---|
| OutOfRange | A value is outside of the valid range |
| NullArgs | Function call missing argument value(s) |
Associate a sound sample with a mixer channel.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The target channel. |
| Sample | A sample handle allocated from Audio⇒AddSample() or Audio⇒AddStream(). |
This function will associate a sound sample with the channel identified by Handle. The client should follow this by setting configuration details (e.g. volume and pan values).
The referenced Sample must have been added to the audio server via the Audio⇒AddSample() or Audio⇒AddStream() methods.
| Okay | Operation successful. |
|---|---|
| NoData | The sample handle refers to a dead or unconfigured sample. |
| OutOfRange | A value is outside of the valid range |
| DataSize | The sample has an invalid length. |
| NullArgs | Function call missing argument value(s) |
Initiates buffering of mix commands.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The target channel. |
Use this function to initiate the buffering of mix commands, up until a call to MixEndSequence() is made. The buffering of mix commands makes it possible to create batches of commands that are executed at timed intervals as determined by MixRate().
When command buffering is activated, the mixer transitions to a batch processing mode with several key characteristics:
This feature can be used to implement complex sound mixes and digital music players.
| Okay | Command buffering successfully initiated. |
|---|---|
| NullArgs | Required parameters are null or missing. |
Stops all playback on a channel.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The target channel. |
This function will stop a channel that is currently playing.
| Okay | Operation successful. |
|---|---|
| NullArgs | Function call missing argument value(s) |
Cancels any playback loop configured for a channel.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The target channel. |
This function will cancel the loop that is associated with the channel identified by Handle if in playback mode. The existing loop configuration will remain intact if playback is restarted.
| Okay | Operation successful. |
|---|---|
| NullArgs | Function call missing argument value(s) |
Changes the volume of a channel.
| Parameter | Description |
|---|---|
| Audio | The target Audio object. |
| Handle | The target channel. |
| Volume | The new volume for the channel. |
This function will change the volume of the mixer channel identified by Handle. Valid values are from 0 (silent) to 1.0 (maximum).
| Okay | Operation successful. |
|---|---|
| NullArgs | Function call missing argument value(s) |
Loop modes for the AudioLoop structure.
| Name | Description |
|---|---|
| LOOP::AMIGA | Single loop: Amiga style. |
| LOOP::AMIGA_NONE | Amiga loop: Do nothing. |
| LOOP::DOUBLE | Double loop: When the note is released, playing shifts to the second loop. |
| LOOP::SINGLE | Single loop: Releasing will end the note. |
| LOOP::SINGLE_RELEASE | Single loop: Sample data after the loop will be played when the note is released. |
Loop types for the AudioLoop structure.
| Name | Description |
|---|---|
| LTYPE::BIDIRECTIONAL | The sample will play in reverse whenever it hits the end marker, then forwards when it hits the start marker. |
| LTYPE::UNIDIRECTIONAL | The sample playback position returns to the byte position specified in the Loop1Start field. |
Loop settings for the AddSample() method.
| Field | Type | Description |
|---|---|---|
| LoopMode | LOOP | Loop mode (single, double) |
| Loop1Type | LTYPE | First loop type (unidirectional, bidirectional) |
| Loop2Type | LTYPE | Second loop type (unidirectional, bidirectional) |
| Loop1Start | INT | Start of the first loop |
| Loop1End | INT | End of the first loop |
| Loop2Start | INT | Start of the second loop |
| Loop2End | INT | End of the second loop |