浏览代码

Now finished documenting Sound

Thomas Buck 11 年前
父节点
当前提交
71b4bcab4f
共有 2 个文件被更改,包括 36 次插入56 次删除
  1. 24
    28
      src/Sound.cpp
  2. 12
    28
      src/Sound.h

+ 24
- 28
src/Sound.cpp 查看文件

1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file Sound.cpp
3
+ * \brief This is the audio manager Implementation
3
  *
4
  *
4
- * Project : OpenRaider
5
- * Author  : Mongoose
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : Sound
9
- * License : No use w/o permission (C) 2001 Mongoose
10
- * Comments: This is the audio manager for OpenRaider
5
+ * Defining UNIT_TEST_SOUND builds Sound class as a console unit test
11
  *
6
  *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- History -------------------------------------------------
17
- *
18
- * 2001.05.23:
19
- * Mongoose - Created
20
- =================================================================*/
7
+ * \author Mongoose
8
+ * \author xythobuz
9
+ */
21
 
10
 
22
 #ifdef HAVE_OPENAL
11
 #ifdef HAVE_OPENAL
23
 #ifdef __APPLE__
12
 #ifdef __APPLE__
25
 #include <OpenAL/alc.h>
14
 #include <OpenAL/alc.h>
26
 #include <AL/alut.h>
15
 #include <AL/alut.h>
27
 #else
16
 #else
28
-#   include <AL/al.h>
29
-#   include <AL/alc.h>
30
-#   include <AL/alut.h>
31
-#   include <AL/alext.h>
17
+#include <AL/al.h>
18
+#include <AL/alc.h>
19
+#include <AL/alut.h>
20
+#include <AL/alext.h>
32
 #endif
21
 #endif
33
 #endif
22
 #endif
34
 
23
 
43
 #include "Sound.h"
32
 #include "Sound.h"
44
 
33
 
45
 #ifdef DEBUG_MEMEORY
34
 #ifdef DEBUG_MEMEORY
46
-#   include "memeory_test.h"
35
+#include "memeory_test.h"
47
 #endif
36
 #endif
48
 
37
 
49
 
38
 
191
 #endif
180
 #endif
192
 }
181
 }
193
 
182
 
194
-
183
+/*!
184
+ * \todo Reimplement, not using deprecated FORMAT specifier
185
+ */
195
 int Sound::addWave(unsigned char *wav, int *source, unsigned int flags)
186
 int Sound::addWave(unsigned char *wav, int *source, unsigned int flags)
196
 {
187
 {
197
 #ifdef HAVE_OPENAL
188
 #ifdef HAVE_OPENAL
230
 		return -2;
221
 		return -2;
231
 	}
222
 	}
232
 
223
 
233
-// This method isn't used yet...
234
-//#warning "AL_FORMAT_WAVE_EXT does not exist on Mac!"
224
+#warning "AL_FORMAT_WAVE_EXT does not exist on Mac!"
235
    // alBufferData(mBuffer[mNextBuffer], AL_FORMAT_WAVE_EXT, data, size, freq);
225
    // alBufferData(mBuffer[mNextBuffer], AL_FORMAT_WAVE_EXT, data, size, freq);
236
    alBufferData(mBuffer[mNextBuffer], 0x10002, data, size, freq);
226
    alBufferData(mBuffer[mNextBuffer], 0x10002, data, size, freq);
237
 
227
 
292
 
282
 
293
 
283
 
294
 #ifdef UNIT_TEST_SOUND
284
 #ifdef UNIT_TEST_SOUND
285
+/*!
286
+ * \brief Sound Unit Test
287
+ * \param argc Number of arguments. Has to be > 1
288
+ * \param argv Argument array. argv[1] will be played as wav file
289
+ * \returns always zero
290
+ */
295
 int main(int argc, char* argv[])
291
 int main(int argc, char* argv[])
