Kohi Game Engine
audio_system.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "audio/audio_types.h"
4 #include "defines.h"
5 
10 #define MAX_AUDIO_CHANNELS 16
11 
12 struct frame_data;
13 
14 typedef struct audio_system_config {
24 
29 
36 
47 KAPI b8 audio_system_initialize(u64* memory_requirement, void* state, void* config);
48 
54 KAPI void audio_system_shutdown(void* state);
55 
59 KAPI b8 audio_system_update(void* state, struct frame_data* p_frame_data);
60 
69 
77 KAPI struct audio_file* audio_system_chunk_load(const char* path);
78 
86 KAPI struct audio_file* audio_system_stream_load(const char* path);
87 
92 KAPI void audio_system_close(struct audio_file* file);
93 
100 
106 
114 
121 KAPI b8 audio_system_channel_volume_query(i8 channel_id, f32* out_volume);
122 
132 KAPI b8 audio_system_channel_play(i8 channel_id, struct audio_file* file, b8 loop);
133 
144 
KAPI void audio_system_master_volume_query(f32 *out_volume)
Queries the master volume.
KAPI void audio_system_close(struct audio_file *file)
Closes the given sound, releasing all internal resources.
KAPI void audio_system_channel_stop(i8 channel_id)
struct audio_system_config audio_system_config
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....
KAPI void audio_system_channel_resume(i8 channel_id)
KAPI void audio_system_channel_pause(i8 channel_id)
KAPI b8 audio_system_channel_volume_set(i8 channel_id, f32 volume)
Sets the volume for the given channel id.
KAPI b8 audio_system_listener_orientation_set(vec3 position, vec3 forward, vec3 up)
KAPI void audio_system_master_volume_set(f32 volume)
Sets the master volume level. This affects all channels overall.
KAPI b8 audio_system_channel_emitter_play(i8 channel_id, struct audio_emitter *emitter)
KAPI b8 audio_system_channel_volume_query(i8 channel_id, f32 *out_volume)
Queries the given channel's volume volume.
KAPI b8 audio_system_update(void *state, struct frame_data *p_frame_data)
Updates the audio system. Should happen once an update cycle.
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....
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 sta...
KAPI b8 audio_system_channel_play(i8 channel_id, struct audio_file *file, b8 loop)
KAPI void audio_system_shutdown(void *state)
Shuts down the audio system.
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:177
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:25
signed char i8
Signed 8-bit integer.
Definition: defines.h:33
_Bool b8
8-bit boolean type
Definition: defines.h:58
float f32
32-bit floating point number
Definition: defines.h:47
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
Definition: audio_types.h:41
Definition: audio_types.h:20
Definition: audio_types.h:69
Definition: audio_system.h:14
audio_plugin plugin
Definition: audio_system.h:16
u32 channel_count
The number of audio channels to support (i.e. 2 for stereo, 1 for mono). not to be confused with audi...
Definition: audio_system.h:23
u32 audio_channel_count
The number of separately-controlled channels used for mixing purposes. Each channel can have its volu...
Definition: audio_system.h:34
u32 chunk_size
Definition: audio_system.h:28
u32 frequency
The frequency to output audio at.
Definition: audio_system.h:18
Engine-level current frame-specific data.
Definition: frame_data.h:16
A 3-element vector.
Definition: math_types.h:49