]> git.mxchange.org Git - simgear.git/blob - simgear/sound/openal_test3.cxx
dccbd3d5f1c187e9820a79e36bc7eaef6bdb1c8d
[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->set_position_geod( SGGeod::fromDeg(0,0) );
26     smgr->activate();
27
28     printf("default position and orientation\n");
29     SGSoundSample *sample1 = new SGSoundSample( SRC_DIR, "jet.wav" );
30     sample1->set_volume(1.0);
31     sample1->set_pitch(1.0);
32     sample1->play_looped();
33     sgr->add(sample1, "sound1");
34     smgr->update(1.0);
35     printf("playing sample\n");
36     sleep(3);
37     sample1->stop();
38     smgr->update(3.0);
39     sleep(1);
40
41     printf("source at lat,lon = (10,-10), listener at (9.99,-9.99)\n");
42     sample1->set_position_geod( SGGeod::fromDeg(10,-10) );
43     smgr->set_position( SGGeod::fromDeg(9.99,-9.99) );
44     sample1->play_looped();
45     smgr->update(1.0);
46     printf("playing sample\n");
47     sleep(3);
48     sample1->stop();
49     smgr->update(3.0);
50     sleep(1);
51
52     sgr->remove("sound1");
53     smgr->unbind();
54     sleep(2);
55     delete smgr;
56 }