audio:: and AudioTest revised

This commit is contained in:
James Turk 2005-07-19 18:35:20 +00:00
parent 06e2e736bb
commit 1a4ec6dba1
7 changed files with 242 additions and 134 deletions

View File

@ -1,5 +1,5 @@
Changelog for Photon Changelog for Photon
$Id: CHANGELOG.txt,v 1.1 2005/07/17 22:41:03 cozman Exp $ $Id: CHANGELOG.txt,v 1.2 2005/07/19 18:35:20 cozman Exp $
0.1.0 (Massachusetts) - Initial Release 0.1.0 (Massachusetts) - Initial Release
@ -11,6 +11,8 @@ $Id: CHANGELOG.txt,v 1.1 2005/07/17 22:41:03 cozman Exp $
* A wide variety of helper utilities for tasks such as filesystem * A wide variety of helper utilities for tasks such as filesystem
navigation, FileBuffer capable of reading from archives, random number navigation, FileBuffer capable of reading from archives, random number
generation, versioning, and timing generation, versioning, and timing
* Powerful input system allowing for direct access to keyboard/mouse status
or passive listeners which are notified of events when they occur.
* Resource Management system including the ability to load resources from * Resource Management system including the ability to load resources from
specified directories or archives. specified directories or archives.
* Variety of math classes including Circle, Rectangle, and Vector classes * Variety of math classes including Circle, Rectangle, and Vector classes
@ -31,5 +33,5 @@ $Id: CHANGELOG.txt,v 1.1 2005/07/17 22:41:03 cozman Exp $
* Entire library is built in a highly-modular fashion with extensibility in * Entire library is built in a highly-modular fashion with extensibility in
mind. Use of modern programming techniques like templates and exceptions mind. Use of modern programming techniques like templates and exceptions
contributes to ease of use and ease of development. contributes to ease of use and ease of development.
* 13 demo programs showing features and ease of use * 13 demo programs showing features and ease of use of various components.

View File

