Kohi Game Engine
|
Go to the source code of this file.
Data Structures | |
struct | audio_system_config |
Macros | |
#define | MAX_AUDIO_CHANNELS 16 |
Typedefs | |
typedef struct audio_system_config | audio_system_config |
Functions | |
KAPI b8 | audio_system_initialize (u64 *memory_requirement, void *state, void *config) |
Initializes the audio system. Should be called twice; once to get the memory requirement (passing state=0), and a second time passing an allocated block of memory to actually initialize the system. More... | |
KAPI void | audio_system_shutdown (void *state) |
Shuts down the audio system. More... | |
KAPI b8 | audio_system_update (void *state, struct frame_data *p_frame_data) |
Updates the audio system. Should happen once an update cycle. More... | |
KAPI b8 | audio_system_listener_orientation_set (vec3 position, vec3 forward, vec3 up) |
KAPI struct audio_file * | audio_system_chunk_load (const char *path) |
Attempts to load a sound chunk at the given path. Returns a pointer to a loaded sound. This dynamically allocates memory, so make sure to call audio_system_close() on it when done. More... | |
KAPI struct audio_file * | audio_system_stream_load (const char *path) |
Attempts to load a audio stream file at the given path. Returns a pointer to a loaded music. This dynamically allocates memory, so make sure to call audio_system_close() on it when done. More... | |
KAPI void | audio_system_close (struct audio_file *file) |
Closes the given sound, releasing all internal resources. More... | |
KAPI void | audio_system_master_volume_set (f32 volume) |
Sets the master volume level. This affects all channels overall. More... | |
KAPI void | audio_system_master_volume_query (f32 *out_volume) |
Queries the master volume. More... | |
KAPI b8 | audio_system_channel_volume_set (i8 channel_id, f32 volume) |
Sets the volume for the given channel id. More... | |
KAPI b8 | audio_system_channel_volume_query (i8 channel_id, f32 *out_volume) |
Queries the given channel's volume volume. More... | |
KAPI b8 | audio_system_channel_play (i8 channel_id, struct audio_file *file, b8 loop) |
KAPI b8 | audio_system_channel_emitter_play (i8 channel_id, struct audio_emitter *emitter) |
KAPI void | audio_system_channel_stop (i8 channel_id) |
KAPI void | audio_system_channel_pause (i8 channel_id) |
KAPI void | audio_system_channel_resume (i8 channel_id) |
#define MAX_AUDIO_CHANNELS 16 |
The maximum number of individually-controlled channels of audio available, each with separate volume control. These are all nested under a master audio volume.
typedef struct audio_system_config audio_system_config |
KAPI b8 audio_system_channel_emitter_play | ( | i8 | channel_id, |
struct audio_emitter * | emitter | ||
) |
Plays spatially-oriented 3d sound from the context of an audio_emitter. The emitter should already have a loaded sound associated with it. In addition, if the emitter is moving, it should be updated per frame with a call to audio_system_emitter_update().
channel_id | The id of the channel to play through. |
emitter | A pointer to an emitter to use for playback. |
KAPI b8 audio_system_channel_play | ( | i8 | channel_id, |
struct audio_file * | file, | ||
b8 | loop | ||
) |
Plays the provided sound on the channel with the given id. Note that this is effectively "2d" sound, meant for sounds which don't exist in the world and should be played globally (i.e. UI sound effects).
channel_id | The id of the channel to play the sound on. |
sound | The sound to be played. |
loop | Indicates if the sound should loop. |
Stops the given channel id.
channel_id | The id of the channel to be stopped. If -1 is passed, all channels are stopped. |
Queries the given channel's volume volume.
channel_id | The id of the channel to query. -1 cannot be used here. |
volume | A pointer to hold the volume. |
Sets the volume for the given channel id.
channel_id | The id of the channel to adjust volume for. @volume The volume to set. Clamped to a range of [0.0-1.0]. |
KAPI struct audio_file* audio_system_chunk_load | ( | const char * | path | ) |
Attempts to load a sound chunk at the given path. Returns a pointer to a loaded sound. This dynamically allocates memory, so make sure to call audio_system_close() on it when done.
path | The full path to the asset to be loaded. |
KAPI void audio_system_close | ( | struct audio_file * | file | ) |
Closes the given sound, releasing all internal resources.
file | A pointer to the sound file to be closed. |
Initializes the audio system. Should be called twice; once to get the memory requirement (passing state=0), and a second time passing an allocated block of memory to actually initialize the system.
memory_requirement | A pointer to hold the memory requirement as it is calculated. |
state | A block of memory to hold the state or, if gathering the memory requirement, 0. |
config | The configuration (audio_system_config) for this system. |
Sets the orientation of the listener. Typically linked to the current camera in the world.
position | The position of the listener. |
forward | The listener's forward vector. |
up | The listener's up vector. |
Queries the master volume.
volume | A pointer to hold the volume. |
Sets the master volume level. This affects all channels overall.
volume | The volume to set. Clamed to a range of [0.0-1.0]. |
KAPI void audio_system_shutdown | ( | void * | state | ) |
Shuts down the audio system.
state | The state block of memory. |
KAPI struct audio_file* audio_system_stream_load | ( | const char * | path | ) |
Attempts to load a audio stream file at the given path. Returns a pointer to a loaded music. This dynamically allocates memory, so make sure to call audio_system_close() on it when done.
path | The full path to the asset to be loaded. |
KAPI b8 audio_system_update | ( | void * | state, |
struct frame_data * | p_frame_data | ||
) |
Updates the audio system. Should happen once an update cycle.