sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
audio.h File Reference
#include <stdint.h>

Go to the source code of this file.

Classes

struct  audio_stream_format
struct  audio_sound_desc
struct  audio_version

Macros

#define AUDIO_OK   0
#define AUDIO_ERR_NOT_INITIALIZED   1
#define AUDIO_ERR_ALREADY_INITIALIZED   2
#define AUDIO_ERR_RPC_FAILED   3
#define AUDIO_ERR_FORMAT_NOT_SUPPORTED   4
#define AUDIO_ERR_OUT_OF_MEMORY   5
#define AUDIO_ERR_INVALID_ARGUMENT   6
#define AUDIO_ERR_NO_FREE_CHANNEL   7
#define AUDIO_ERR_OUT_OF_SPU_MEMORY   8
#define AUDIO_ERR_BAD_SOUND_DATA   9
#define AUDIO_ERR_STREAM_NOT_STARTED   10
#define AUDIO_ERR_STREAM_PAUSED   11
#define AUDIO_ERR_TIMEOUT   12
#define AUDIO_ERR_INTERRUPTED   13
#define AUDIO_ERR_DRIVER_LOAD_FAILED   14
#define AUDIO_ERR_BUSY   15
#define AUDIO_EFFECT_OFF   0
#define AUDIO_EFFECT_ROOM   1
#define AUDIO_EFFECT_STUDIO_SMALL   2
#define AUDIO_EFFECT_STUDIO_MEDIUM   3
#define AUDIO_EFFECT_STUDIO_LARGE   4
#define AUDIO_EFFECT_HALL   5
#define AUDIO_EFFECT_SPACE   6
#define AUDIO_EFFECT_ECHO   7
#define AUDIO_EFFECT_DELAY   8
#define AUDIO_EFFECT_PIPE   9
#define AUDIO_SOUND_INVALID   0

Typedefs

typedef int32_t audio_sound_t
typedef struct audio_stream_format audio_stream_format_t
typedef struct audio_sound_desc audio_sound_desc_t
typedef struct audio_version audio_version_t
typedef void(*) audio_low_data_fn(void *user, int32_t queued_source_bytes)

Functions

int audio_init (void)
int audio_shutdown (void)
const char * audio_get_error_message (int error_code)
int audio_get_version (audio_version_t *version_out)
int audio_set_master_volume (int volume_percent)
int audio_get_channel_count (void)
int audio_stream_start (const audio_stream_format_t *format)
int audio_stream_end (void)
int audio_stream_queue_pcm (const void *pcm, int32_t byte_count)
int audio_stream_wait_until_writable (int32_t byte_count, int32_t timeout_ms)
int audio_stream_get_queued_bytes (void)
int audio_stream_get_free_bytes (void)
int audio_stream_stop_and_clear (void)
int audio_stream_pause (void)
int audio_stream_resume (void)
int audio_stream_set_volume (int volume_percent)
int audio_stream_set_low_data_callback (int32_t threshold_bytes, audio_low_data_fn callback, void *user)
int audio_sound_load_adpcm (const audio_sound_desc_t *desc, audio_sound_t *sound_out)
int audio_sound_load_apcm (const void *file_data, int32_t file_size_bytes, audio_sound_t *sound_out)
int audio_sound_free (audio_sound_t sound)
int audio_sound_free_all (void)
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)
int audio_effect_set_preset (int preset)
int audio_effect_set_depth (int depth_percent)
int audio_effect_set_delay_and_feedback (int delay, int feedback)
int audio_channel_set_effect_send (int channel, int enabled)
int audio_stream_set_effect_send (int enabled)

Detailed Description

PS2 audio library: PCM streaming and preloaded ADPCM sounds on mixer channels.

Every function here works on one default context, created by audio_init() and released by audio_shutdown(). audio_core.h has the same functions on an explicit context.

Return values: a value >= 0 is success (some functions return a count or a channel number). A failure is the negated error code, for example -AUDIO_ERR_INVALID_ARGUMENT. See Concepts for how the parts fit together.

Licensed under the Academic Free License version 2.0.

Definition in file audio.h.

Macro Definition Documentation

◆ AUDIO_SOUND_INVALID

#define AUDIO_SOUND_INVALID   0

The value that is never a valid sound handle.

Definition at line 75 of file audio.h.

Typedef Documentation

◆ audio_low_data_fn

typedef void(*) audio_low_data_fn(void *user, int32_t queued_source_bytes)

Callback for audio_stream_set_low_data_callback().

Parameters
userPointer given at registration.
queued_source_bytesBytes still queued when the callback runs.

Definition at line 111 of file audio.h.

◆ audio_sound_desc_t

Raw PS-ADPCM data for audio_sound_load_adpcm().

◆ audio_sound_t

typedef int32_t audio_sound_t

Handle to a sound loaded into SPU2 memory. Valid handles are >= 1; a freed handle never becomes valid again.

Definition at line 72 of file audio.h.

◆ audio_stream_format_t

Format of the PCM data given to audio_stream_queue_pcm().

◆ audio_version_t

Library and driver versions, filled by audio_get_version().