FreeRTOS Emulator with SDL2 Based Graphics and Input Library  1.0
A POSIX wrapper to run FreeRTOS on an x86 machine with some basic input and output libraries aimed at making teaching FreeRTOS simpler.
GFX Sound API

An API wrapper around the SDL Mixer library to play a set of predefined pong waveforms. More...

Macros

#define GEN_ENUM(ENUM)   ENUM,
 
#define FOR_EACH_SAMPLE(SAMPLE)
 

Enumerations

enum  gfxSound_samples_e {
  a3 , a4 , a5 , b3 ,
  b4 , c3 , c4 , c5 ,
  d3 , d4 , d5 , e3 ,
  e4 , e5 , f3 , f4 ,
  f5 , g3 , g4 , g5
}
 Enum containing the currently loaded wav samples. More...
 

Functions

int gfxSoundInit (char *bin_dir_str)
 Initializes the SDL2 Mixer library and loads the wav samples specified in the gfxSound_samples_e. More...
 
void gfxSoundExit (void)
 Deinitializes the SDL2 Mixer library. More...
 
void gfxSoundPlaySample (unsigned char index)
 Plays a wav sample. More...
 
int gfxSoundLoadUserSample (const char *filepath)
 Loads a .wav sample from disk. More...
 
int gfxSoundPlayUserSample (const char *filename)
 Plays a loaded waveform. More...
 

Detailed Description

An API wrapper around the SDL Mixer library to play a set of predefined pong waveforms.

Macro Definition Documentation

◆ FOR_EACH_SAMPLE

#define FOR_EACH_SAMPLE (   SAMPLE)
Value:
SAMPLE(a3) \
SAMPLE(a4) \
SAMPLE(a5) \
SAMPLE(b3) \
SAMPLE(b4) \
SAMPLE(c3) \
SAMPLE(c4) \
SAMPLE(c5) \
SAMPLE(d3) \
SAMPLE(d4) \
SAMPLE(d5) \
SAMPLE(e3) \
SAMPLE(e4) \
SAMPLE(e5) \
SAMPLE(f3) \
SAMPLE(f4) \
SAMPLE(f5) \
SAMPLE(g3) \
SAMPLE(g4) \
SAMPLE(g5)
@ g4
Definition: gfx_sound.h:74
@ d4
Definition: gfx_sound.h:74
@ c5
Definition: gfx_sound.h:74
@ d3
Definition: gfx_sound.h:74
@ b4
Definition: gfx_sound.h:74
@ d5
Definition: gfx_sound.h:74
@ a3
Definition: gfx_sound.h:74
@ a5
Definition: gfx_sound.h:74
@ f4
Definition: gfx_sound.h:74
@ f3
Definition: gfx_sound.h:74
@ g5
Definition: gfx_sound.h:74
@ c4
Definition: gfx_sound.h:74
@ e5
Definition: gfx_sound.h:74
@ a4
Definition: gfx_sound.h:74
@ c3
Definition: gfx_sound.h:74
@ e4
Definition: gfx_sound.h:74
@ b3
Definition: gfx_sound.h:74
@ g3
Definition: gfx_sound.h:74
@ e3
Definition: gfx_sound.h:74
@ f5
Definition: gfx_sound.h:74

A list of wav filenames which are loaded

◆ GEN_ENUM

#define GEN_ENUM (   ENUM)    ENUM,

Generates an enum entry for a given string ENUM pong sample

Enumeration Type Documentation

◆ gfxSound_samples_e

Enum containing the currently loaded wav samples.

The waveforms located in the resource/waveforms folder are added using the FOR_EACH_SAMPLE macro to generate an enum that can be used to access the appropriate sample from the internal sample list.

Enumerator
a3 

a3 pong sample

a4 

a4 pong sample

a5 

a5 pong sample

b3 

b3 pong sample

b4 

b4 pong sample

c3 

c3 pong sample

c4 

c4 pong sample

c5 

c5 pong sample

d3 

d3 pong sample

d4 

d4 pong sample

d5 

d5 pong sample

e3 

e3 pong sample

e4 

e4 pong sample

e5 

e5 pong sample

f3 

f3 pong sample

f4 

f4 pong sample

f5 

f5 pong sample

g3 

g3 pong sample

g4 

g4 pong sample

g5 

g5 pong sample

Function Documentation

◆ gfxSoundExit()

void gfxSoundExit ( void  )

Deinitializes the SDL2 Mixer library.

◆ gfxSoundInit()

int gfxSoundInit ( char *  bin_dir_str)

Initializes the SDL2 Mixer library and loads the wav samples specified in the gfxSound_samples_e.

Parameters
bin_dir_strString specifying where the program's binary is located
Returns
0 on success

◆ gfxSoundLoadUserSample()

int gfxSoundLoadUserSample ( const char *  filepath)

Loads a .wav sample from disk.

The filepath must specify the location of the wavefile either relative to the executing binary or the absolute path. To ensure executing on other systems with different file system structures a relative path is recommended.

Parameters
filepathThe location of the waveform on disk to be loaded
Returns
0 on success

◆ gfxSoundPlaySample()

void gfxSoundPlaySample ( unsigned char  index)

Plays a wav sample.

Parameters
indexIndex to specify which sample to play, gfxSound_samples_e gives appropriate indices

◆ gfxSoundPlayUserSample()

int gfxSoundPlayUserSample ( const char *  filename)

Plays a loaded waveform.

Once loaded the wavefile can be played by providing either the entire filepath or the basename. Eg. A file with the path '../resources/my_sample.wav' could be played by either passing '../resources/my_sample.wav' or simply 'my_sample.wav'.

Parameters
filenameThe name of the waveform to be played
Returns
0 on success