|
@@ -1,6 +1,6 @@
|
1
|
1
|
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
|
2
|
2
|
/*================================================================
|
3
|
|
- *
|
|
3
|
+ *
|
4
|
4
|
* Project : OpenRaider
|
5
|
5
|
* Author : Mongoose
|
6
|
6
|
* Website : http://www.westga.edu/~stu7440/
|
|
@@ -10,14 +10,14 @@
|
10
|
10
|
* Comments: This is the audio manager for OpenRaider
|
11
|
11
|
*
|
12
|
12
|
*
|
13
|
|
- * This file was generated using Mongoose's C++
|
|
13
|
+ * This file was generated using Mongoose's C++
|
14
|
14
|
* template generator script. <stu7440@westga.edu>
|
15
|
15
|
*
|
16
|
16
|
*-- Test Defines -----------------------------------------------
|
17
|
|
- *
|
18
|
|
- * UNIT_TEST_SOUND - Builds Sound class as a console unit test
|
19
|
17
|
*
|
20
|
|
- *-- History ----------------------------------------------------
|
|
18
|
+ * UNIT_TEST_SOUND - Builds Sound class as a console unit test
|
|
19
|
+ *
|
|
20
|
+ *-- History ----------------------------------------------------
|
21
|
21
|
*
|
22
|
22
|
* 2002.09.13:
|
23
|
23
|
* Mongoose - API follows new code style guidelines
|
|
@@ -32,150 +32,80 @@
|
32
|
32
|
#ifndef __OPENRAIDER_MONGOOSE_SOUND_H_
|
33
|
33
|
#define __OPENRAIDER_MONGOOSE_SOUND_H_
|
34
|
34
|
|
35
|
|
-typedef enum
|
36
|
|
-{
|
37
|
|
- SoundFlagsNone = 0, /* No FX */
|
38
|
|
- SoundFlagsLoop = 1 /* Enable looping during playback */
|
39
|
|
-
|
40
|
|
-} SoundFlags;
|
41
|
|
-
|
42
|
|
-
|
43
|
|
-class Sound
|
44
|
|
-{
|
45
|
|
- public:
|
46
|
|
-
|
47
|
|
- Sound();
|
48
|
|
- /*------------------------------------------------------
|
49
|
|
- * Pre :
|
50
|
|
- * Post : Constructs an object of Sound
|
51
|
|
- *
|
52
|
|
- *-- History ------------------------------------------
|
53
|
|
- *
|
54
|
|
- * 2001.05.23:
|
55
|
|
- * Mongoose - Created
|
56
|
|
- ------------------------------------------------------*/
|
57
|
|
-
|
58
|
|
- ~Sound();
|
59
|
|
- /*------------------------------------------------------
|
60
|
|
- * Pre : Sound object is allocated
|
61
|
|
- * Post : Deconstructs an object of Sound
|
62
|
|
- *
|
63
|
|
- *-- History ------------------------------------------
|
64
|
|
- *
|
65
|
|
- * 2001.05.23:
|
66
|
|
- * Mongoose - Created
|
67
|
|
- ------------------------------------------------------*/
|
68
|
|
-
|
69
|
|
- int init();
|
70
|
|
- /*------------------------------------------------------
|
71
|
|
- * Pre :
|
72
|
|
- * Post : Initializes sound system
|
73
|
|
- *
|
74
|
|
- * No error returns 0 all others returns < 0
|
75
|
|
- * error flags
|
76
|
|
- *
|
77
|
|
- *-- History ------------------------------------------
|
78
|
|
- *
|
79
|
|
- * 2001.05.23:
|
80
|
|
- * Mongoose - Created
|
81
|
|
- ------------------------------------------------------*/
|
82
|
|
-
|
83
|
|
- void listenAt(float pos[3], float angle[3]);
|
84
|
|
- /*------------------------------------------------------
|
85
|
|
- * Pre : pos and angles are valid for listener
|
86
|
|
- * Post : Moves listener and repositions them
|
87
|
|
- *
|
88
|
|
- *-- History ------------------------------------------
|
89
|
|
- *
|
90
|
|
- * 2001.05.23:
|
91
|
|
- * Mongoose - Created
|
92
|
|
- ------------------------------------------------------*/
|
93
|
|
-
|
94
|
|
- void sourceAt(int source, float pos[3]);
|
95
|
|
- /*------------------------------------------------------
|
96
|
|
- * Pre : source and pos are valid for source
|
97
|
|
- * Post : Moves sound source to position
|
98
|
|
- *
|
99
|
|
- *-- History ------------------------------------------
|
100
|
|
- *
|
101
|
|
- * 2001.05.23:
|
102
|
|
- * Mongoose - Created
|
103
|
|
- ------------------------------------------------------*/
|
104
|
|
-
|
105
|
|
- int add(char *filename, int *source, unsigned int flags);
|
106
|
|
- /*------------------------------------------------------
|
107
|
|
- * Pre : filename and source aren't NULL
|
108
|
|
- * flags (un)set options
|
109
|
|
- *
|
110
|
|
- * Post : Loads wav file from disk
|
111
|
|
- *
|
112
|
|
- * Source returns it's sound source id,
|
113
|
|
- * source id is set -1 for error
|
114
|
|
- *
|
115
|
|
- * Returns either 0 for no error or < 0 error
|
116
|
|
- * flag
|
117
|
|
- *
|
118
|
|
- *-- History ------------------------------------------
|
119
|
|
- *
|
120
|
|
- * 2001.05.23:
|
121
|
|
- * Mongoose - Created
|
122
|
|
- ------------------------------------------------------*/
|
123
|
|
-
|
124
|
|
- // FIXME: Not implemented yet
|
125
|
|
- int add(unsigned char *wav, int *source, unsigned int flags);
|
126
|
|
- /*------------------------------------------------------
|
127
|
|
- * Pre : wav and source aren't NULL
|
128
|
|
- * wav is a valid waveform buffer
|
129
|
|
- *
|
130
|
|
- * flags (un)set options
|
131
|
|
- *
|
132
|
|
- * Post : Loads wav file from buffer
|
133
|
|
- *
|
134
|
|
- * Source returns it's sound source id,
|
135
|
|
- * source id is set -1 for error
|
136
|
|
- *
|
137
|
|
- * Returns either 0 for no error or < 0 error
|
138
|
|
- * flag
|
139
|
|
- *
|
140
|
|
- *-- History ------------------------------------------
|
141
|
|
- *
|
142
|
|
- * 2001.05.23:
|
143
|
|
- * Mongoose - Created
|
144
|
|
- ------------------------------------------------------*/
|
145
|
|
-
|
146
|
|
- void play(int source);
|
147
|
|
- /*------------------------------------------------------
|
148
|
|
- * Pre :
|
149
|
|
- * Post : Play sound source
|
150
|
|
- *
|
151
|
|
- *-- History ------------------------------------------
|
152
|
|
- *
|
153
|
|
- * 2001.05.23:
|
154
|
|
- * Mongoose - Created
|
155
|
|
- ------------------------------------------------------*/
|
156
|
|
-
|
157
|
|
- void stop(int source);
|
158
|
|
- /*------------------------------------------------------
|
159
|
|
- * Pre :
|
160
|
|
- * Post : Stop playing sound source
|
161
|
|
- *
|
162
|
|
- *-- History ------------------------------------------
|
163
|
|
- *
|
164
|
|
- * 2001.05.23:
|
165
|
|
- * Mongoose - Created
|
166
|
|
- ------------------------------------------------------*/
|
167
|
|
-
|
168
|
|
- private:
|
169
|
|
-
|
170
|
|
- bool mInit; /* Guard to ensure ausio system is active */
|
171
|
|
-
|
172
|
|
- unsigned int mBuffer[256]; /* Audio buffer id list */
|
173
|
|
-
|
174
|
|
- unsigned int mSource[256]; /* Audio source id list */
|
175
|
|
-
|
176
|
|
- unsigned int mNextBuffer; /* Audio buffer id cursor */
|
177
|
|
-
|
178
|
|
- unsigned int mNextSource; /* Audio source id cursor */
|
|
35
|
+class Sound {
|
|
36
|
+public:
|
|
37
|
+
|
|
38
|
+ typedef enum {
|
|
39
|
+ SoundFlagsNone = 0, //!< No FX
|
|
40
|
+ SoundFlagsLoop = 1 //!< Enable looping during playback
|
|
41
|
+ } SoundFlags;
|
|
42
|
+
|
|
43
|
+ /*!
|
|
44
|
+ * \brief Constructs an object of Sound
|
|
45
|
+ */
|
|
46
|
+ Sound();
|
|
47
|
+
|
|
48
|
+ /*!
|
|
49
|
+ * \brief Deconstructs an object of Sound
|
|
50
|
+ */
|
|
51
|
+ ~Sound();
|
|
52
|
+
|
|
53
|
+ /*!
|
|
54
|
+ * \brief Initialize sound system
|
|
55
|
+ * \returns 0 on success or < 0 error flags
|
|
56
|
+ */
|
|
57
|
+ int init();
|
|
58
|
+
|
|
59
|
+ /*!
|
|
60
|
+ * \brief Move listener and repositions them
|
|
61
|
+ * \param pos New position for listener
|
|
62
|
+ * \param angle New orientation for listener
|
|
63
|
+ */
|
|
64
|
+ void listenAt(float pos[3], float angle[3]);
|
|
65
|
+
|
|
66
|
+ /*!
|
|
67
|
+ * \brief Move sound source to position
|
|
68
|
+ * \param source valid source id
|
|
69
|
+ * \param pos new position for source
|
|
70
|
+ */
|
|
71
|
+ void sourceAt(int source, float pos[3]);
|
|
72
|
+
|
|
73
|
+ /*!
|
|
74
|
+ * \brief Load wav file from disk
|
|
75
|
+ * \param filename not NULL!
|
|
76
|
+ * \param source not NULL! Returns new source ID or -1 on error.
|
|
77
|
+ * \param flags (un)set options. Use SoundFlags enum
|
|
78
|
+ * \returns 0 for no error or < 0 error flag
|
|
79
|
+ */
|
|
80
|
+ int addFile(char *filename, int *source, unsigned int flags);
|
|
81
|
+
|
|
82
|
+ /*!
|
|
83
|
+ * \brief Load wav file from buffer
|
|
84
|
+ * \param wav not NULL! Is a valid waveform buffer!
|
|
85
|
+ * \param source not NULL! Returns new source ID or -1 on error.
|
|
86
|
+ * \param flags (un)set options. Use SoundFlags enum
|
|
87
|
+ * \returns 0 for no error or < 0 error flag
|
|
88
|
+ */
|
|
89
|
+ int addWave(unsigned char *wav, int *source, unsigned int flags);
|
|
90
|
+
|
|
91
|
+ /*!
|
|
92
|
+ * \brief Play sound source
|
|
93
|
+ * \param source sound source to play
|
|
94
|
+ */
|
|
95
|
+ void play(int source);
|
|
96
|
+
|
|
97
|
+ /*!
|
|
98
|
+ * \brief Stop playing sound source
|
|
99
|
+ * \param source sound source to stop
|
|
100
|
+ */
|
|
101
|
+ void stop(int source);
|
|
102
|
+
|
|
103
|
+private:
|
|
104
|
+ bool mInit; //!< Guard to ensure ausio system is active
|
|
105
|
+ unsigned int mBuffer[256]; //!< Audio buffer id list
|
|
106
|
+ unsigned int mSource[256]; //!< Audio source id list
|
|
107
|
+ unsigned int mNextBuffer; //!< Audio buffer id cursor
|
|
108
|
+ unsigned int mNextSource; //!< Audio source id cursor
|
179
|
109
|
};
|
180
|
110
|
|
181
|
111
|
#endif
|