Changeset 2854 in orxonox.OLD for orxonox/branches/sound/src
- Timestamp:
- Nov 14, 2004, 4:44:31 PM (20 years ago)
- Location:
- orxonox/branches/sound/src
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/sound/src/Makefile.am
r2636 r2854 5 5 6 6 7 bin_PROGRAMS=orxonox 7 bin_PROGRAMS=orxonox sound 8 8 orxonox_SOURCES=orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc 9 10 sound_SOURCES=sound_test.cc sound_control.cc 9 11 10 12 noinst_HEADERS=ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h -
orxonox/branches/sound/src/Makefile.in
r2640 r2854 116 116 117 117 #"-O3 -pedantic -fPIC -ffast-math -I/usr/X11R6/include" 118 bin_PROGRAMS = orxonox 118 bin_PROGRAMS = orxonox sound 119 119 orxonox_SOURCES = orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc 120 121 sound_SOURCES = sound_test.cc sound_control.cc 120 122 121 123 noinst_HEADERS = ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h … … 125 127 CONFIG_HEADER = $(top_builddir)/config.h 126 128 CONFIG_CLEAN_FILES = 127 bin_PROGRAMS = orxonox$(EXEEXT) 129 bin_PROGRAMS = orxonox$(EXEEXT) sound$(EXEEXT) 128 130 PROGRAMS = $(bin_PROGRAMS) 129 131 … … 138 140 orxonox_DEPENDENCIES = 139 141 orxonox_LDFLAGS = 142 am_sound_OBJECTS = sound_test.$(OBJEXT) sound_control.$(OBJEXT) 143 sound_OBJECTS = $(am_sound_OBJECTS) 144 sound_LDADD = $(LDADD) 145 sound_DEPENDENCIES = 146 sound_LDFLAGS = 140 147 141 148 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) … … 148 155 @AMDEP_TRUE@ ./$(DEPDIR)/ini_parser.Po ./$(DEPDIR)/keynames.Po \ 149 156 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox.Po ./$(DEPDIR)/player.Po \ 157 @AMDEP_TRUE@ ./$(DEPDIR)/sound_control.Po \ 158 @AMDEP_TRUE@ ./$(DEPDIR)/sound_test.Po \ 150 159 @AMDEP_TRUE@ ./$(DEPDIR)/story_entity.Po ./$(DEPDIR)/track.Po \ 151 160 @AMDEP_TRUE@ ./$(DEPDIR)/vector.Po ./$(DEPDIR)/world.Po \ … … 156 165 CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ 157 166 -o $@ 158 DIST_SOURCES = $(orxonox_SOURCES) 167 DIST_SOURCES = $(orxonox_SOURCES) $(sound_SOURCES) 159 168 HEADERS = $(noinst_HEADERS) 160 169 161 170 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.in INSTALL \ 162 171 Makefile.am 163 SOURCES = $(orxonox_SOURCES) 172 SOURCES = $(orxonox_SOURCES) $(sound_SOURCES) 164 173 165 174 all: all-am … … 199 208 @rm -f orxonox$(EXEEXT) 200 209 $(CXXLINK) $(orxonox_LDFLAGS) $(orxonox_OBJECTS) $(orxonox_LDADD) $(LIBS) 210 sound$(EXEEXT): $(sound_OBJECTS) $(sound_DEPENDENCIES) 211 @rm -f sound$(EXEEXT) 212 $(CXXLINK) $(sound_LDFLAGS) $(sound_OBJECTS) $(sound_LDADD) $(LIBS) 201 213 202 214 mostlyclean-compile: … … 217 229 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox.Po@am__quote@ 218 230 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/player.Po@am__quote@ 231 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sound_control.Po@am__quote@ 232 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sound_test.Po@am__quote@ 219 233 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/story_entity.Po@am__quote@ 220 234 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/track.Po@am__quote@ -
orxonox/branches/sound/src/sound_control.cc
r2838 r2854 15 15 16 16 #include "sound_control.h" 17 #include <string.h>18 #include "SDL_mixer.h"19 17 20 18 using namespace std; 21 19 22 20 // global variables 23 24 SoundControl* SoundControl::instance = 0; // singleton reference 25 int volume = SDL_MIX_MAXVOLUME; // volume 26 int done = 0; // 21 SoundControl* SoundControl::instance = NULL; // singleton reference 22 int volume = SDL_MIX_MAXVOLUME; 23 int done = 0; 27 24 int track_number = 1; 28 Mix_Music* music = NULL; 25 static Mix_Music* music = NULL; 26 int audio_rate = MIX_DEFAULT_FREQUENCY, audio_channels = MIX_DEFAULT_CHANNELS, audio_buffers = 16384, bits = 0; 27 Uint16 audio_format = MIX_DEFAULT_FORMAT; 28 29 29 30 30 /** … … 35 35 */ 36 36 SoundControl::SoundControl () { 37 38 //setup parameters 39 int audio_rate = MIX_DEFAULT_FREQUENCY, audio_channels = MIX_DEFAULT_CHANNELS, audio_buffers = 8192, bits = 0; 40 Uint16 audio_format = MIX_DEFAULT_FORMAT; 41 42 //initializing sound and calling Mix_OpenAudio 37 38 /* 39 initializing sound and calling Mix_OpenAudio 43 40 if(SDL_Init(SDL_INIT_AUDIO)<0){ 44 printf("SDL_Init: \n"); 45 exit(1); 41 printf("SDL_Init: INIT_AUDIO error.\n"); 46 42 } 43 */ 47 44 48 45 if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)){ 49 printf("Mix_OpenAudio: \n"); 50 exit(1); 46 printf("Mix_OpenAudio: Failed to open audio!\n"); 51 47 } 52 48 … … 56 52 57 53 /** 58 \brief De structor for the singleton instance54 \brief Default destructor 59 55 */ 60 56 SoundControl::~SoundControl () { 61 delete instance;62 instance = 0;63 57 } 64 58 … … 67 61 */ 68 62 SoundControl* SoundControl::getInstance() { 69 if (instance == 0) {63 if (instance == NULL) { 70 64 instance = new SoundControl; 71 65 } … … 74 68 75 69 void SoundControl::deleteInstance() { 76 ~SoundControl(); 70 delete instance; 71 instance = NULL; 77 72 } 78 73 … … 186 181 */ 187 182 void SoundControl::pauseMusic () { 188 Mix_PauseMusic() 183 Mix_PauseMusic(); 189 184 } 190 185 … … 194 189 */ 195 190 void SoundControl::resumeMusic () { 196 Mix_ResumeMusic() 191 Mix_ResumeMusic(); 197 192 } 198 193 … … 200 195 \brief Selects the track of all orxonox tracks 201 196 */ 202 void SoundControl::trackSelect 197 void SoundControl::trackSelect() { 203 198 switch (track_number) { 204 199 case 1: … … 219 214 music = Mix_LoadMUS("luke_grey_orxonox3.ogg"); 220 215 if(Mix_PlayMusic(music, 1) == -1){ 221 printf("Mix_PlayMusic: %s\n",Mix_GetError());222 }223 Mix_HookMusicFinished(musicDone);224 break;216 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 217 } 218 Mix_HookMusicFinished(musicDone); 219 break; 225 220 case 4: 226 221 music = Mix_LoadMUS("luke_grey_and_aquarius_orxonox.ogg"); … … 239 234 case 6: 240 235 music = Mix_LoadMUS("nomenes_funkadudu.ogg"); 241 if(Mix_PlayMusic(music, 1) == -1){242 printf("Mix_PlayMusic: %s\n",Mix_GetError());243 }244 Mix_HookMusicFinished(musicDone);245 break;236 if(Mix_PlayMusic(music, 1) == -1){ 237 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 238 } 239 Mix_HookMusicFinished(musicDone); 240 break; 246 241 } 247 242 } … … 251 246 \brief Hooked by playOgg at end of .ogg playback 252 247 */ 253 void SoundControl::musicDone () { 254 track_number++; 248 void SoundControl::musicDone() { 255 249 Mix_HaltMusic(); 256 250 Mix_FreeMusic(music); -
orxonox/branches/sound/src/sound_control.h
r2838 r2854 2 2 #define SOUNDCONTROL_CLASS_H 3 3 4 #include "data_tank.h" 4 #include "SDL/SDL.h" 5 #include "SDL/SDL_mixer.h" 6 #include <stdio.h> 5 7 6 8 class SoundControl { … … 9 11 static SoundControl* getInstance(); 10 12 static void deleteInstance(); 11 void setNumberOfChannels(int number_of 13 void setNumberOfChannels(int number_of_channels); 12 14 int playMod(char* filename); 13 15 int playWav(char* filename); … … 21 23 void resumeMusic(); 22 24 void trackSelect(); 25 static void musicDone(); 23 26 24 27 protected: … … 29 32 private: 30 33 static SoundControl* instance; 31 32 } 34 }; 33 35 34 36 #endif -
orxonox/branches/sound/src/sound_test.cc
r2838 r2854 14 14 */ 15 15 16 17 16 #include "sound_test.h" 18 #include "SDL.h"19 #include "SDL_mixer.h"20 17 21 18 using namespace std; 22 19 23 SoundControl* test; 20 SoundControl* sound = NULL; 21 int counter = 0; 22 int through = 0; 24 23 25 SoundTest::SoundTest 26 test= SoundControl::getInstance();24 SoundTest::SoundTest() { 25 sound = SoundControl::getInstance(); 27 26 } 28 27 29 28 30 SoundTest::~SoundTest 31 29 SoundTest::~SoundTest() { 30 sound->deleteInstance(); 32 31 } 33 32 34 33 35 void main (void) { 34 int main(void) { 35 SoundTest(); 36 36 SDL_Surface *screen; 37 SDL_Init(SDL_INIT_VIDEO );37 SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO); 38 38 screen = SDL_SetVideoMode(320, 240, 0, 0); 39 SoundControl* sound = new SoundControl; 40 sound.SoundControl(); 41 sound->playOgg(music.ogg); 42 sound.~SoundControl(); 39 sound->playOgg("music.ogg"); 40 while(!through) { 41 SDL_Delay(100); 42 if(counter >= 1000) { 43 through = 1; 44 } 45 counter++; 46 } 47 SDL_Quit(); 43 48 } -
orxonox/branches/sound/src/sound_test.h
r2838 r2854 1 2 1 #ifndef SOUND_TEST_H 3 2 #define SOUND_TEST_H 4 3 5 #include "data_tank.h" 6 4 #include "sound_control.h" 5 #include "SDL/SDL.h" 6 #include "SDL/SDL_mixer.h" 7 7 8 8 class SoundTest { 9 9 10 10 public: 11 SoundTest (); 12 ~SoundTest (); 13 void main (void); 11 SoundTest(); 12 ~SoundTest(); 13 int main (void); 14 SoundControl* sound; 15 int counter; 16 int through; 14 17 }; 15 18
Note: See TracChangeset
for help on using the changeset viewer.