sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
Channels

Mixer channels 0 to 23 that play sounds. More...

Functions

int audio_channel_play_sound (int channel, audio_sound_t sound)
int audio_play_sound (audio_sound_t sound)
int audio_channel_stop (int channel)
int audio_channel_is_playing (int channel)
int audio_channel_get_playing_sound (int channel, audio_sound_t *sound_out)
int audio_channel_set_volume (int channel, int volume_percent)
int audio_channel_set_volume_and_pan (int channel, int volume_percent, int pan)
int audio_channel_set_pitch (int channel, float ratio)

Detailed Description

Mixer channels 0 to 23 that play sounds.

A channel keeps its volume, pan and pitch until they are changed, including across sounds and before the first sound plays. Commands that return AUDIO_OK without a reply from the driver (play, stop and the volume, pan and pitch setters) are validated by the library, sent, and executed by the driver in the order they were sent; a later call such as audio_channel_is_playing() sees their effect.

Function Documentation

◆ audio_channel_get_playing_sound()

int audio_channel_get_playing_sound ( int channel,
audio_sound_t * sound_out )

The sound playing on a channel.

Parameters
channel0 to 23.
[out]sound_outReceives the handle, or AUDIO_SOUND_INVALID when the channel is idle.
Returns
AUDIO_OK or a negative error.

◆ audio_channel_is_playing()

int audio_channel_is_playing ( int channel)

Whether a channel is playing. A sound that finished counts as not playing.

Parameters
channel0 to 23.
Returns
1 playing, 0 idle, or a negative error.

◆ audio_channel_play_sound()

int audio_channel_play_sound ( int channel,
audio_sound_t sound )

Plays a sound on a channel, replacing whatever was playing there. The channel keeps its volume, pan and pitch.

Parameters
channel0 to 23.
soundA handle from a load function.
Returns
AUDIO_OK, or -AUDIO_ERR_INVALID_ARGUMENT for a channel out of range or a handle that is not live.

◆ audio_channel_set_pitch()

int audio_channel_set_pitch ( int channel,
float ratio )

Sets the playback speed as a ratio of the sound's own rate. Applies at once to a playing sound and persists.

Parameters
channel0 to 23.
ratio0.0625 to 4.0; 1.0 plays at the sound's rate.
Returns
AUDIO_OK or -AUDIO_ERR_INVALID_ARGUMENT.

◆ audio_channel_set_volume()

int audio_channel_set_volume ( int channel,
int volume_percent )

Sets the channel volume and leaves pan and pitch unchanged. Applies at once to a playing sound and persists.

Parameters
channel0 to 23.
volume_percent0 to 100.
Returns
AUDIO_OK or -AUDIO_ERR_INVALID_ARGUMENT.

◆ audio_channel_set_volume_and_pan()

int audio_channel_set_volume_and_pan ( int channel,
int volume_percent,
int pan )

Sets volume and pan together. Applies at once to a playing sound and persists.

Parameters
channel0 to 23.
volume_percent0 to 100.
pan-100 (left) to 100 (right), 0 centered; it works as a balance for stereo sounds.
Returns
AUDIO_OK or -AUDIO_ERR_INVALID_ARGUMENT.

◆ audio_channel_stop()

int audio_channel_stop ( int channel)

Stops the sound on a channel. Volume, pan and pitch are kept.

Parameters
channel0 to 23.
Returns
AUDIO_OK, also for an idle channel, or -AUDIO_ERR_INVALID_ARGUMENT.

◆ audio_play_sound()

int audio_play_sound ( audio_sound_t sound)

Plays a sound on the first idle channel, searching from channel 0. The channel is reset to volume 100, centered, normal pitch before the sound starts.

Parameters
soundA handle from a load function.
Returns
The channel number 0-23, -AUDIO_ERR_NO_FREE_CHANNEL (nothing is interrupted), -AUDIO_ERR_INVALID_ARGUMENT or -AUDIO_ERR_NOT_INITIALIZED.
Note
Waits for the driver's answer, since the channel number is the result.