]> git.mxchange.org Git - simgear.git/blob - simgear/sound/openal_test2.cxx
another test program, using real world locations
[simgear.git] / simgear / sound / openal_test2.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( SGVec3d::fromGeod(SGGeod::fromDeg(0,0)) );
26     smgr->activate();
27
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 sample1\n");
35     sleep(1);
36
37     SGSoundSample *sample2 = new SGSoundSample( SRC_DIR, "jet.wav" );
38     sample2->set_volume(0.5);
39     sample2->set_pitch(0.4);
40     sample2->play_looped();
41     sgr->add(sample2, "sound2");
42     smgr->update(1.0);
43     printf("playing sample2\n");
44     sleep(1);
45
46     SGSoundSample *sample3 = new SGSoundSample( SRC_DIR, "jet.wav" );
47     sample3->set_volume(0.5);
48     sample3->set_pitch(0.8);
49     sample3->play_looped();
50     sgr->add(sample3, "sound3");
51     smgr->update(1.0);
52     printf("playing sample3\n");
53     sleep(1);
54
55     SGSoundSample *sample4 = new SGSoundSample( SRC_DIR, "jet.wav" );
56     sample4->set_volume(0.5);
57     sample4->set_pitch(1.2);
58     sample4->play_looped();
59     sgr->add(sample4, "sound4");
60     smgr->update(1.0);
61     printf("playing sample4\n");
62     sleep(1);
63
64     SGSoundSample *sample5 = new SGSoundSample( SRC_DIR, "jet.wav" );
65     sample5->set_volume(0.5);
66     sample5->set_pitch(1.6);
67     sample5->play_looped();
68     sgr->add(sample5, "sound5");
69     smgr->update(1.0);
70     printf("playing sample5\n");
71     sleep(1);
72
73     SGSoundSample *sample6 = new SGSoundSample( SRC_DIR, "jet.wav" );
74     sample6->set_volume(0.5);
75     sample6->set_pitch(2.0);
76     sample6->play_looped();
77     sgr->add(sample6, "sound6");
78     smgr->update(1.0);
79     printf("playing sample6\n");
80     sleep(1);
81
82     for (int i=0; i<10; i++) {
83         sleep(1);
84         smgr->update(1);
85     }
86
87     sgr->stop("sound1");
88     sgr->stop("sound2");
89     sgr->stop("sound3");
90     sleep(0.5);
91     smgr->update(0.5);
92     sgr->stop("sound4");
93     sgr->stop("sound5");
94     sgr->stop("sound6");
95     smgr->update(1);
96     sleep(1);
97
98     smgr->unbind();
99     sleep(2);
100     delete smgr;
101 }