Changeset 3114 in orxonox.OLD for orxonox/branches
- Timestamp:
- Dec 6, 2004, 12:39:37 PM (20 years ago)
- Location:
- orxonox/branches/sound
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/sound/hud/Makefile
r3020 r3114 1 1 CC = gcc -Wall -ansi 2 SOURCE = hud.cc 3 FLAGS = -lGL -lGLU `sdl-config --cflags --libs` 4 BINARY = hud 2 SOURCE = hud_tga.cc 3 FLAGS = -lGL -lGLU 4 SDL = `sdl-config --cflags --libs` 5 INCLUDES = -I/usr/include/SDL -L/usr/lib 6 BINARY = hud_tga 5 7 6 8 all: 7 $(CC) $(SOURCE) -o $(BINARY) $(FLAGS) 9 $(CC) $(SOURCE) -o $(BINARY) $(FLAGS) $(SDL) $(INCLUDES) 8 10 9 11 clean: -
orxonox/branches/sound/sound/sound_control.cc
r3020 r3114 21 21 int sfx_channel2 = -1; 22 22 int finished = 0; 23 static SoundControl* instance = NULL;24 static SoundControl* sound = SoundControl::getInstance();23 SoundControl* SoundControl::sound = SoundControl::getInstance(); 24 SoundControl* SoundControl::instance = 0; 25 25 int volume = SDL_MIX_MAXVOLUME; 26 26 int track_number = 1; 27 staticMix_Music* music = NULL;27 Mix_Music* music = NULL; 28 28 int audio_rate = 44100, audio_channels = MIX_DEFAULT_CHANNELS, 29 29 audio_buffers = 16384, bits = 0; … … 34 34 /** 35 35 \brief standard constructor 36 37 This constructor builds a SoundControl Object, which waits for callers. 36 This constructor builds a SoundControl Object and initialises it . 38 37 All sound output is handled by this singleton object. 39 38 */ 40 SoundControl::SoundControl 39 SoundControl::SoundControl() { 41 40 if(SDL_Init(SDL_INIT_AUDIO)<0) { 42 41 printf("SDL_Init: INIT_AUDIO error.\n"); … … 51 50 \brief Default destructor 52 51 */ 53 SoundControl::~SoundControl 52 SoundControl::~SoundControl() { 54 53 } 55 54 56 55 /** 57 \brief Returns a reference to the singleton56 \brief Returns a reference to the SoundControl singleton 58 57 */ 59 58 SoundControl* SoundControl::getInstance() { 60 if (instance == NULL) {59 if (instance == 0) { 61 60 instance = new SoundControl; 62 61 } … … 65 64 66 65 void SoundControl::deleteInstance() { 67 delete instance;68 instance = NULL;69 66 } 70 67 … … 82 79 \brief Sets the number of output Channels 83 80 */ 84 void SoundControl::setNumberOfChannels 81 void SoundControl::setNumberOfChannels(int number_of_channels) { 85 82 Mix_AllocateChannels(number_of_channels); 86 83 } 87 84 88 85 /** 89 \brief May be called from any WorldEntityto play a .xm file86 \brief Static function to play a .xm file 90 87 \param filename: self-explanatory 91 88 */ 92 void SoundControl::playMod 89 void SoundControl::playMod(char* fileName) { 93 90 Mix_Chunk* chunk = NULL; 94 91 chunk = Mix_LoadWAV(fileName); … … 99 96 100 97 /** 101 \brief May be called from any WorldEntityto play a .wav file98 \brief Static function to play a .wav file 102 99 \param filename: self-explanatory 103 100 */ 104 void SoundControl::playWav 101 void SoundControl::playWav(char* fileName) { 105 102 Mix_Chunk* chunk = NULL; 106 103 chunk = Mix_LoadWAV(fileName); … … 111 108 112 109 /** 113 \brief May be called from any WorldEntity to play a.ogg file110 \brief Static function to play an .ogg file 114 111 \param filename: self-explanatory 115 112 */ 116 void SoundControl::playOgg 113 void SoundControl::playOgg(char* fileName) { 117 114 Mix_Music* music = NULL; 118 115 music = Mix_LoadMUS(fileName); … … 126 123 \brief Heightens the overall volume of output 127 124 */ 128 void SoundControl::volumeUp 125 void SoundControl::volumeUp() { 129 126 volume = (volume + 1) << 1; 130 127 if(volume > SDL_MIX_MAXVOLUME) … … 137 134 \brief Lowers the overall volume of output 138 135 */ 139 void SoundControl::volumeDown 136 void SoundControl::volumeDown() { 140 137 volume >>= 1; 141 138 Mix_VolumeMusic(volume); … … 145 142 \brief Rewinds music to the beginning 146 143 */ 147 void SoundControl::trackRewind 144 void SoundControl::trackRewind() { 148 145 Mix_RewindMusic(); 149 146 } … … 152 149 \brief Rewinds the music 5 seconds 153 150 */ 154 void SoundControl::forwardMusic 151 void SoundControl::forwardMusic() { 155 152 Mix_SetMusicPosition(+5); 156 153 } … … 166 163 \brief Pauses music output 167 164 */ 168 void SoundControl::pauseMusic 165 void SoundControl::pauseMusic() { 169 166 Mix_PauseMusic(); 170 167 } 171 168 172 169 /** 173 \brief this function pauses music output174 */ 175 void SoundControl::resumeMusic 170 \brief Pauses music output 171 */ 172 void SoundControl::resumeMusic() { 176 173 Mix_ResumeMusic(); 177 174 } 175 176 /** 177 \brief Fades in music 178 */ 179 void fadeInMusic(int time) { 180 181 } 182 183 /** 184 \brief Fades out music 185 */ 186 void SoundControl::fadeOutMusic(int time) { 187 188 } 178 189 179 190 /** … … 194 205 if(key.type == SDL_KEYDOWN) { 195 206 if(sfx_channel1 < 0) { 196 sfx_channel1 = sound->playWav("sound1.wav"); 207 sfx_channel1 = 1; 208 sound->playWav("sound1.wav"); 197 209 } 198 210 } else { … … 204 216 if(key.type == SDL_KEYDOWN) { 205 217 if(sfx_channel2 < 0) { 206 sfx_channel2 = sound->playWav("sound2.wav"); 218 sfx_channel2 = 1; 219 sound->playWav("sound2.wav"); 207 220 } 208 221 } else { … … 224 237 } 225 238 226 int SoundControl::main( void) {239 int SoundControl::main(int argc, char* argv[]) { 227 240 SDL_Surface* screen; 228 241 SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO); -
orxonox/branches/sound/sound/sound_control.h
r3020 r3114 10 10 static SoundControl* getInstance(); 11 11 static void deleteInstance(); 12 12 13 void setNumberOfChannels(int number_of_channels); 13 void playMod(char* filename);14 void playWav(char* filename);15 void playOgg(char* filename);14 static void playMod(char* filename); 15 static void playWav(char* filename); 16 static void playOgg(char* filename); 16 17 void volumeUp(); 17 18 void volumeDown(); … … 21 22 void pauseMusic(); 22 23 void resumeMusic(); 24 void fadeInMusic(int time); 25 void fadeOutMusic(int time); 23 26 static void musicDone(); 27 24 28 void handleKey(SDL_KeyboardEvent key); 25 int main (void); 26 static SoundControl* instance; 29 int main(int argc, char* argv[]); 30 31 static SoundControl* sound; 27 32 int volume; 28 33 int track_number; … … 33 38 int sfx_channel2; 34 39 int finished; 35 private: 36 void initialise();40 41 protected: 37 42 SoundControl(); 38 43 ~SoundControl(); 44 void initialise(); 45 46 private: 47 static SoundControl* instance; 39 48 }; 40 49
Note: See TracChangeset
for help on using the changeset viewer.