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