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
$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
@ -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
navigation, FileBuffer capable of reading from archives, random number
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
specified directories or archives.
* 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
mind. Use of modern programming techniques like templates and exceptions
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 ;)
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
* Everyone who contributed to, used, or downloaded 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
* Everyone responsible for FreeMind (http://freemind.sf.net)
* 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"/>
<node ID="Freemind_Link_682620075" POSITION="right" TEXT="0.1 Release">
<font BOLD="true" NAME="SansSerif" SIZE="12"/>
<node ID="Freemind_Link_1479941799" TEXT="Clean up source">
<node ID="Freemind_Link_1271859141" TEXT="math::"/>
<node ID="Freemind_Link_510494143" TEXT="util::"/>
<node ID="Freemind_Link_1243282886" TEXT="video::"/>
<node ID="Freemind_Link_327905180" TEXT="photon:: (general)"/>
<node ID="Freemind_Link_1716705807" TEXT="clean up naturaldocs"/>
<node ID="Freemind_Link_1746871436" TEXT="remaining features">
<node ID="Freemind_Link_40954797" TEXT="improved input handling ">
<icon BUILTIN="button_ok"/>
<node ID="_" TEXT="amph listener system">
<icon BUILTIN="button_ok"/>
</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_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 ID="Freemind_Link_1092577706" TEXT="keysPressed list">
<icon BUILTIN="button_ok"/>
</node>
</node>
<node FOLDED="true" ID="Freemind_Link_486829238" POSITION="right" TEXT="0.2 Release">
<node ID="Freemind_Link_1298931281" TEXT="XML resource files"/>
<node ID="Freemind_Link_216021234" TEXT="Sprite System">
<node ID="Freemind_Link_1825420810" TEXT="Music">
<node ID="Freemind_Link_105493282" TEXT="maybe at least WAV queueing"/>
<node ID="Freemind_Link_211899568" TEXT="delay development into 0.1.x">
<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"/>
</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"/>
</node>
</node>

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// 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"
@ -35,8 +35,13 @@ AppCore::AppCore() :
AppCore::~AppCore()
{
if(dispWidth_ && dispHeight_)
{
video::VideoCore::destroy(); // destroy videocore
glfwCloseWindow(); //close GLFW window
}
glfwTerminate(); //shutdown GLFW
}

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// 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"
@ -43,7 +43,6 @@ Application::~Application()
// destroy the singletons
AppCore::destroy();
//audio::AudioCore::destroy();
Kernel::destroy();
}

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu)
//
// 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
@ -33,12 +33,12 @@ AudioCore::~AudioCore()
ALCcontext* context( alcGetCurrentContext() );
ALCdevice* device( alcGetContextsDevice(context) );
// set current context to null
alcMakeContextCurrent(0);
// destroy context & device
alcDestroyContext(context);
alcCloseDevice(device);
// set current context to null
alcMakeContextCurrent(0);
}
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
#endif
throwOpenALError("AudioCore::initOpenAL");
return util::VersionInfo(major,minor,patch);
}

View File

@ -5,17 +5,19 @@
// James Turk (jpt2433@rit.edu)
//
// 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"
using namespace photon;
#include <boost/lexical_cast.hpp>
// actual test is only compiled if OpenAL is in use
#ifdef PHOTON_USE_OPENAL
using namespace photon::audio;
class MainTask : public Task
// sole task of AudioTest
class MainTask : public Task , public InputListener
{
public:
@ -24,14 +26,13 @@ public:
app(AppCore::getInstance()),
video(video::VideoCore::getInstance())
{
LogSinkPtr csp( new ConsoleSink("console") );
log.addSink(csp);
video.setOrthoView(800,600);
video.setOrthoView(800,600); // setup view
// load a font
video::Font::addResource("font","data/FreeMono.ttf",20);
font.open("font");
// load the 6 sound effects
Sample::addResource("chimes","data/chimes.wav");
Sample::addResource("ocean","data/ocean.wav");
Sample::addResource("rain","data/rain.wav");
@ -39,6 +40,7 @@ public:
Sample::addResource("thunder","data/thunder.wav");
Sample::addResource("waterdrop","data/waterdrop.wav");
// open the sounds
chimes.open("chimes");
ocean.open("ocean");
rain.open("rain");
@ -46,31 +48,33 @@ public:
thunder.open("thunder");
waterdrop.open("waterdrop");
// make all sounds looping
chimes.setLooping(true);
ocean.setLooping(true);
rain.setLooping(true);
stream.setLooping(true);
thunder.setLooping(true);
// test Sample::isLooping via assertions
assert(!waterdrop.isLooping());
waterdrop.setLooping(true);
assert(waterdrop.isLooping());
// status holds strings describing playing status for nice output
for(int i=0; i < 6; ++i)
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 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())
{
chimes.play();
@ -81,9 +85,9 @@ public:
chimes.stop();
status[0] = NOT_PLAYING;
}
}
if(app.keyPressed(KEY_O))
{
break;
case KEY_O:
if(!ocean.isPlaying())
{
ocean.play();
@ -94,9 +98,9 @@ public:
ocean.stop();
status[1] = NOT_PLAYING;
}
}
if(app.keyPressed(KEY_R))
{
break;
case KEY_R:
if(!rain.isPlaying())
{
rain.play();
@ -107,9 +111,9 @@ public:
rain.stop();
status[2] = NOT_PLAYING;
}
}
if(app.keyPressed(KEY_S))
{
break;
case KEY_S:
if(!stream.isPlaying())
{
stream.play();
@ -120,9 +124,9 @@ public:
stream.stop();
status[3] = NOT_PLAYING;
}
}
if(app.keyPressed(KEY_T))
{
break;
case KEY_T:
if(!thunder.isPlaying())
{
thunder.play();
@ -133,9 +137,9 @@ public:
thunder.stop();
status[4] = NOT_PLAYING;
}
}
if(app.keyPressed(KEY_W))
{
break;
case KEY_W:
if(!waterdrop.isPlaying())
{
waterdrop.play();
@ -146,15 +150,18 @@ public:
waterdrop.stop();
status[5] = NOT_PLAYING;
}
}
break;
default:
break;
}
}
// called once per frame
void update()
{
static const photon::uint fontHeight(font.getHeight());
// used to measure FPS and display it in the title bar
static double t=0;
if(app.getTime() - t > 1.0)
{
app.setTitle("FPS: " +
@ -162,10 +169,12 @@ public:
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] <<
"playing" << font.endDraw();
font.beginDraw(0, 1*fontHeight) << "(O)cean is " << status[1] <<
@ -186,7 +195,7 @@ private:
audio::Sample chimes, ocean, rain, stream, thunder, waterdrop;
std::string status[6];
Log log;
// references to singleton cores
AppCore& app;
video::VideoCore& video;
};
@ -197,23 +206,29 @@ public:
int main(const StrVec& args)
{
// create window
AppCore::getInstance().createDisplay(800,600,32,0,0,false);
// create sound device
AudioCore::initAudioDevice("OSS");
// add the task to the Kernel
Kernel::getInstance().addTask(TaskPtr(new MainTask()));
// run Kernel until task finishes
Kernel::getInstance().run();
// destroy AudioCore, shuts down audio system
AudioCore::destroy();
return 0;
}
};
ENTRYPOINT(AudioTest)
ENTRYPOINT(AudioTest) // make AudioTest the entrypoint class
#else
#include <iostream>
// alternate application if OpenAL was not available
#include <iostream>
int main()
{
std::cerr << "Photon compiled without OpenAL support.\n";