]> git.mxchange.org Git - simgear.git/blob - simgear/sound/openal_test2.cxx
Optionally use HTTP repository.
[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 #include <simgear/timing/timestamp.hxx>
12
13 #include "soundmgr_openal.hxx"
14 #include "sample_group.hxx"
15 #include "sample_openal.hxx"
16
17
18 int main( int argc, char *argv[] ) {
19     SGSampleGroup *sgr;
20     SGSoundMgr *smgr;
21
22     smgr = new SGSoundMgr;
23
24     smgr->bind();
25     smgr->init();
26     sgr = smgr->find("default", true);
27     smgr->set_volume(0.9);
28     smgr->activate();
29
30     SGPath srcDir(SRC_DIR);
31
32     SGSoundSample *sample1 = new SGSoundSample("jet.wav", srcDir);
33     sample1->set_volume(1.0);
34     sample1->set_pitch(1.0);
35     sample1->play_looped();
36     sgr->add(sample1, "sound1");
37     smgr->update(1.0);
38     printf("playing sample1\n");
39     sleep(1);
40
41     SGSoundSample *sample2 = new SGSoundSample("jet.wav", srcDir);
42     sample2->set_volume(0.5);
43     sample2->set_pitch(0.4);
44     sample2->play_looped();
45     sgr->add(sample2, "sound2");
46     smgr->update(1.0);
47     printf("playing sample2\n");
48     sleep(1);
49
50     SGSoundSample *sample3 = new SGSoundSample("jet.wav", srcDir);
51     sample3->set_volume(0.5);
52     sample3->set_pitch(0.8);
53     sample3->play_looped();
54     sgr->add(sample3, "sound3");
55     smgr->update(1.0);
56     printf("playing sample3\n");
57     sleep(1);
58
59     SGSoundSample *sample4 = new SGSoundSample("jet.wav", srcDir);
60     sample4->set_volume(0.5);
61     sample4->set_pitch(1.2);
62     sample4->play_looped();
63     sgr->add(sample4, "sound4");
64     smgr->update(1.0);
65     printf("playing sample4\n");
66     sleep(1);
67
68     SGSoundSample *sample5 = new SGSoundSample("jet.wav", srcDir);
69     sample5->set_volume(0.5);
70     sample5->set_pitch(1.6);
71     sample5->play_looped();
72     sgr->add(sample5, "sound5");
73     smgr->update(1.0);
74     printf("playing sample5\n");
75     sleep(1);
76
77     SGSoundSample *sample6 = new SGSoundSample("jet.wav", srcDir);
78     sample6->set_volume(0.5);
79     sample6->set_pitch(2.0);
80     sample6->play_looped();
81     sgr->add(sample6, "sound6");
82     smgr->update(1.0);
83     printf("playing sample6\n");
84     sleep(1);
85
86     for (int i=0; i<10; i++) {
87         sleep(1);
88         smgr->update(1);
89     }
90
91     sgr->stop("sound1");
92     sgr->stop("sound2");
93     sgr->stop("sound3");
94     SGTimeStamp::sleepForMSec(500);
95     smgr->update(0.5);
96     sgr->stop("sound4");
97     sgr->stop("sound5");
98     sgr->stop("sound6");
99     smgr->update(1);
100     sleep(1);
101
102     smgr->unbind();
103     sleep(2);
104     delete smgr;
105 }