caudio/Examples/Tutorial3_MemoryPlayback/main.cpp
Joshua Jones 75ece68dcf Added cross-platform Mutex and Thread classes.
Made cAudio, cAudioCapture, cAudioManager and other classes thread safe.
Made cAudioManager use a seperate update thread by default.
Added cAudioSleep, a cross-platform sleep() function
Moved global defines to cAudioDefines
Added defines to disable thread safety or the internal update thread if the user wishes it
Updated tutorials to reflect the changes made
2009-08-29 11:24:31 +00:00

55 lines
1.6 KiB
C++

//****************************************************************
//cAudio 1.7.1 Tutorial 3
//Basic Memory Playback *Virtual file systems*
//bling.h created with bin2h http://deadnode.org/sw/bin2h/
//****************************************************************
#include <iostream>
//Include IAudioManager so we can easily work with cAudio
#include "../../include/IAudioManager.h"
//Include IAudio so we can create cAudio objects
#include "../../include/IAudio.h"
//Include The cAudio vector class
#include "../../include/cVector3.h"
//Include our version of Sleep to free CPU usage
#include "../../include/cAudioSleep.h"
//Our Bling sound
#include "bling.h"
using namespace std;
int main(int argc, char* argv[])
{
//Make visual studio happy
cAudio::IAudio* mysound = 0x0;
//Some fancy text
cout << "cAudio 1.7.1 Tutorial 3: MemoryPlayback \n";
//Grap the cAudioManager
cAudio::IAudioManager* manager = cAudio::getAudioManager();
//Init the cAudio Engine
manager->init(argc,argv);
manager->getListener()->setPosition(cAudio::cVector3(0.0,0.0,0.0));
//Create a IAudio object and load a sound from memory. using the bling array and bling size generated by bin2h.
mysound = manager->createFromMemory("bling",(const char*)bling,bling_size,"wav");
if(mysound)
{
//Set the IAudio Sound to play2d and loop
mysound->play2d(true);
while(mysound->playing())
{
//Sleep for 10 ms to free some CPU
cAudio::cAudioSleep(10);
}
}
//Delete all IAudio sounds
manager->release();
//Shutdown cAudio
manager->shutDown();
return 0;
}