@ -3,6 +3,7 @@ The following people have contributed code to photon:
..yeah this list is too short right now, so help out ;) ..yeah this list is too short right now, so help out ;)
In addition, I'd like to thank: In addition, I'd like to thank:
* Sourceforge.net - Providing hosting for the project and CVS.
* Sean and Gamer Tazar from the old CoZ team, where ZEngine was born * Sean and Gamer Tazar from the old CoZ team, where ZEngine was born
* Everyone who contributed to, used, or downloaded ZEngine * Everyone who contributed to, used, or downloaded ZEngine
* Sam Lantinga and the rest of the SDL crew (without SDL, no ZEngine, * Sam Lantinga and the rest of the SDL crew (without SDL, no ZEngine,
@ -13,5 +14,8 @@ In addition, I'd like to thank:
* Jesse Maurais and DevMaster.net for the OpenAL tutorials * Jesse Maurais and DevMaster.net for the OpenAL tutorials
* Everyone responsible for FreeMind (http://freemind.sf.net) * Everyone responsible for FreeMind (http://freemind.sf.net)
* The Ubuntu Team (http://ubuntulinux.com) * The Ubuntu Team (http://ubuntulinux.com)
* Makoto Matsumoto and Takuji Nishimura for authoring the Mersenne Twister
algorithm, and making it freely available.
http://www.math.keio.ac.jp/~matumoto/emt.html
$Id: CREDITS.txt,v 1.1 2005/07/17 22:41:03 cozman Exp $ $Id: CREDITS.txt,v 1.2 2005/07/19 18:35:20 cozman Exp $

145
photon.mm
View File

@ -5,45 +5,126 @@
<font BOLD="true" NAME="SansSerif" SIZE="12"/> <font BOLD="true" NAME="SansSerif" SIZE="12"/>
<node ID="Freemind_Link_682620075" POSITION="right" TEXT="0.1 Release"> <node ID="Freemind_Link_682620075" POSITION="right" TEXT="0.1 Release">
<font BOLD="true" NAME="SansSerif" SIZE="12"/> <font BOLD="true" NAME="SansSerif" SIZE="12"/>
<node ID="Freemind_Link_1479941799" TEXT="Clean up source"> <node ID="Freemind_Link_1746871436" TEXT="remaining features">
<node ID="Freemind_Link_1271859141" TEXT="math::"/> <node ID="Freemind_Link_40954797" TEXT="improved input handling ">
<node ID="Freemind_Link_510494143" TEXT="util::"/> <icon BUILTIN="button_ok"/>
<node ID="Freemind_Link_1243282886" TEXT="video::"/> <node ID="_" TEXT="amph listener system">
<node ID="Freemind_Link_327905180" TEXT="photon:: (general)"/> <icon BUILTIN="button_ok"/>
<node ID="Freemind_Link_1716705807" TEXT="clean up naturaldocs"/>
</node> </node>
<node ID="Freemind_Link_1153941464" TEXT="test compilation on fresh systems"> <node ID="Freemind_Link_1092577706" TEXT="keysPressed list">
<node ID="Freemind_Link_1403005191" TEXT="test compilation on clean linux system"/> <icon BUILTIN="button_ok"/>
<node ID="Freemind_Link_617919930" TEXT="test compilation on windows system"/>
<node ID="Freemind_Link_510637" TEXT="OSX tester?"/>
</node>
<node ID="Freemind_Link_1010220321" TEXT="test all tests"/>
<node ID="Freemind_Link_1870184326" TEXT="example game">
<node ID="Freemind_Link_714736465" TEXT="Let&apos;s Draw"/>
<node COLOR="#000000" ID="Freemind_Link_597173063" TEXT="Asteroids"/>
</node>
<node ID="Freemind_Link_1746871436" TEXT="possible features">
<node ID="Freemind_Link_40954797" TEXT="Decide on callbacks (push to 0.1.x possibly)"/>
<node ID="Freemind_Link_547285954" TEXT="Decide on Kernel/Appcore Test"/>
<node ID="Freemind_Link_1825420810" TEXT="Music"/>
</node> </node>
</node> </node>
<node FOLDED="true" ID="Freemind_Link_486829238" POSITION="right" TEXT="0.2 Release"> <node ID="Freemind_Link_1825420810" TEXT="Music">
<node ID="Freemind_Link_1298931281" TEXT="XML resource files"/> <node ID="Freemind_Link_105493282" TEXT="maybe at least WAV queueing"/>
<node ID="Freemind_Link_216021234" TEXT="Sprite System"> <node ID="Freemind_Link_211899568" TEXT="delay development into 0.1.x">
<font NAME="SansSerif" SIZE="12"/> <font NAME="SansSerif" SIZE="12"/>
</node>
<node ID="Freemind_Link_1497432478" TEXT="Particle System"/>
<node ID="Freemind_Link_1339011485" TEXT="Tilemap System"/>
<node ID="Freemind_Link_1070201117" TEXT="Transitions"/>
<node ID="Freemind_Link_654490435" TEXT="Second Example Game">
<node ID="Freemind_Link_1191623789" TEXT="Public Project?"/>
</node>
<node COLOR="#000000" ID="Freemind_Link_420721466" TEXT="XML/XSLT sink">
<icon BUILTIN="help"/> <icon BUILTIN="help"/>
</node> </node>
</node> </node>
<node COLOR="#147f1e" ID="Freemind_Link_438641521" POSITION="left" TEXT="Version: $Id: photon.mm,v 1.20 2005/07/18 05:14:18 cozman Exp $"> <node ID="Freemind_Link_547285954" TEXT="Kernel Test">
<node ID="Freemind_Link_1976399424" TEXT="make call to keep/remove Kernel system">
<icon BUILTIN="messagebox_warning"/>
</node>
</node>
<node ID="Freemind_Link_261923672" TEXT="change way Audio is enabled">
<icon BUILTIN="button_ok"/>
<node ID="Freemind_Link_1100203457" TEXT="fixed ~AudioCore"/>
</node>
</node>
<node ID="Freemind_Link_1716705807" TEXT="clean up naturaldocs"/>
<node ID="Freemind_Link_1010220321" TEXT="clean/test all tests">
<node ID="Freemind_Link_129725390" TEXT="Audio">
<icon BUILTIN="button_ok"/>
</node>
<node ID="Freemind_Link_543532536" TEXT="ConfigFile"/>
<node ID="Freemind_Link_1037234161" TEXT="Font"/>
<node ID="Freemind_Link_1574983928" TEXT="Image"/>
<node ID="Freemind_Link_83171017" TEXT="Input"/>
<node ID="Freemind_Link_714170273" TEXT="Log"/>
<node ID="Freemind_Link_1336661607" TEXT="Pen"/>
<node ID="Freemind_Link_26290657" TEXT="RandGen"/>
<node ID="Freemind_Link_1563035547" TEXT="Texture"/>
<node ID="Freemind_Link_226187774" TEXT="exception"/>
<node ID="Freemind_Link_120826083" TEXT="filesys"/>
<node ID="Freemind_Link_1985120655" TEXT="math"/>
</node>
<node ID="Freemind_Link_1153941464" TEXT="test compilation on fresh systems">
<node ID="Freemind_Link_1403005191" TEXT="test compilation on clean linux system"/>
<node ID="Freemind_Link_617919930" TEXT="test compilation on windows system">
<node ID="Freemind_Link_962964571" TEXT="MingW"/>
<node ID="Freemind_Link_601778960" TEXT="visual c++"/>
</node>
<node ID="Freemind_Link_510637" TEXT="OSX tester?">
<node ID="Freemind_Link_1837644449" TEXT="gamedev"/>
<node ID="Freemind_Link_867673431" TEXT="OSX dev community"/>
<node ID="Freemind_Link_1722199385" TEXT="sourceforge">
<node ID="Freemind_Link_518828740" TEXT="job posting"/>
<node ID="Freemind_Link_997339944" TEXT="compile farm">
<icon BUILTIN="button_cancel"/>
</node>
</node>
</node>
</node>
<node ID="Freemind_Link_1870184326" TEXT="example game">
<node COLOR="#000000" ID="Freemind_Link_597173063" TEXT="Asteroids"/>
<node ID="Freemind_Link_719722821" TEXT="Lunar Lander"/>
<node ID="Freemind_Link_173048174" TEXT="Missile Command"/>
</node>
</node>
<node FOLDED="true" ID="Freemind_Link_486829238" POSITION="right" TEXT="0.2 Release">
<font BOLD="true" NAME="SansSerif" SIZE="12"/>
<node FOLDED="true" ID="Freemind_Link_103747781" TEXT="New Features">
<font NAME="SansSerif" SIZE="12"/>
<node COLOR="#000000" ID="Freemind_Link_420721466" TEXT="XML/XSLT sink"/>
<node ID="Freemind_Link_1298931281" TEXT="XML resource files"/>
<node ID="Freemind_Link_1070201117" TEXT="Transitions">
<node ID="Freemind_Link_664044389" TEXT="investigate what other libs do"/>
<node ID="Freemind_Link_1667343634" TEXT="render to texture?"/>
</node>
<node ID="Freemind_Link_1339011485" TEXT="Tilemap System"/>
<node ID="Freemind_Link_1497432478" TEXT="Particle System"/>
<node ID="Freemind_Link_216021234" TEXT="Sprite System">
<font NAME="SansSerif" SIZE="12"/>
</node>
</node>
<node FOLDED="true" ID="Freemind_Link_654490435" TEXT="Second Example Game">
<node ID="Freemind_Link_1191623789" TEXT="Public Project?"/>
</node>
<node FOLDED="true" ID="Freemind_Link_903043501" TEXT="Improvements">
<node ID="Freemind_Link_878549222" TEXT="drop alut dependency"/>
<node ID="Freemind_Link_1362733907" TEXT="investigate dropping Corona"/>
</node>
</node>
<node FOLDED="true" ID="Freemind_Link_1111954089" POSITION="right" TEXT="Long Term">
<font BOLD="true" NAME="SansSerif" SIZE="12"/>
<node FOLDED="true" ID="Freemind_Link_1066996987" TEXT="New Features">
<font NAME="SansSerif" SIZE="12"/>
<node ID="Freemind_Link_539015028" TEXT="physics:: (similar to math::)"/>
<node FOLDED="true" ID="Freemind_Link_1107695046" TEXT="gui::">
<node ID="Freemind_Link_548983970" TEXT="skinnable XML based"/>
</node>
<node FOLDED="true" ID="Freemind_Link_304523376" TEXT="network::">
<node ID="Freemind_Link_717482997" TEXT="wrap enet?"/>
</node>
<node ID="Freemind_Link_21483700" TEXT="python interface">
<icon BUILTIN="help"/>
</node>
<node ID="Freemind_Link_1045478290" TEXT="lua integration">
<icon BUILTIN="help"/>
</node>
<node ID="Freemind_Link_1083759822" TEXT="java interface">
<icon BUILTIN="help"/>
</node>
</node>
<node FOLDED="true" ID="Freemind_Link_1067043723" TEXT="allow for alternate backends ">
<node ID="Freemind_Link_1997175841" TEXT="audiere for audio"/>
<node ID="Freemind_Link_961284194" TEXT="SDL backend">
<icon BUILTIN="help"/>
</node>
</node>
</node>
<node COLOR="#147f1e" ID="Freemind_Link_438641521" POSITION="left" TEXT="Version: $Id: photon.mm,v 1.21 2005/07/19 18:35:20 cozman Exp $">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/> <font ITALIC="true" NAME="SansSerif" SIZE="12"/>
</node> </node>
</node> </node>

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: AppCore.cpp,v 1.11 2005/07/19 05:45:23 cozman Exp $ // $Id: AppCore.cpp,v 1.12 2005/07/19 18:35:20 cozman Exp $
#include "AppCore.hpp" #include "AppCore.hpp"
@ -35,8 +35,13 @@ AppCore::AppCore() :
AppCore::~AppCore() AppCore::~AppCore()
{ {
video::VideoCore::destroy(); // destroy videocore
glfwCloseWindow(); //close GLFW window if(dispWidth_ && dispHeight_)
{
video::VideoCore::destroy(); // destroy videocore
glfwCloseWindow(); //close GLFW window
}
glfwTerminate(); //shutdown GLFW glfwTerminate(); //shutdown GLFW
} }

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Application.cpp,v 1.12 2005/07/19 01:31:38 cozman Exp $ // $Id: Application.cpp,v 1.13 2005/07/19 18:35:20 cozman Exp $
#include "Application.hpp" #include "Application.hpp"
@ -43,7 +43,6 @@ Application::~Application()
// destroy the singletons // destroy the singletons
AppCore::destroy(); AppCore::destroy();
//audio::AudioCore::destroy();
Kernel::destroy(); Kernel::destroy();
} }

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: AudioCore.cpp,v 1.9 2005/07/19 05:56:08 cozman Exp $ // $Id: AudioCore.cpp,v 1.10 2005/07/19 18:35:20 cozman Exp $
#ifdef PHOTON_USE_OPENAL #ifdef PHOTON_USE_OPENAL
@ -33,12 +33,12 @@ AudioCore::~AudioCore()
ALCcontext* context( alcGetCurrentContext() ); ALCcontext* context( alcGetCurrentContext() );
ALCdevice* device( alcGetContextsDevice(context) ); ALCdevice* device( alcGetContextsDevice(context) );
// set current context to null
alcMakeContextCurrent(0);
// destroy context & device // destroy context & device
alcDestroyContext(context); alcDestroyContext(context);
alcCloseDevice(device); alcCloseDevice(device);
// set current context to null
alcMakeContextCurrent(0);
} }
std::string AudioCore::getAudioDeviceName() const std::string AudioCore::getAudioDeviceName() const
@ -140,6 +140,8 @@ util::VersionInfo AudioCore::initOpenAL(const std::string& deviceName)
#warning OpenAL only built on Windows/Linux, find out version on OSX #warning OpenAL only built on Windows/Linux, find out version on OSX
#endif #endif
throwOpenALError("AudioCore::initOpenAL");
return util::VersionInfo(major,minor,patch); return util::VersionInfo(major,minor,patch);
} }

