]> git.mxchange.org Git - simgear.git/commitdiff
another test program, using real world locations
authorehofman <ehofman>
Thu, 29 Oct 2009 12:53:20 +0000 (12:53 +0000)
committerTim Moore <timoore@redhat.com>
Thu, 29 Oct 2009 22:04:17 +0000 (23:04 +0100)
simgear/sound/Makefile.am
simgear/sound/openal_test2.cxx
simgear/sound/openal_test3.cxx [new file with mode: 0644]

index 67d91110502c0639adc8151bb3f3fd8e63464425..dd271496c22ba5a0be0b92fa2f5779d8892f7c71 100644 (file)
@@ -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\"
index 6ab355e36c9eea26ca0d8d4b95452116490ae616..c28957b8cc23363b68e452615f11373c00b46a9c 100644 (file)
@@ -1,10 +1,9 @@
 #include <stdio.h>
-#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 <windows.h>
+#define sleep(x) Sleep(x*1000)
 #else
-#include <unistd.h>    // sleep()
+#include <unistd.h>
 #endif
 
 #include <simgear/debug/logstream.hxx>
@@ -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 (file)
index 0000000..c5f124f
--- /dev/null
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#ifdef _WIN32
+#include <windows.h>
+#define sleep(x) Sleep(x*1000)
+#else
+#include <unistd.h>
+#endif
+
+#include <simgear/debug/logstream.hxx>
+#include <simgear/misc/sg_path.hxx>
+
+#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;
+}