296
 {
292
 {
297
 	Sound snd;
293
 	Sound snd;
305
 	{
301
 	{
306
 		snd.init();
302
 		snd.init();
307
 		printf("Loading %s\n", argv[1]);
303
 		printf("Loading %s\n", argv[1]);
308
-		ret = snd.add(argv[1], &id, SoundFlagsNone);
304
+		ret = snd.addFile(argv[1], &id, SoundFlagsNone);
309
 		printf("Load returned %i\n", ret);
305
 		printf("Load returned %i\n", ret);
310
 		printf("Playing %u::%s\n", id, argv[1]);
306
 		printf("Playing %u::%s\n", id, argv[1]);
311
 		snd.play(id);
307
 		snd.play(id);
327
 			fclose(f);
323
 			fclose(f);
328
 
324
 
329
 			printf("Loading buffer of %s\n", argv[1]);
325
 			printf("Loading buffer of %s\n", argv[1]);
330
-			ret = snd.add(buf, &id, SoundFlagsNone);
326
+			ret = snd.addFile(buf, &id, SoundFlagsNone);
331
 			printf("Load returned %i\n", ret);
327
 			printf("Load returned %i\n", ret);
332
 			printf("Playing buffer of %u::%s\n", id, argv[1]);
328
 			printf("Playing buffer of %u::%s\n", id, argv[1]);
333
 			snd.play(id);
329
 			snd.play(id);

+ 12
- 28
src/Sound.h 查看文件

1
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
-/*================================================================
1
+/*!
2
+ * \file Sound.h
3
+ * \brief This is the audio manager Header
3
  *
4
  *
4
- * Project : OpenRaider
5
- * Author  : Mongoose
6
- * Website : http://www.westga.edu/~stu7440/
7
- * Email   : stu7440@westga.edu
8
- * Object  : Sound
9
- * License : No use w/o permission (C) 2001 Mongoose
10
- * Comments: This is the audio manager for OpenRaider
5
+ * Defining UNIT_TEST_SOUND builds Sound class as a console unit test
11
  *
6
  *
12
- *
13
- *           This file was generated using Mongoose's C++
14
- *           template generator script.  <stu7440@westga.edu>
15
- *
16
- *-- Test Defines -----------------------------------------------
17
- *
18
- * UNIT_TEST_SOUND - Builds Sound class as a console unit test
19
- *
20
- *-- History ----------------------------------------------------
21
- *
22
- * 2002.09.13:
23
- * Mongoose - API follows new code style guidelines
24
- *
25
- * 2002.01.03:
26
- * Mongoose - Flags use added
27
- *
28
- * 2001.05.23:
29
- * Mongoose - Created
30
- ================================================================*/
7
+ * \author Mongoose
8
+ * \author xythobuz
9
+ */
31
 
10
 
32
 #ifndef __OPENRAIDER_MONGOOSE_SOUND_H_
11
 #ifndef __OPENRAIDER_MONGOOSE_SOUND_H_
33
 #define __OPENRAIDER_MONGOOSE_SOUND_H_
12
 #define __OPENRAIDER_MONGOOSE_SOUND_H_
34
 
13
 
14
+/*!
15
+ * \brief This is the audio manager for OpenRaider
16
+ */
35
 class Sound {
17
 class Sound {
36
 public:
18
 public:
37
 
19
 
85
      * \param source not NULL! Returns new source ID or -1 on error.
67
      * \param source not NULL! Returns new source ID or -1 on error.
86
      * \param flags (un)set options. Use SoundFlags enum
68
      * \param flags (un)set options. Use SoundFlags enum
87
      * \returns 0 for no error or < 0 error flag
69
      * \returns 0 for no error or < 0 error flag
70
+     *
71
+     * \todo not yet implemented!
88
      */
72
      */
89
     int addWave(unsigned char *wav, int *source, unsigned int flags);
73
     int addWave(unsigned char *wav, int *source, unsigned int flags);
90
 
74
 

正在加载...
取消
保存