From: ehofman Date: Thu, 29 Oct 2009 12:53:20 +0000 (+0000) Subject: another test program, using real world locations X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f6358694ae8d32cd908408ccacf7ba04adbc3d10;p=simgear.git another test program, using real world locations --- diff --git a/simgear/sound/Makefile.am b/simgear/sound/Makefile.am index 67d91110..dd271496 100644 --- a/simgear/sound/Makefile.am +++ b/simgear/sound/Makefile.am @@ -18,10 +18,11 @@ libsgsound_a_SOURCES = \ soundmgr_openal.cxx \ xmlsound.cxx -check_PROGRAMS = openal_test1 openal_test2 +check_PROGRAMS = openal_test1 openal_test2 openal_test3 openal_test1_SOURCES = openal_test1.cxx openal_test2_SOURCES = openal_test2.cxx +openal_test3SOURCES = openal_test3.cxx openal_test1_LDADD = \ $(top_builddir)/simgear/debug/libsgdebug.a \ @@ -36,4 +37,13 @@ openal_test2_LDADD = \ $(top_builddir)/simgear/math/libsgmath.a \ $(openal_LIBS) +openal_test3_LDADD = \ + libsgsound.a \ + $(top_builddir)/simgear/structure/libsgstructure.a \ + $(top_builddir)/simgear/timing/libsgtiming.a \ + $(top_builddir)/simgear/debug/libsgdebug.a \ + $(top_builddir)/simgear/misc/libsgmisc.a \ + $(top_builddir)/simgear/math/libsgmath.a \ + $(openal_LIBS) -lstdc++ + INCLUDES = -I$(top_srcdir) -DSRC_DIR=\"$(top_srcdir)/simgear/sound\" diff --git a/simgear/sound/openal_test2.cxx b/simgear/sound/openal_test2.cxx index 6ab355e3..c28957b8 100644 --- a/simgear/sound/openal_test2.cxx +++ b/simgear/sound/openal_test2.cxx @@ -1,10 +1,9 @@ #include -#ifdef __MINGW32__ -// This is broken, but allows the file to compile without a POSIX -// environment. -static unsigned int sleep(unsigned int secs) { return 0; } +#ifdef _WIN32 +#include +#define sleep(x) Sleep(x*1000) #else -#include // sleep() +#include #endif #include @@ -23,6 +22,7 @@ int main( int argc, char *argv[] ) { smgr->init(); sgr = smgr->find("default", true); smgr->set_volume(0.9); + smgr->set_position( SGVec3d::fromGeod(SGGeod::fromDeg(0,0)) ); smgr->activate(); SGSoundSample *sample1 = new SGSoundSample( SRC_DIR, "jet.wav" ); diff --git a/simgear/sound/openal_test3.cxx b/simgear/sound/openal_test3.cxx new file mode 100644 index 00000000..c5f124f7 --- /dev/null +++ b/simgear/sound/openal_test3.cxx @@ -0,0 +1,55 @@ +#include +#ifdef _WIN32 +#include +#define sleep(x) Sleep(x*1000) +#else +#include +#endif + +#include +#include + +#include "soundmgr_openal.hxx" + + +int main( int argc, char *argv[] ) { + SGSampleGroup *sgr; + SGSoundMgr *smgr; + + smgr = new SGSoundMgr; + + smgr->bind(); + smgr->init(); + sgr = smgr->find("default", true); + smgr->set_volume(0.9); + smgr->set_position( SGVec3d::fromGeod(SGGeod::fromDeg(0,0)) ); + smgr->activate(); + + printf("default position and orientation\n"); + SGSoundSample *sample1 = new SGSoundSample( SRC_DIR, "jet.wav" ); + sample1->set_volume(1.0); + sample1->set_pitch(1.0); + sample1->play_looped(); + sgr->add(sample1, "sound1"); + smgr->update(1.0); + printf("playing sample\n"); + sleep(3); + sgr->stop("sound1"); + smgr->update(3.0); + sleep(1); + + printf("source at lat,lon = (10,-10), listener at (0.999,-0.999)\n"); + sample1->set_position( SGGeod::fromDeg(10,-10) ); + smgr->set_position( SGVec3d::fromGeod(SGGeod::fromDeg(9.99,-9.99)) ); + sample1->play_looped(); + smgr->update(1.0); + printf("playing sample\n"); + sleep(3); + sgr->stop("sound1"); + smgr->update(3.0); + sleep(1); + + smgr->unbind(); + sleep(2); + delete smgr; +}