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

Manages audio playback for music and sound effects. More...

#include <SDL_mixer.h>
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  SimpleQueue
 
struct  SoundResources
 
struct  Sound
 

Macros

#define MAX_MUSIC_QUEUE_SIZE   20
 

Typedefs

typedef struct SimpleQueue SimpleQueue
 
typedef struct SoundResources SoundResources
 
typedef struct Sound Sound
 

Enumerations

enum  SoundEffect {
  SOUND_SWOOSH , SOUND_GUNSHOT , SOUND_VINE_BOOM , SOUND_BOOST_UP ,
  SOUND_BUFFING , SOUND_CRATE_OPENING , SOUND_DASH , SOUND_ELEVATOR_CLOSE ,
  SOUND_ELEVATOR_OPEN , SOUND_ENEMY_HEALING , SOUND_ENERGY_GUNSHOT , SOUND_EXPLOSION ,
  SOUND_GRENADE_LAUNCHER , SOUND_GUN_PICKUP , SOUND_HITMARKER , SOUND_KAMIKAZE_BEEP ,
  SOUND_LAST_STAND , SOUND_PARRY , SOUND_PASSIVE_OBTAINED , SOUND_PLAYER_HEALING ,
  SOUND_PLAYER_HURT , SOUND_RECALL , SOUND_ROCKET_LAUNCH , SOUND_SENTRY_LASER ,
  SOUND_SPAWN_IN , SOUND_VANTAGE_LASER , SOUND_BOOST_DOWN , SOUND_HOVER ,
  SOUND_ARMOR_PISTOL , SOUND_ASSAULT_RIFLE , SOUND_AUTO_SHOTGUN , SOUND_BATTLE_RIFLE ,
  SOUND_BULLPUP_RIFLE , SOUND_BURST_RIFLE , SOUND_PDW , SOUND_PISTOL ,
  SOUND_RAPID_SMG , SOUND_REVOLVER , SOUND_SELECT , SOUND_SHOTGUN ,
  SOUND_SMG , SOUND_GUN_JAM , SOUND_COUNT
}
 

Functions

bool Sound_System_Initialize ()
 
bool Sound_Load_Resources ()
 
void Sound_Play_Music (const char *path, int loops)
 [Update] Update Sound_Play_Music to free previous music
 
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
 
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 Music_Finished_Callback ()
 [Callback] Called when music finishes playing Plays the next queued song if available
 
void Sound_Set_Max_Channels (int numChannels)
 Sets the maximum number of sound effect channels.
 

Variables

SoundResources soundResources
 

Detailed Description

Manages audio playback for music and sound effects.

The sound system is used to play music and sound effects. It uses SDL_mixer to play the music and sound effects.

Author
Darren
Date
2025-07-03

Macro Definition Documentation

◆ MAX_MUSIC_QUEUE_SIZE

#define MAX_MUSIC_QUEUE_SIZE   20

Typedef Documentation

◆ SimpleQueue

typedef struct SimpleQueue SimpleQueue

◆ Sound

typedef struct Sound Sound

◆ SoundResources

Enumeration Type Documentation

◆ SoundEffect

Enumerator
SOUND_SWOOSH 
SOUND_GUNSHOT 
SOUND_VINE_BOOM 
SOUND_BOOST_UP 
SOUND_BUFFING 
SOUND_CRATE_OPENING 
SOUND_DASH 
SOUND_ELEVATOR_CLOSE 
SOUND_ELEVATOR_OPEN 
SOUND_ENEMY_HEALING 
SOUND_ENERGY_GUNSHOT 
SOUND_EXPLOSION 
SOUND_GRENADE_LAUNCHER 
SOUND_GUN_PICKUP 
SOUND_HITMARKER 
SOUND_KAMIKAZE_BEEP 
SOUND_LAST_STAND 
SOUND_PARRY 
SOUND_PASSIVE_OBTAINED 
SOUND_PLAYER_HEALING 
SOUND_PLAYER_HURT 
SOUND_RECALL 
SOUND_ROCKET_LAUNCH 
SOUND_SENTRY_LASER 
SOUND_SPAWN_IN 
SOUND_VANTAGE_LASER 
SOUND_BOOST_DOWN 
SOUND_HOVER 
SOUND_ARMOR_PISTOL 
SOUND_ASSAULT_RIFLE 
SOUND_AUTO_SHOTGUN 
SOUND_BATTLE_RIFLE 
SOUND_BULLPUP_RIFLE 
SOUND_BURST_RIFLE 
SOUND_PDW 
SOUND_PISTOL 
SOUND_RAPID_SMG 
SOUND_REVOLVER 
SOUND_SELECT 
SOUND_SHOTGUN 
SOUND_SMG 
SOUND_GUN_JAM 
SOUND_COUNT 

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

◆ soundResources

SoundResources soundResources
extern