GBAlatro
A Demake of Balatro for the GBA
Loading...
Searching...
No Matches
audio_utils.h File Reference

Utilities for using maxmod to play sound effects. More...

#include "game_variables.h"
#include <mm_types.h>

Go to the source code of this file.

Macros

#define MM_MODULE_FULL_VOLUME   1024
 The maximum volume for maxmod module volume (main theme)
 
#define MM_SFX_FULL_VOLUME   255
 The maximum volume for maxmod mm_sound_effect.volume.
 
#define MM_PAN_CENTER   128
 The center pan of stereo audio for maxmod.
 
#define MM_BASE_PITCH_RATE   1024
 The default pitch rate for the sound effect played.
 
#define SFX_DEFAULT_VOLUME   MM_SFX_FULL_VOLUME
 Default volume for sound effects.
 
#define SFX_DEFAULT_PAN   MM_PAN_CENTER
 The default stereo pan, will always be center pan.
 
#define GBAL_MM_NUM_CHANNELS   14
 

Functions

void play_sfx (mm_word id, mm_word rate, mm_byte volume)
 Play a sound effect, wrapper for mmEffectEx() See https://maxmod.org/ref/functions/mm_sound_effect.html and https://maxmod.org/ref/functions/mmEffectEx.html.
 
void play_lose_music (void)
 Play music at a low pitch and slow tempo (lose screen)
 
void play_regular_music (void)
 Play music at a normal pitch and tempo.
 
void set_volume (int volume)
 
int volume_module_step_to_val (unsigned char step)
 Get MaxMod module audio value from VOLUME_OPTION value.
 

Detailed Description

Utilities for using maxmod to play sound effects.

Definition in file audio_utils.h.

Macro Definition Documentation

◆ GBAL_MM_NUM_CHANNELS

#define GBAL_MM_NUM_CHANNELS   14

The number of audio channels to allocate for maxmod, passed to mmInitDefault()

Definition at line 56 of file audio_utils.h.

◆ MM_BASE_PITCH_RATE

#define MM_BASE_PITCH_RATE   1024

The default pitch rate for the sound effect played.

Increasing the rate increases the pitch, while decreasing lowers the pitch.

Definition at line 37 of file audio_utils.h.

◆ MM_MODULE_FULL_VOLUME

#define MM_MODULE_FULL_VOLUME   1024

The maximum volume for maxmod module volume (main theme)

Definition at line 17 of file audio_utils.h.

◆ MM_PAN_CENTER

#define MM_PAN_CENTER   128

The center pan of stereo audio for maxmod.

Definition at line 29 of file audio_utils.h.

◆ MM_SFX_FULL_VOLUME

#define MM_SFX_FULL_VOLUME   255

The maximum volume for maxmod mm_sound_effect.volume.

Definition at line 23 of file audio_utils.h.

◆ SFX_DEFAULT_PAN

#define SFX_DEFAULT_PAN   MM_PAN_CENTER

The default stereo pan, will always be center pan.

Definition at line 49 of file audio_utils.h.

◆ SFX_DEFAULT_VOLUME

#define SFX_DEFAULT_VOLUME   MM_SFX_FULL_VOLUME

Default volume for sound effects.

Definition at line 43 of file audio_utils.h.

Function Documentation

◆ play_lose_music()

void play_lose_music ( void  )

Play music at a low pitch and slow tempo (lose screen)

Definition at line 116 of file audio_utils.c.

◆ play_regular_music()

void play_regular_music ( void  )

Play music at a normal pitch and tempo.

Definition at line 135 of file audio_utils.c.

◆ play_sfx()

void play_sfx ( mm_word  id,
mm_word  rate,
mm_byte  volume 
)

Play a sound effect, wrapper for mmEffectEx() See https://maxmod.org/ref/functions/mm_sound_effect.html and https://maxmod.org/ref/functions/mmEffectEx.html.

Parameters
idthe sound id to play, from maxmod compiled soundbank.h header
ratethe pitch rate, the default value is MM_BASE_PTCH_RATE
volumethe volume ranging from 0 (silent) to 255 (loudest)

Definition at line 103 of file audio_utils.c.

◆ set_volume()

void set_volume ( int  volume)

Definition at line 146 of file audio_utils.c.

◆ volume_module_step_to_val()

int volume_module_step_to_val ( unsigned char  step)
inline

Get MaxMod module audio value from VOLUME_OPTION value.

Parameters
stepVOLUME_OPTION between VOLUME_OPTION_MIN and VOLUME_OPTION_MAX

Definition at line 85 of file audio_utils.h.