]> git.mxchange.org Git - simgear.git/blob - simgear/sound/openal_test2.cxx
Remove OpenVG dependency from header file
[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 #include "sample_group.hxx"
14 #include "sample_openal.hxx"
15
16
17 int main( int argc, char *argv[] ) {
18     SGSampleGroup *sgr;
19     SGSoundMgr *smgr;
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     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 sample1\n");
38     sleep(1);
39
40     SGSoundSample *sample2 = new SGSoundSample("jet.wav", srcDir);
41     sample2->set_volume(0.5);
42     sample2->set_pitch(0.4);
43     sample2->play_looped();
44     sgr->add(sample2, "sound2");
45     smgr->update(1.0);
46     printf("playing sample2\n");
47     sleep(1);
48
49     SGSoundSample *sample3 = new SGSoundSample("jet.wav", srcDir);
50     sample3->set_volume(0.5);
51     sample3->set_pitch(0.8);
52     sample3->play_looped();
53     sgr->add(sample3, "sound3");
54     smgr->update(1.0);
55     printf("playing sample3\n");
56     sleep(1);
57
58     SGSoundSample *sample4 = new SGSoundSample("jet.wav", srcDir);
59     sample4->set_volume(0.5);
60     sample4->set_pitch(1.2);
61     sample4->play_looped();
62     sgr->add(sample4, "sound4");
63     smgr->update(1.0);
64     printf("playing sample4\n");
65     sleep(1);
66
67     SGSoundSample *sample5 = new SGSoundSample("jet.wav", srcDir);
68     sample5->set_volume(0.5);
69     sample5->set_pitch(1.6);
70     sample5->play_looped();
71     sgr->add(sample5, "sound5");
72     smgr->update(1.0);
73     printf("playing sample5\n");
74     sleep(1);
75
76     SGSoundSample *sample6 = new SGSoundSample("jet.wav", srcDir);
77     sample6->set_volume(0.5);
78     sample6->set_pitch(2.0);
79     sample6->play_looped();
80     sgr->add(sample6, "sound6");
81     smgr->update(1.0);
82     printf("playing sample6\n");
83     sleep(1);
84
85     for (int i=0; i<10; i++) {
86         sleep(1);
87         smgr->update(1);
88     }
89
90     sgr->stop("sound1");
91     sgr->stop("sound2");
92     sgr->stop("sound3");
93     sleep(0.5);
94     smgr->update(0.5);
95     sgr->stop("sound4");
96     sgr->stop("sound5");
97     sgr->stop("sound6");
98     smgr->update(1);
99     sleep(1);
100
101     smgr->unbind();
102     sleep(2);
103     delete smgr;
104 }