|
@@ -110,7 +110,7 @@ void Sound::sourceAt(int source, float pos[3])
|
110
|
110
|
}
|
111
|
111
|
|
112
|
112
|
|
113
|
|
-// Mongoose 2002.01.04, FIXME seperate sourcing and buffering
|
|
113
|
+//! \fixme Seperate sourcing and buffering, Mongoose 2002.01.04
|
114
|
114
|
int Sound::addFile(char *filename, int *source, unsigned int flags)
|
115
|
115
|
{
|
116
|
116
|
#ifdef HAVE_OPENAL
|
|
@@ -180,13 +180,12 @@ int Sound::addFile(char *filename, int *source, unsigned int flags)
|
180
|
180
|
#endif
|
181
|
181
|
}
|
182
|
182
|
|
183
|
|
-/*!
|
184
|
|
- * \todo Reimplement, not using deprecated FORMAT specifier
|
185
|
|
- */
|
186
|
|
-int Sound::addWave(unsigned char *wav, int *source, unsigned int flags)
|
|
183
|
+int Sound::addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags)
|
187
|
184
|
{
|
188
|
185
|
#ifdef HAVE_OPENAL
|
189
|
|
- ALsizei size = 0, freq = 0;
|
|
186
|
+ ALsizei size;
|
|
187
|
+ ALfloat freq;
|
|
188
|
+ ALenum format;
|
190
|
189
|
ALvoid *data;
|
191
|
190
|
#endif
|
192
|
191
|
|
|
@@ -221,9 +220,21 @@ int Sound::addWave(unsigned char *wav, int *source, unsigned int flags)
|
221
|
220
|
return -2;
|
222
|
221
|
}
|
223
|
222
|
|
224
|
|
-#warning "AL_FORMAT_WAVE_EXT does not exist on Mac!"
|
225
|
|
- // alBufferData(mBuffer[mNextBuffer], AL_FORMAT_WAVE_EXT, data, size, freq);
|
226
|
|
- alBufferData(mBuffer[mNextBuffer], 0x10002, data, size, freq);
|
|
223
|
+ //AL_FORMAT_WAVE_EXT does not exist on Mac!"
|
|
224
|
+ // alBufferData(mBuffer[mNextBuffer], AL_FORMAT_WAVE_EXT, data, size, freq);
|
|
225
|
+ // Idea: Fill Buffer with
|
|
226
|
+ // alutLoadMemoryFromFileImage
|
|
227
|
+ // (const ALvoid *data, ALsizei length, ALenum *format, ALsizei *size, ALfloat *frequency)
|
|
228
|
+
|
|
229
|
+ data = alutLoadMemoryFromFileImage(wav, length, &format, &size, &freq);
|
|
230
|
+
|
|
231
|
+ if ((alGetError() != AL_NO_ERROR) || (data == NULL)) {
|
|
232
|
+ fprintf(stderr, "Could not load wav buffer\n");
|
|
233
|
+ return -3;
|
|
234
|
+ }
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+ alBufferData(mBuffer[mNextBuffer], format, data, size, freq);
|
227
|
238
|
|
228
|
239
|
alSourcei(mSource[mNextSource], AL_BUFFER, mBuffer[mNextBuffer]);
|
229
|
240
|
|
|
@@ -323,7 +334,7 @@ int main(int argc, char* argv[])
|
323
|
334
|
fclose(f);
|
324
|
335
|
|
325
|
336
|
printf("Loading buffer of %s\n", argv[1]);
|
326
|
|
- ret = snd.addWave(buf, &id, snd.SoundFlagsNone);
|
|
337
|
+ ret = snd.addWave(buf, l, &id, snd.SoundFlagsNone);
|
327
|
338
|
printf("Load returned %i\n", ret);
|
328
|
339
|
printf("Playing buffer of %u::%s\n", id, argv[1]);
|
329
|
340
|
snd.play(id);
|