Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: playing music works :)
now it really is bedTime

File size: 2.3 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
46  virtual void play() = 0;
47  virtual void stop() = 0;
48
49 protected:
50  SOUND_TYPE soundType;
51  int channel;
52  int volume;
53};
54
55class SoundEffect : public Sound {
56 public:
57  SoundEffect(const char* fileName, SOUND_TYPE soundType = SOUND_NONE);
58  virtual ~SoundEffect(void);
59
60  virtual void play();
61  virtual void stop();
62 private:
63  Mix_Chunk* effect;
64};
65
66class Music :public Sound {
67 public:
68  Music(const char* fileName, SOUND_TYPE soundType = SOUND_NONE);
69  virtual ~Music(void);
70
71  virtual void play();
72  virtual void stop();
73 private:
74  Mix_Music* music;
75};
76
77//! The Main Sound Engine
78class SoundEngine : public BaseObject {
79
80 public:
81  static SoundEngine* getInstance(void);
82  virtual ~SoundEngine(void);
83
84
85  void setNumberOfChannels(unsigned int numberOfChannels);
86
87
88  static bool isInit;
89  static bool enabled;
90 private:
91  SoundEngine(void);
92  static SoundEngine* singletonRef;
93
94  void enableSound(void);
95  void disableSound(void);
96  static bool checkVersion(void);
97
98
99  // settings
100  int volume;
101  unsigned int numberOfChannels;
102
103  // audio specifications
104  int frequency;
105  Uint16 format;
106  int channels;
107  int bits;
108  int buffers;
109
110
111
112};
113
114
115#endif /* _SOUND_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.