cpp_photon/test/Audio_test.cpp

89 lines
1.7 KiB
C++
Raw Normal View History

2005-05-15 02:50:07 +00:00
//This file is part of Photon (http://photon.sourceforge.net)
//Copyright (C) 2004-2005 James Turk
//
// Author:
// James Turk (jpt2433@rit.edu)
//
// Version:
2005-07-06 02:10:06 +00:00
// $Id: Audio_test.cpp,v 1.1 2005/07/06 02:10:07 cozman Exp $
2005-05-15 02:50:07 +00:00
#include "photon.hpp"
using namespace photon;
2005-07-05 06:44:55 +00:00
#include <boost/lexical_cast.hpp>
2005-07-04 03:06:48 +00:00
#ifdef PHOTON_USE_OPENAL
2005-05-15 02:50:07 +00:00
using namespace photon::audio;
2005-07-05 06:44:55 +00:00
class MainTask : public Task
{
public:
MainTask() :
Task("MainTask"),
app(AppCore::getInstance()),
video(video::VideoCore::getInstance())
{
LogSinkPtr csp( new ConsoleSink("console") );
log.addSink(csp);
video.setOrthoView(800,600);
Sample::addResource("wavdata/ocean.wav");
sample.open("wavdata/ocean.wav");
sample.play();
}
void update()
{
static double t=0;
if(app.getTime() - t > 1.0)
{
app.setTitle("FPS: " +
boost::lexical_cast<std::string>(app.getFramerate()) );
t = app.getTime();
}
video.clear();
}
private:
audio::Sample sample;
Log log;
AppCore& app;
video::VideoCore& video;
};
2005-05-15 02:50:07 +00:00
class AudioTest : public Application
{
public:
int main(const StrVec& args)
{
2005-07-05 06:44:55 +00:00
AppCore::getInstance().createDisplay(800,600,32,0,0,false);
AudioCore::setDesiredDevice("OSS");
new AudioCore;
Kernel::getInstance().addTask(TaskPtr(new MainTask()));
2005-07-04 03:06:48 +00:00
2005-07-05 06:44:55 +00:00
Kernel::getInstance().run();
2005-05-15 02:50:07 +00:00
return 0;
}
};
ENTRYPOINT(AudioTest)
2005-07-04 03:06:48 +00:00
#else
int main()
{
std::cerr << "Photon compiled without OpenAL support.\n";
}
#endif //PHOTON_USE_OPENAL