FreeRTOS Tetris
Macros | Enumerations | Functions
TUM Sound API

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

Collaboration diagram for TUM Sound API:

Macros

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

Enumerations

enum  tumSound_samples_e { FOR_EACH_SAMPLE =(GEN_ENUM) }
 Enum containing the currently loaded wav samples. More...
 

Functions

int tumSoundInit (char *bin_dir_str)
 Initializes the SDL2 Mixer library and loads the wav samples specified in the tumSound_samples_e. More...
 
void tumSoundExit (void)
 Deinitializes the SDL2 Mixer library.
 
void tumSoundPlaySample (unsigned char index)
 Plays a wav sample. More...
 
int tumSoundLoadUserSample (const char *filepath)
 Loads a .wav sample from disk. More...
 
int tumSoundPlayUserSample (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)

#include <TUM_Sound.h>

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)

A list of wav filenames which are loaded

◆ GEN_ENUM

#define GEN_ENUM (   ENUM)    ENUM,

#include <TUM_Sound.h>

Generates an enum entry for a given string ENUM pong sample

Enumeration Type Documentation

◆ tumSound_samples_e

#include <TUM_Sound.h>

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.

Function Documentation

◆ tumSoundInit()

int tumSoundInit ( char *  bin_dir_str)

#include <TUM_Sound.h>

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

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

◆ tumSoundLoadUserSample()

int tumSoundLoadUserSample ( const char *  filepath)

#include <TUM_Sound.h>

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

◆ tumSoundPlaySample()

void tumSoundPlaySample ( unsigned char  index)

#include <TUM_Sound.h>

Plays a wav sample.

Parameters
indexIndex to specify which sample to play, tumSound_samples_e gives appropriate indices
Returns
NULL always returns NULL

◆ tumSoundPlayUserSample()

int tumSoundPlayUserSample ( const char *  filename)

#include <TUM_Sound.h>

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