-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudio.h
More file actions
41 lines (34 loc) · 1.68 KB
/
Audio.h
File metadata and controls
41 lines (34 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef AUDIO_H
#define AUDIO_H
//Allegro libraries
#include <allegro5/allegro.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
//Other libraries needed
#include <string>
/*
* This is the audio library. Everything related with the audio
* will be programmed here.
*
* Keep in mind the difference between sound and song, being the
* first one considered as a soundEffect that might be played when
* certain circumstances occurs and a song to be the music played
* in the background of the game.
*/
//Types of playmodes.
enum playmodeType{ once, loop, bidir };
//Loads a sound. | PARAMETERS: Variable, directory of the sound file.
void loadSound(ALLEGRO_SAMPLE * &sound, std::string directory);
//Loads a song | PARAMETERS: Song, directory, instance, playmode (once, loop, bidir).
void loadSong(ALLEGRO_SAMPLE * &song, std::string directory, ALLEGRO_SAMPLE_INSTANCE * &songInstance, playmodeType playmode);
//Plays a sound | PARAMETERS: Sound, playmode (once/loop/birir), volume, pan (headphones side), speed.
void playSound(ALLEGRO_SAMPLE *sound, playmodeType playmode, float volume = 1.0, float pan = 0.0, float speed = 1.0);
//Plays a song | PARAMETERS: Song.
void playSong(ALLEGRO_SAMPLE_INSTANCE *songInstance);
//Stops a song | PARAMETERS: Song.
void stopSong(ALLEGRO_SAMPLE_INSTANCE *songInstance);
//Destroys and frees the memmory and resources used by the sound. Also lets the pointer to nullptr | PARAMETERS: Sound.
void destroySound(ALLEGRO_SAMPLE * &soundeffect);
//Destroys and frees the memmory and resources used by the song. Also lets the pointer to nullptr | PARAMETERS: Song.
void destroySong(ALLEGRO_SAMPLE * &song, ALLEGRO_SAMPLE_INSTANCE * &songInstance);
#endif