Arch Game Engine  0.2
audio.cpp
1 #include "audio.h"
2 
3 Audio::~Audio() {
4  SDL_CloseAudioDevice(deviceId);
5  SDL_FreeWAV(wavBuffer);
6 }
7 
8 
9 void Audio::load(const char* filename) {
10  SDL_LoadWAV(filename, &wavSpec, &wavBuffer, &wavLength);
11  deviceId = SDL_OpenAudioDevice(NULL, 0, &wavSpec, NULL, 0);
12 }
13 
14 void Audio::play() {
15  SDL_QueueAudio(deviceId, wavBuffer, wavLength);
16  SDL_PauseAudioDevice(deviceId, 0);
17 }