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