Operation Null Mind 0.4.1
A 2D roguelike top down shooter game made with SDL2
 
Loading...
Searching...
No Matches
sound.c File Reference

Sound system implementation. More...

#include <sound.h>
#include <stdio.h>
#include <SDL_mixer.h>
#include <stdlib.h>
#include <string.h>
#include <SDL.h>

Functions

void Sound_Set_Max_Channels (int numChannels)
 Sets the maximum number of sound effect channels.
 
bool Sound_System_Initialize ()
 
bool Sound_Load_Resources ()
 
void Sound_Play_Effect (int index)
 [Utility] Play sound effect
 
float Sound_Get_Music_Duration (const char *path)
 
void Sound_Stop_Music ()
 [Utility] Stop background music
 
void Sound_System_Cleanup ()
 [Quit] Clean up sound resources
 
void Music_Finished_Callback ()
 [Callback] Called when music finishes playing Plays the next queued song if available
 
bool Sound_Queue_Next_Song (const char *path)
 [Utility] Queue a single song to play next
 
void Sound_Clear_Queue ()
 [Utility] Clear the queued song
 
void Sound_Play_Music (const char *path, int loops)
 [Update] Update Sound_Play_Music to free previous music
 

Variables

SoundResources soundResources
 
SimpleQueue musicQueue
 

Detailed Description

Sound system implementation.

Manages the game's audio resources, including sound effects, music playback, and volume controls.

Author
Darren
Date
2025-03-07

Function Documentation

◆ Music_Finished_Callback()

void Music_Finished_Callback ( )

[Callback] Called when music finishes playing Plays the next queued song if available

◆ Sound_Clear_Queue()

void Sound_Clear_Queue ( )

[Utility] Clear the queued song

◆ Sound_Get_Music_Duration()

float Sound_Get_Music_Duration ( const char *  path)

◆ Sound_Load_Resources()

bool Sound_Load_Resources ( )

◆ Sound_Play_Effect()

void Sound_Play_Effect ( int  index)

[Utility] Play sound effect

Parameters
indexIndex of the sound effect to play
Todo:
[sound.c:95] Maybe implement a way to play sound effects by name?

◆ Sound_Play_Music()

void Sound_Play_Music ( const char *  path,
int  loops 
)

[Update] Update Sound_Play_Music to free previous music

◆ Sound_Queue_Next_Song()

bool Sound_Queue_Next_Song ( const char *  path)

[Utility] Queue a single song to play next

Parameters
pathPath to the music file to play next
Returns
true if queued successfully, false if failed

◆ Sound_Set_Max_Channels()

void Sound_Set_Max_Channels ( int  numChannels)

Sets the maximum number of sound effect channels.

Parameters
numChannelsThe number of channels to allocate.

◆ Sound_Stop_Music()

void Sound_Stop_Music ( )

[Utility] Stop background music

◆ Sound_System_Cleanup()

void Sound_System_Cleanup ( )

[Quit] Clean up sound resources

◆ Sound_System_Initialize()

bool Sound_System_Initialize ( )

Variable Documentation

◆ musicQueue

SimpleQueue musicQueue
Initial value:
= {
.nextSongPath = NULL,
.hasNextSong = false
}

◆ soundResources

SoundResources soundResources