Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/sound_engine/src/lib/sound/sound_engine.h @ 3890

Last change on this file since 3890 was 3890, checked in by bensch, 19 years ago

orxonox/branches/sound_engine: loading unloading should work

File size: 2.1 KB
Line 
1/*!
2    \file sound_engine.h
3    \brief Definition of the SoundEngine
4
5    !!AVOID!!:
6    SDL_OpenAudio
7     Use Mix_OpenAudio instead.
8    SDL_CloseAudio
9     Use Mix_CloseAudio instead.
10    SDL_PauseAudio
11     Use Mix_Pause(-1) and Mix_PauseMusic instead, to pause.
12     Use Mix_Resume(-1) and Mix_ResumeMusic instead, to unpause.
13    SDL_LockAudio
14     This is just not needed since SDL_mixer handles this for you.
15     Using it may cause problems as well.
16    SDL_UnlockAudio
17     This is just not needed since SDL_mixer handles this for you.
18     Using it may cause problems as well.
19*/
20
21#ifndef _SOUND_ENGINE_H
22#define _SOUND_ENGINE_H
23
24#include "base_object.h"
25#include <SDL_mixer.h>
26
27#define SOUND_DEFAULT_FREQUENCY 44100
28#define SOUND_DEFAULT_CHANNELS 2
29#define SOUND_DEFAULT_BUFIZE 16384
30
31// an enumerator of the different Sound Types.
32typedef enum SOUND_TYPE {SOUND_NONE,
33                         SOUND_WAV, /* .wav */
34                         SOUND_MOD, /* .mod .s3m .it .xm */
35                         SOUND_MID, /* mid */
36                         SOUND_OGG,
37                         SOUND_MP3};
38
39// FORWARD DEFINITION
40
41class Sound {
42 public:
43  Sound(const char* fileName, SOUND_TYPE soundType);
44  virtual ~Sound(void);
45 protected:
46  SOUND_TYPE soundType;
47  int channel;
48};
49
50class SoundEffect : public Sound {
51 public:
52  SoundEffect(const char* fileName, SOUND_TYPE soundType = SOUND_NONE);
53  virtual ~SoundEffect(void);
54 private:
55  Mix_Chunk* effect;
56};
57
58class Music :public Sound {
59 public:
60  Music(const char* fileName, SOUND_TYPE soundType = SOUND_NONE);
61  virtual ~Music(void);
62 private:
63  Mix_Music* music;
64};
65
66//! The Main Sound Engine
67class SoundEngine : public BaseObject {
68
69 public:
70  static SoundEngine* getInstance(void);
71  virtual ~SoundEngine(void);
72
73
74  void setNumberOfChannels(unsigned int numberOfChannels);
75
76
77  static bool isInit;
78  static bool enabled;
79 private:
80  SoundEngine(void);
81  static SoundEngine* singletonRef;
82
83  void enableSound(void);
84  void disableSound(void);
85  static bool checkVersion(void);
86
87
88  // settings
89  int volume;
90  unsigned int numberOfChannels;
91
92  // audio specifications
93  int frequency;
94  Uint16 format;
95  int channels;
96  int bits;
97  int buffers;
98
99
100
101};
102
103
104#endif /* _SOUND_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.