]> git.mxchange.org Git - simgear.git/blob - simgear/sound/openal_test2.cxx
46a0f621ad640392e0158e9d3ded4d6110d84fd6
[simgear.git] / simgear / sound / openal_test2.cxx
1 #include <stdio.h>
2 #ifdef __MINGW32__
3 // This is broken, but allows the file to compile without a POSIX
4 // environment.
5 static unsigned int sleep(unsigned int secs) { return 0; }
6 #else
7 #include <unistd.h>     // sleep()
8 #endif
9
10 #include <simgear/debug/logstream.hxx>
11 #include <simgear/misc/sg_path.hxx>
12
13 #include "soundmgr_openal.hxx"
14
15
16 int main( int argc, char *argv[] ) {
17     SGSampleGroup *sgr;
18     SGSoundMgr *smgr;
19
20     smgr = new SGSoundMgr;
21
22     smgr->bind();
23     smgr->init();
24     smgr->set_volume(0.9);
25     sgr = smgr->find("default", true);
26
27     SGSoundSample *sample1 = new SGSoundSample( SRC_DIR, "jet.wav" );
28     sample1->set_volume(1.0);
29     sample1->set_pitch(1.0);
30     sample1->play_looped();
31     sgr->add(sample1, "sound1");
32     smgr->update(1.0);
33     printf("playing sample1\n");
34     sleep(1);
35
36     SGSoundSample *sample2 = new SGSoundSample( SRC_DIR, "jet.wav" );
37     sample2->set_volume(0.5);
38     sample2->set_pitch(0.4);
39     sample2->play_looped();
40     sgr->add(sample2, "sound2");
41     smgr->update(1.0);
42     printf("playing sample2\n");
43     sleep(1);
44
45     SGSoundSample *sample3 = new SGSoundSample( SRC_DIR, "jet.wav" );
46     sample3->set_volume(0.5);
47     sample3->set_pitch(0.8);
48     sample3->play_looped();
49     sgr->add(sample3, "sound3");
50     smgr->update(1.0);
51     printf("playing sample3\n");
52     sleep(1);
53
54     SGSoundSample *sample4 = new SGSoundSample( SRC_DIR, "jet.wav" );
55     sample4->set_volume(0.5);
56     sample4->set_pitch(1.2);
57     sample4->play_looped();
58     sgr->add(sample4, "sound4");
59     smgr->update(1.0);
60     printf("playing sample4\n");
61     sleep(1);
62
63     SGSoundSample *sample5 = new SGSoundSample( SRC_DIR, "jet.wav" );
64     sample5->set_volume(0.5);
65     sample5->set_pitch(1.6);
66     sample5->play_looped();
67     sgr->add(sample5, "sound5");
68     smgr->update(1.0);
69     printf("playing sample5\n");
70     sleep(1);
71
72     SGSoundSample *sample6 = new SGSoundSample( SRC_DIR, "jet.wav" );
73     sample6->set_volume(0.5);
74     sample6->set_pitch(2.0);
75     sample6->play_looped();
76     sgr->add(sample6, "sound6");
77     smgr->update(1.0);
78     printf("playing sample6\n");
79     sleep(1);
80
81     for (int i=0; i<10; i++) {
82         sleep(1);
83         smgr->update(1);
84     }
85
86     sgr->stop("sound1");
87     sgr->stop("sound2");
88     sgr->stop("sound3");
89     sleep(0.5);
90     sgr->update(0.5);
91     sgr->stop("sound4");
92     sgr->stop("sound5");
93     sgr->stop("sound6");
94     sgr->update(1);
95     sleep(1);
96
97     smgr->unbind();
98     sleep(2);
99     delete smgr;
100 }