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.c File Reference

A simple interface to play wav files using the SDL2 Mixer library. More...

#include <string.h>
#include <libgen.h>
#include <SDL2/SDL_mixer.h>
#include "gfx_sound.h"
#include "gfx_utils.h"
#include "gfx_print.h"

Classes

struct  loaded_sample
 

Macros

#define SAMPLE_FOLDER   "/../resources/waveforms/"
 
#define NUM_WAVEFORMS   20
 
#define AUDIO_CHANNELS   2
 
#define MIXING_CHANNELS   4
 
#define GEN_FULL_SAMPLE_PATH(SAMPLE)    SAMPLE_FOLDER #SAMPLE ".wav",
 

Typedefs

typedef struct loaded_sample loaded_sample_t
 

Functions

void gfxSoundExit (void)
 Deinitializes the SDL2 Mixer library. More...
 
int gfxSoundInit (char *bin_dir_str)
 Initializes the SDL2 Mixer library and loads the wav samples specified in the gfxSound_samples_e. 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...
 

Variables

Mix_Chunk * samples [20] = { 0 }
 
loaded_sample_t user_samples = { .name = "HEAD" }
 

Detailed Description

A simple interface to play wav files using the SDL2 Mixer library.

Author
Alex Hoffman
Date
18 April 2020
----------------------------------------------------------------------
Copyright (C) Alexander Hoffman, 2020
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------

Macro Definition Documentation

◆ AUDIO_CHANNELS

#define AUDIO_CHANNELS   2

◆ GEN_FULL_SAMPLE_PATH

#define GEN_FULL_SAMPLE_PATH (   SAMPLE)     SAMPLE_FOLDER #SAMPLE ".wav",

◆ MIXING_CHANNELS

#define MIXING_CHANNELS   4

◆ NUM_WAVEFORMS

#define NUM_WAVEFORMS   20

◆ SAMPLE_FOLDER

#define SAMPLE_FOLDER   "/../resources/waveforms/"

Typedef Documentation

◆ loaded_sample_t

Variable Documentation

◆ samples

Mix_Chunk* samples[20] = { 0 }

◆ user_samples

loaded_sample_t user_samples = { .name = "HEAD" }