-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRun3Sound.h
57 lines (41 loc) · 943 Bytes
/
Run3Sound.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
Sound in Ogre3d head by sgw32
*/
#define TEST_FILE "2.wav"
#include"Framework.h"
class Run3SoundManager
{
virtual void PlaySoundStatic(void)
{
ALuint uiBuffer;
ALuint uiSource;
ALint iState;
// Initialize Framework
ALFWInit();
if (!ALFWInitOpenAL())
{
ALFWShutdown();
}
// Generate an AL Buffer
alGenBuffers( 1, &uiBuffer );
ALFWLoadWaveToBuffer((char*)TEST_FILE, uiBuffer);
// Load Wave file into OpenAL Buffer
// Generate a Source to playback the Buffer
alGenSources( 1, &uiSource );
// Attach Source to Buffer
alSourcei( uiSource, AL_BUFFER, uiBuffer );
// Play Source
alSourcePlay( uiSource );
do
{
Sleep(100);
// Get Source State
alGetSourcei( uiSource, AL_SOURCE_STATE, &iState);
} while (iState == AL_PLAYING);
alSourceStop(uiSource);
alDeleteSources(1, &uiSource);
alDeleteBuffers(1, &uiBuffer);
ALFWShutdownOpenAL();
ALFWShutdown();
}
};