All audio files live in the assets/sounds/ directory, organized into categorized subdirectories. All sound files use the .wav format. SDL2_mixer handles both short sound effects (Mix_Chunk via Mix_LoadWAV) and streaming music (Mix_Music via Mix_LoadMUS).
Currently Used Sounds
Player — assets/sounds/player/
File
Type
GameState Field
Description
player_jump.wav
Mix_Chunk
gs->snd_jump
Played on Space press when on_ground == 1
player_hit.wav
Mix_Chunk
gs->snd_hit
Played when the player takes damage
Collectibles — assets/sounds/collectibles/
File
Type
GameState Field
Description
coin.wav
Mix_Chunk
gs->snd_coin
Played when the player collects a coin
Entities — assets/sounds/entities/
File
Type
GameState Field
Description
bird.wav
Mix_Chunk
gs->snd_flap
Played for bird enemy wing flap
spider.wav
Mix_Chunk
gs->snd_spider_attack
Played for spider enemy attack
fish.wav
Mix_Chunk
gs->snd_dive
Played for fish enemy dive
Hazards — assets/sounds/hazards/
File
Type
GameState Field
Description
axe_trap.wav
Mix_Chunk
gs->snd_axe
Played for axe trap swing
Surfaces — assets/sounds/surfaces/
File
Type
GameState Field
Description
bouncepad.wav
Mix_Chunk
gs->snd_spring
Played when the player lands on a bouncepad
Screens — assets/sounds/screens/
File
Type
GameState Field
Description
confirm_ui.wav
Mix_Chunk
menu->snd_confirm
Played on menu confirmation
Levels — assets/sounds/levels/
File
Type
GameState Field
Description
water.wav
Mix_Music
gs->music
Background music for water-themed levels, loaded via Mix_LoadMUS (streaming)
lava.wav
Mix_Music
gs->music
Background music for lava-themed levels, loaded via Mix_LoadMUS (streaming)
winds.wav
Mix_Music
gs->music
Background music for wind-themed levels, loaded via Mix_LoadMUS (streaming)
Unused Sounds
The following sounds are stored in assets/sounds/unused/ and are not loaded by the game. They are available as reserves for future use.
All sound effects use Mix_LoadWAV and are fully loaded into memory. The background music tracks (water.wav, lava.wav, winds.wav) use Mix_LoadMUS which streams from disk, keeping memory usage low. Music is assigned per level via the TOML level definition's music_path field.
Adding a New Sound Effect
Place the .wav file in the appropriate assets/sounds/<category>/ subdirectory.
Add a Mix_Chunk *snd_<name> field to GameState in game.h.
Load it in game_init:
gs->snd_<name>=Mix_LoadWAV("assets/sounds/<category>/<name>.wav");
if (!gs->snd_<name>) {
fprintf(stderr, "Warning: failed to load <name>.wav: %s\n", Mix_GetError());
/* Non-fatal — game continues without this sound */
}
Free it in game_cleanup (before SDL_DestroyRenderer):
if (gs->snd_<name>) {
Mix_FreeChunk(gs->snd_<name>);
gs->snd_<name>=NULL;
}
Play it wherever the event occurs:
if (gs->snd_<name>) Mix_PlayChannel(-1, gs->snd_<name>, 0);
The if guard is important: if the WAV fails to load for any reason, the game continues without crashing.
Adding a New Music Track
// Load (streaming — not fully decoded into RAM)gs->music=Mix_LoadMUS("assets/sounds/levels/new_track.wav");
if (!gs->music) { /* handle error */ }
// Start (loop forever)Mix_PlayMusic(gs->music, -1);
// Volume (0-128)Mix_VolumeMusic(64); // 50%// Stop and freeMix_HaltMusic();
Mix_FreeMusic(gs->music);
gs->music=NULL;
Mix_Musicstreams from disk; it does not load the entire file into RAM. This keeps memory usage low for large audio files.