-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleAudio.cpp
More file actions
60 lines (46 loc) · 1.07 KB
/
ModuleAudio.cpp
File metadata and controls
60 lines (46 loc) · 1.07 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "Globals.h"
#include "Application.h"
#include "ModuleAudio.h"
#include "SDL/include/SDL.h"
#include "SDL_mixer\include\SDL_mixer.h"
ModuleAudio::ModuleAudio()
{
audio[last];
}
ModuleAudio::~ModuleAudio()
{}
bool ModuleAudio::Init()
{
if (Mix_Init(MIX_INIT_OGG) == 0)
{
LOG("An error has ocurred while initializing the audio: %s", SDL_GetError())
return false;
}
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) == -1)
{
LOG("An error has ocurred while opening the audio has ocurred: %s", SDL_GetError())
}
ModuleAudio::Load("Gunbird OST Trump A.ogg");
if (Mix_PlayMusic(audio[last], -1) == -1)
{
LOG("An error has ocurred while reproducing the audio %s", SDL_GetError())
}
return true;
}
bool ModuleAudio::CleanUp()
{
LOG("Freeing audio");
Mix_FreeMusic(audio[last]);
//Mix_FreeMusic();//Free mixer
Mix_Quit();
return true;
}
Mix_Music* const ModuleAudio::Load(const char* path)
{
audio[last] = Mix_LoadMUS(path);
if (audio[last] == NULL)
{
LOG("An error has ocurred when loading the sound: %s", SDL_GetError())
}
return audio[last];
}