View File

@ -5,17 +5,19 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Audio_test.cpp,v 1.4 2005/07/19 05:57:58 cozman Exp $ // $Id: Audio_test.cpp,v 1.5 2005/07/19 18:35:20 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
// actual test is only compiled if OpenAL is in use
#ifdef PHOTON_USE_OPENAL #ifdef PHOTON_USE_OPENAL
using namespace photon::audio; using namespace photon::audio;
class MainTask : public Task // sole task of AudioTest
class MainTask : public Task , public InputListener
{ {
public: public:
@ -24,14 +26,13 @@ public:
app(AppCore::getInstance()), app(AppCore::getInstance()),
video(video::VideoCore::getInstance()) video(video::VideoCore::getInstance())
{ {
LogSinkPtr csp( new ConsoleSink("console") ); video.setOrthoView(800,600); // setup view
log.addSink(csp);
video.setOrthoView(800,600);
// load a font
video::Font::addResource("font","data/FreeMono.ttf",20); video::Font::addResource("font","data/FreeMono.ttf",20);
font.open("font"); font.open("font");
// load the 6 sound effects
Sample::addResource("chimes","data/chimes.wav"); Sample::addResource("chimes","data/chimes.wav");
Sample::addResource("ocean","data/ocean.wav"); Sample::addResource("ocean","data/ocean.wav");
Sample::addResource("rain","data/rain.wav"); Sample::addResource("rain","data/rain.wav");
@ -39,6 +40,7 @@ public:
Sample::addResource("thunder","data/thunder.wav"); Sample::addResource("thunder","data/thunder.wav");
Sample::addResource("waterdrop","data/waterdrop.wav"); Sample::addResource("waterdrop","data/waterdrop.wav");
// open the sounds
chimes.open("chimes"); chimes.open("chimes");
ocean.open("ocean"); ocean.open("ocean");
rain.open("rain"); rain.open("rain");
@ -46,115 +48,120 @@ public:
thunder.open("thunder"); thunder.open("thunder");
waterdrop.open("waterdrop"); waterdrop.open("waterdrop");
// make all sounds looping
chimes.setLooping(true); chimes.setLooping(true);
ocean.setLooping(true); ocean.setLooping(true);
rain.setLooping(true); rain.setLooping(true);
stream.setLooping(true); stream.setLooping(true);
thunder.setLooping(true); thunder.setLooping(true);
// test Sample::isLooping via assertions
assert(!waterdrop.isLooping()); assert(!waterdrop.isLooping());
waterdrop.setLooping(true); waterdrop.setLooping(true);
assert(waterdrop.isLooping()); assert(waterdrop.isLooping());
// status holds strings describing playing status for nice output
for(int i=0; i < 6; ++i) for(int i=0; i < 6; ++i)
status[i] = "NOT "; status[i] = "NOT ";
} }
void checkKeys() // executes the checking of the keys, when a key is pressed
// the state is toggled
void onKeyPress(int key)
{ {
static const std::string NOT_PLAYING = "NOT "; static const std::string NOT_PLAYING = "NOT ";
static scalar lastCheck = 0;
if(app.getTime() - lastCheck > 0.1) switch(key)
{ {
lastCheck = app.getTime();
if(app.keyPressed(KEY_C)) case KEY_C:
if(!chimes.isPlaying())
{ {
if(!chimes.isPlaying()) chimes.play();
{ status[0] = "";
chimes.play();
status[0] = "";
}
else
{
chimes.stop();
status[0] = NOT_PLAYING;
}
} }
if(app.keyPressed(KEY_O)) else
{ {
if(!ocean.isPlaying()) chimes.stop();
{ status[0] = NOT_PLAYING;
ocean.play();
status[1] = "";
}
else
{
ocean.stop();
status[1] = NOT_PLAYING;
}
} }
if(app.keyPressed(KEY_R)) break;
case KEY_O:
if(!ocean.isPlaying())
{ {
if(!rain.isPlaying()) ocean.play();
{ status[1] = "";
rain.play();
status[2] = "";
}
else
{
rain.stop();
status[2] = NOT_PLAYING;
}
} }
if(app.keyPressed(KEY_S)) else
{ {
if(!stream.isPlaying()) ocean.stop();
{ status[1] = NOT_PLAYING;
stream.play();
status[3] = "";
}
else
{
stream.stop();
status[3] = NOT_PLAYING;
}
} }
if(app.keyPressed(KEY_T)) break;
case KEY_R:
if(!rain.isPlaying())
{ {
if(!thunder.isPlaying()) rain.play();
{ status[2] = "";
thunder.play();
status[4] = "";
}
else
{
thunder.stop();
status[4] = NOT_PLAYING;
}
} }
if(app.keyPressed(KEY_W)) else
{ {
if(!waterdrop.isPlaying()) rain.stop();
{ status[2] = NOT_PLAYING;
waterdrop.play();
status[5] = "";
}
else
{
waterdrop.stop();
status[5] = NOT_PLAYING;
}
} }
break;
case KEY_S:
if(!stream.isPlaying())
{
stream.play();
status[3] = "";
}
else
{
stream.stop();
status[3] = NOT_PLAYING;
}
break;
case KEY_T:
if(!thunder.isPlaying())
{
thunder.play();
status[4] = "";
}
else
{
thunder.stop();
status[4] = NOT_PLAYING;
}
break;
case KEY_W:
if(!waterdrop.isPlaying())
{
waterdrop.play();
status[5] = "";
}
else
{
waterdrop.stop();
status[5] = NOT_PLAYING;
}
break;
default:
break;
} }
} }
// called once per frame
void update() void update()
{ {
static const photon::uint fontHeight(font.getHeight()); // used to measure FPS and display it in the title bar
static double t=0; static double t=0;
if(app.getTime() - t > 1.0) if(app.getTime() - t > 1.0)
{ {
app.setTitle("FPS: " + app.setTitle("FPS: " +
@ -162,10 +169,12 @@ public:
t = app.getTime(); t = app.getTime();
} }
checkKeys(); // used for calculating draw position
static const photon::uint fontHeight(font.getHeight());
video.clear(); video.clear(); // clear display before drawing
// draw the status of all 6 sounds
font.beginDraw(0, 0*fontHeight) << "(C)himes is " << status[0] << font.beginDraw(0, 0*fontHeight) << "(C)himes is " << status[0] <<
"playing" << font.endDraw(); "playing" << font.endDraw();
font.beginDraw(0, 1*fontHeight) << "(O)cean is " << status[1] << font.beginDraw(0, 1*fontHeight) << "(O)cean is " << status[1] <<
@ -186,7 +195,7 @@ private:
audio::Sample chimes, ocean, rain, stream, thunder, waterdrop; audio::Sample chimes, ocean, rain, stream, thunder, waterdrop;
std::string status[6]; std::string status[6];
Log log; // references to singleton cores
AppCore& app; AppCore& app;
video::VideoCore& video; video::VideoCore& video;
}; };
@ -197,23 +206,29 @@ public:
int main(const StrVec& args) int main(const StrVec& args)
{ {
// create window
AppCore::getInstance().createDisplay(800,600,32,0,0,false); AppCore::getInstance().createDisplay(800,600,32,0,0,false);
// create sound device
AudioCore::initAudioDevice("OSS");
AudioCore::initAudioDevice("OSS"); // add the task to the Kernel
Kernel::getInstance().addTask(TaskPtr(new MainTask())); Kernel::getInstance().addTask(TaskPtr(new MainTask()));
// run Kernel until task finishes
Kernel::getInstance().run(); Kernel::getInstance().run();
// destroy AudioCore, shuts down audio system
AudioCore::destroy();
return 0; return 0;
} }
}; };
ENTRYPOINT(AudioTest) ENTRYPOINT(AudioTest) // make AudioTest the entrypoint class
#else #else
#include <iostream>
// alternate application if OpenAL was not available
#include <iostream>
int main() int main()
{ {
std::cerr << "Photon compiled without OpenAL support.\n"; std::cerr << "Photon compiled without OpenAL support.\n";