LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
|
Functions | |
int | lg_init_audio_to_defaults () |
int | lg_init_audio (int freq, uint16_t format, int n_channels, int buffer_size) |
void | lg_free_audio () |
int | lg_load_play_music (const char *file_name, int loops) |
zboolean | lg_music_is_playing () |
void | lg_pause_music () |
void | lg_resume_music () |
void | lg_stop_music () |
void | lg_free_music () |
LG_Sound * | lg_sound_new (const char *file_name) |
void | lg_disable_cant_play_audio_file () |
void | lg_enable_cant_play_audio_file () |
int | lg_sound_play (lg_play_mode mode, LG_Sound *sound) |
zboolean | lg_sound_is_playing (LG_Sound *sound) |
void | lg_sound_channel_set_volume (LG_Sound *sound, float v) |
float | lg_sound_channel_get_volume (LG_Sound *sound) |
void | lg_sound_free (LG_Sound *sound) |
void | lg_audio_set_global_volume (float v) |
void | lg_audio_set_music_volume (float v) |
void | lg_audio_set_sounds_volume (float v) |
=== SDL2 Mixer audio system === Unlike sounds, only *one* music playing at a time Should maybe use a linked list or sth, to get some kind of sound pool
int lg_init_audio_to_defaults | ( | ) |
Init SDL2 Mixer audio system (using default values)
int lg_init_audio | ( | int | freq, |
uint16_t | format, | ||
int | n_channels, | ||
int | buffer_size | ||
) |
Init SDL2 Mixer audio system
See: https://wiki.libsdl.org/SDL2_mixer/Mix_OpenAudio
freq | Frequency to playback audio (in Hz) |
format | Audio format (one of SDL's AUDIO_* values) |
n_channels | Num of audio channels |
buffer_size | Size of audio buffer |
void lg_free_audio | ( | ) |
Free SDL2 Mixer audio system resources
int lg_load_play_music | ( | const char * | file_name, |
int | loops | ||
) |
Load and play music
file_name | A music file in the 'music' assets (don't use lg_mus() as it's already used internally) |
loops | Number of times to play, -1 = don't stop |
zboolean lg_music_is_playing | ( | ) |
Check state of music playing
void lg_pause_music | ( | ) |
Pause music playing
void lg_resume_music | ( | ) |
Resume music playing
void lg_stop_music | ( | ) |
Stop music playing
void lg_free_music | ( | ) |
Free music
LG_Sound* lg_sound_new | ( | const char * | file_name | ) |
void lg_disable_cant_play_audio_file | ( | ) |
Disable "Can't play audio file" logging - can be quite verbose if some latency issues
void lg_enable_cant_play_audio_file | ( | ) |
Enable "Can't play audio file" logging - can be quite verbose if some latency issues
This is the default state
int lg_sound_play | ( | lg_play_mode | mode, |
LG_Sound * | sound | ||
) |
Play sound
Example use of lg_sound_*() funcs in file level_1.c:
mode | A lg_play_mode, one of LG_PLAY, LG_REPEAT, LG_WAIT, LG_STOP |
sound | A LG_Sound instance |
zboolean lg_sound_is_playing | ( | LG_Sound * | sound | ) |
Check state of sound playing
sound | A LG_Sound instance |
void lg_sound_channel_set_volume | ( | LG_Sound * | sound, |
float | v | ||
) |
Set volume of specific sound->channel
=== EXPERIMENTAL ===
sound | A LG_Sound instance |
float lg_sound_channel_get_volume | ( | LG_Sound * | sound | ) |
Get volume of specific sound->channel
=== EXPERIMENTAL ===
sound | A LG_Sound instance |
void lg_audio_set_global_volume | ( | float | v | ) |
Set audio (both music AND sounds) volume
Use lg_audio_set_music_volume() or lg_audio_set_sounds_volume() if you need more granular control
v | Volume, in range [0.0, 1.0] |
void lg_audio_set_music_volume | ( | float | v | ) |
Set music volume
v | Volume, in range [0.0, 1.0] |
void lg_audio_set_sounds_volume | ( | float | v | ) |
Set sounds volume
v | Volume, in range [0.0, 1.0] |