]> git.mxchange.org Git - simgear.git/blob - simgear/sound/openal_test3.cxx
the wrong name also mislead me: rotate velocity to the proper quat
[simgear.git] / simgear / sound / openal_test3.cxx
1 #include <stdio.h>
2 #ifdef _WIN32
3 #include <windows.h>
4 #define sleep(x) Sleep(x*1000)
5 #else
6 #include <unistd.h>
7 #endif
8
9 #include <simgear/debug/logstream.hxx>
10 #include <simgear/misc/sg_path.hxx>
11
12 #include "soundmgr_openal.hxx"
13
14
15 int main( int argc, char *argv[] ) {
16     SGSampleGroup *sgr;
17     SGSoundMgr *smgr;
18
19     smgr = new SGSoundMgr;
20
21     smgr->bind();
22     smgr->init();
23     sgr = smgr->find("default", true);
24     smgr->set_volume(0.9);
25     smgr->activate();
26
27     printf("default position and orientation\n");
28     SGSoundSample *sample1 = new SGSoundSample( SRC_DIR, "jet.wav" );
29     sample1->set_volume(1.0);
30     sample1->set_pitch(1.0);
31     sample1->play_looped();
32     sgr->add(sample1, "sound1");
33     smgr->update(1.0);
34     printf("playing sample\n");
35     sleep(3);
36     sample1->stop();
37     smgr->update(3.0);
38     sleep(1);
39
40     printf("source at lat,lon = (10,-10), listener at (9.99,-9.99)\n");
41     sample1->set_position( SGVec3d::fromGeod(SGGeod::fromDeg(10,-10)) );
42     smgr->set_position( SGVec3d::fromGeod(SGGeod::fromDeg(9.99,-9.99)) );
43     sample1->play_looped();
44     smgr->update(1.0);
45     printf("playing sample\n");
46     sleep(3);
47     sample1->stop();
48     smgr->update(3.0);
49     sleep(1);
50
51     sgr->remove("sound1");
52     smgr->unbind();
53     sleep(2);
54     delete smgr;
55 }