]> git.mxchange.org Git - simgear.git/blob - simgear/sound/openal_test3.cxx
Fixes for headless mode.
[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     SGGeod pos;
19
20     smgr = new SGSoundMgr;
21
22     smgr->bind();
23     smgr->init();
24     sgr = smgr->find("default", true);
25     smgr->set_volume(0.9);
26     smgr->activate();
27
28     SGPath srcDir(SRC_DIR);
29
30     printf("default position and orientation\n");
31     SGSoundSample *sample1 = new SGSoundSample("jet.wav", srcDir);
32     sample1->set_volume(1.0);
33     sample1->set_pitch(1.0);
34     sample1->play_looped();
35     sgr->add(sample1, "sound1");
36     smgr->update(1.0);
37     printf("playing sample\n");
38     sleep(3);
39     sample1->stop();
40     smgr->update(3.0);
41     sleep(1);
42
43     printf("source at lat,lon = (10,-10), listener at (9.99,-9.99)\n");
44     pos = SGGeod::fromDeg(9.99,-9.99);
45     sample1->set_position( SGVec3d::fromGeod(SGGeod::fromDeg(10,-10)) );
46     smgr->set_position( SGVec3d::fromGeod(pos), pos );
47     sample1->play_looped();
48     smgr->update(1.0);
49     printf("playing sample\n");
50     sleep(3);
51     sample1->stop();
52     smgr->update(3.0);
53     sleep(1);
54
55     sgr->remove("sound1");
56     smgr->unbind();
57     sleep(2);
58     delete smgr;
59 }