00001 #include <stdio.h>
00002 #ifdef _WIN32
00003 #include <windows.h>
00004 #define sleep(x) Sleep(x*1000)
00005 #else
00006 #include <unistd.h>
00007 #endif
00008
00009 #include <simgear/debug/logstream.hxx>
00010 #include <simgear/misc/sg_path.hxx>
00011
00012 #include "soundmgr_openal.hxx"
00013
00014
00015 int main( int argc, char *argv[] ) {
00016 SGSampleGroup *sgr;
00017 SGSoundMgr *smgr;
00018 SGGeod pos;
00019
00020 smgr = new SGSoundMgr;
00021
00022 smgr->bind();
00023 smgr->init();
00024 sgr = smgr->find("default", true);
00025 smgr->set_volume(0.9);
00026 smgr->activate();
00027
00028 printf("default position and orientation\n");
00029 SGSoundSample *sample1 = new SGSoundSample( SRC_DIR, "jet.wav" );
00030 sample1->set_volume(1.0);
00031 sample1->set_pitch(1.0);
00032 sample1->play_looped();
00033 sgr->add(sample1, "sound1");
00034 smgr->update(1.0);
00035 printf("playing sample\n");
00036 sleep(3);
00037 sample1->stop();
00038 smgr->update(3.0);
00039 sleep(1);
00040
00041 printf("source at lat,lon = (10,-10), listener at (9.99,-9.99)\n");
00042 pos = SGGeod::fromDeg(9.99,-9.99);
00043 sample1->set_position( SGVec3d::fromGeod(SGGeod::fromDeg(10,-10)) );
00044 smgr->set_position( SGVec3d::fromGeod(pos), pos );
00045 sample1->play_looped();
00046 smgr->update(1.0);
00047 printf("playing sample\n");
00048 sleep(3);
00049 sample1->stop();
00050 smgr->update(3.0);
00051 sleep(1);
00052
00053 sgr->remove("sound1");
00054 smgr->unbind();
00055 sleep(2);
00056 delete smgr;
00057 }