Skip to content
Permalink
507e57f869
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
26 lines (24 sloc) 527 Bytes
#include "AudioH.h"
//// Deconstructor ////
Audio::~Audio()
{
SDL_CloseAudioDevice(deviceId);
SDL_FreeWAV(wavBuffer);
}
void Audio::load(const char* fileName)
{
//// Load .wav file ////
SDL_LoadWAV(fileName, &wavSpec, &wavBuffer, &wavLength);
deviceId = SDL_OpenAudioDevice(NULL, 0, &wavSpec, NULL, 0);
}
void Audio::play()
{
//// Play the Music ////
SDL_QueueAudio(deviceId,wavBuffer, wavLength);
SDL_PauseAudioDevice(deviceId, 0);
}
void Audio::stop()
{
//// Stop the Music ////
SDL_PauseAudioDevice(deviceId, 1);
}