Debian Codegraph @

src/include/audio.h

raw
1
2 // audio.h [pengine]
3
4 // Copyright 2004-2006 Jasmine Langridge, [email protected]
5 // License: GPL version 2 (see included gpl.txt)
6
7
8 // Ubuntu patch "15_fixup_physfs_alut_interaction.patch" includes
9 // the OpenAL header so that ALuint can be used for PAudioSample::buffer.
10 // I don't like exposing OpenAL to the rest of the engine, so I'm
11 // omitting it, but if you find it causes build problems, you may
12 // want to re-enable it below. - jaz 20/10/2006
13
14 #if defined( USE_OPENAL )
15 #define INCLUDE_OPENAL_HEADER
16 #endif
17
18 #if defined( INCLUDE_OPENAL_HEADER )
19 #include <AL/al.h>
20 #endif
21
22 // TODO: move audio subsystem choosing from audio.cpp to here
23 #ifdef WIN32
24 #define INCLUDE_FMOD_HEADER
25 #include <fmod.h>
26 #endif
27
28 class PSSAudio : public PSubsystem {
29 private:
30 PResourceList<PAudioSample> samplist;
31
32 public:
33 PSSAudio(PApp &parentApp);
34 ~PSSAudio();
35 void tick();
36 PAudioSample *loadSample(const std::string &name, bool positional3D = true);
37 };
38
39 class PAudioSample : public PResource {
40 private:
41 #if defined (INCLUDE_OPENAL_HEADER)
42 ALuint buffer;
43 #elif defined (INCLUDE_FMOD_HEADER)
44 FMOD_SOUND *buffer;
45 #endif
46
47 public:
48 PAudioSample(const std::string &filename, bool positional3D = false);
49
50 ~PAudioSample()
51 {
52 unload();
53 }
54
55 void unload();
56
57 friend class PAudioInstance;
58 };
59
60 class PAudioInstance {
61 private:
62 PAudioSample *samp;
63 #if defined (INCLUDE_FMOD_HEADER)
64 FMOD_CHANNEL *source;
65 float reserved1;
66 #else
67 unsigned int source;
68 #endif
69
70 public:
71 PAudioInstance(PAudioSample *_samp, bool looping = false);
72 ~PAudioInstance();
73
74 void update(const vec3f &pos, const vec3f &vel);
75 void setGain(float gain); // 0-1
76 void setHalfDistance(float lambda);
77 void setPitch(float pitch); // 1 is normal
78
79 void play();
80 void stop();
81 bool isPlaying();
82 };
83
84
85 #ifdef INCLUDE_OPENAL_HEADER
86 #undef INCLUDE_OPENAL_HEADER
87 #endif
88