1 | #include <iostream> |
---|
2 | #include "Ambient.h" |
---|
3 | |
---|
4 | namespace audio |
---|
5 | { |
---|
6 | Ambient::Ambient() |
---|
7 | { |
---|
8 | SourcePos[0]=0; |
---|
9 | SourcePos[1]=0; |
---|
10 | SourcePos[2]=0; |
---|
11 | |
---|
12 | SourceVel[0]=0; |
---|
13 | SourceVel[1]=0; |
---|
14 | SourceVel[2]=0; |
---|
15 | |
---|
16 | ListenerPos[0]=0; |
---|
17 | ListenerPos[1]=0; |
---|
18 | ListenerPos[2]=0; |
---|
19 | |
---|
20 | ListenerVel[0]=0; |
---|
21 | ListenerVel[1]=0; |
---|
22 | ListenerVel[2]=0; |
---|
23 | |
---|
24 | ListenerOri[0]=0; |
---|
25 | ListenerOri[1]=0; |
---|
26 | ListenerOri[2]=-1; |
---|
27 | ListenerOri[3]=0; |
---|
28 | ListenerOri[4]=1; |
---|
29 | ListenerOri[5]=0; |
---|
30 | |
---|
31 | std::cout << "Play sone ambient background sound"; |
---|
32 | } |
---|
33 | |
---|
34 | ALboolean Ambient::LoadALData() |
---|
35 | { |
---|
36 | ALenum format; |
---|
37 | ALsizei size; |
---|
38 | ALvoid* data; |
---|
39 | ALsizei freq; |
---|
40 | ALboolean loop; |
---|
41 | |
---|
42 | alGenBuffers(1, &Buffer); |
---|
43 | |
---|
44 | if(alGetError() != AL_NO_ERROR) |
---|
45 | return AL_FALSE; |
---|
46 | |
---|
47 | alutLoadWAVFile((ALbyte*)"wavdata/pirate.wav", &format, &data, &size, &freq, &loop); |
---|
48 | alBufferData(Buffer, format, data, size, freq); |
---|
49 | alutUnloadWAV(format, data, size, freq); |
---|
50 | |
---|
51 | alGenSources(1, &Source); |
---|
52 | |
---|
53 | if(alGetError() != AL_NO_ERROR) |
---|
54 | return AL_FALSE; |
---|
55 | |
---|
56 | alSourcei (Source, AL_BUFFER, Buffer ); |
---|
57 | alSourcef (Source, AL_PITCH, 1.0 ); |
---|
58 | alSourcef (Source, AL_GAIN, 1.0 ); |
---|
59 | alSourcefv(Source, AL_POSITION, SourcePos); |
---|
60 | alSourcefv(Source, AL_VELOCITY, SourceVel); |
---|
61 | alSourcei (Source, AL_LOOPING, loop ); |
---|
62 | |
---|
63 | if(alGetError() == AL_NO_ERROR) |
---|
64 | return AL_TRUE; |
---|
65 | |
---|
66 | return AL_FALSE; |
---|
67 | } |
---|
68 | |
---|
69 | |
---|
70 | } |
---|
71 | |
---|