Changeset 3179 in orxonox.OLD for orxonox/branches
- Timestamp:
- Dec 15, 2004, 3:40:54 AM (20 years ago)
- Location:
- orxonox/branches/sound/src
- Files:
-
- 2 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/sound/src/Makefile
r2964 r3179 1 # Makefile.in generated by automake 1.8. 5from Makefile.am.1 # Makefile.in generated by automake 1.8.2 from Makefile.am. 2 2 # src/Makefile. Generated from Makefile.in by configure. 3 3 … … 49 49 CONFIG_HEADER = $(top_builddir)/config.h 50 50 CONFIG_CLEAN_FILES = 51 am__installdirs = "$(DESTDIR)$(bindir)"51 am__installdirs = $(DESTDIR)$(bindir) 52 52 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) 53 53 PROGRAMS = $(bin_PROGRAMS) … … 90 90 CTAGS = ctags 91 91 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 92 ACLOCAL = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --runaclocal-1.892 ACLOCAL = aclocal-1.8 93 93 AMDEP_FALSE = # 94 94 AMDEP_TRUE = 95 AMTAR = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --runtar96 AUTOCONF = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --runautoconf97 AUTOHEADER = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --runautoheader98 AUTOMAKE = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --runautomake-1.895 AMTAR = tar 96 AUTOCONF = autoconf 97 AUTOHEADER = autoheader 98 AUTOMAKE = automake-1.8 99 99 AWK = gawk 100 100 CC = gcc … … 113 113 ECHO_T = 114 114 EGREP = grep -E 115 EXEEXT = 115 EXEEXT = .exe 116 116 INSTALL_DATA = ${INSTALL} -m 644 117 117 INSTALL_PROGRAM = ${INSTALL} … … 120 120 LDFLAGS = 121 121 LIBOBJS = 122 LIBS = -lm -l GL -lGLU -lSDL -lSDL_mixer -lpthread -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0122 LIBS = -lm -lopengl32 -lGLU32 -lmingw32 -lsdlmain -lsdl -lSDL_mixer -Lc:/Prog/Utils/MinGW/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -liconv 123 123 LTLIBOBJS = 124 MAKEINFO = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --runmakeinfo125 MSBITFIELDS = 124 MAKEINFO = makeinfo 125 MSBITFIELDS = -mms-bitfields 126 126 OBJEXT = o 127 127 PACKAGE = orxonox … … 137 137 VERSION = 0.1-pre-alpha 138 138 ac_ct_CC = gcc 139 ac_ct_CXX = 139 ac_ct_CXX = g++ 140 140 ac_ct_STRIP = 141 141 am__fastdepCC_FALSE = # … … 153 153 includedir = ${prefix}/include 154 154 infodir = ${prefix}/info 155 install_sh = / home/bensch/svn/orxonox/branches/sound/install-sh155 install_sh = /c/Documents and Settings/bensch/Desktop/svn/orxonox/branches/sound/install-sh 156 156 libdir = ${exec_prefix}/lib 157 157 libexecdir = ${exec_prefix}/libexec … … 206 206 install-binPROGRAMS: $(bin_PROGRAMS) 207 207 @$(NORMAL_INSTALL) 208 test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"208 $(mkdir_p) $(DESTDIR)$(bindir) 209 209 @list='$(bin_PROGRAMS)'; for p in $$list; do \ 210 210 p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ … … 212 212 ; then \ 213 213 f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ 214 echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \215 $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f"|| exit 1; \214 echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \ 215 $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \ 216 216 else :; fi; \ 217 217 done … … 221 221 @list='$(bin_PROGRAMS)'; for p in $$list; do \ 222 222 f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ 223 echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \224 rm -f "$(DESTDIR)$(bindir)/$$f"; \223 echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ 224 rm -f $(DESTDIR)$(bindir)/$$f; \ 225 225 done 226 226 … … 296 296 $(AWK) ' { files[$$0] = 1; } \ 297 297 END { for (i in files) print i; }'`; \ 298 if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ 299 test -n "$$unique" || unique=$$empty_fix; \ 300 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 301 $$tags $$unique; \ 302 fi 298 test -z "$(ETAGS_ARGS)$$tags$$unique" \ 299 || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 300 $$tags $$unique 303 301 ctags: CTAGS 304 302 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ … … 355 353 all-am: Makefile $(PROGRAMS) $(HEADERS) 356 354 installdirs: 357 for dir in "$(DESTDIR)$(bindir)"; do \ 358 test -z "$$dir" || $(mkdir_p) "$$dir"; \ 359 done 355 $(mkdir_p) $(DESTDIR)$(bindir) 360 356 install: install-am 361 357 install-exec: install-exec-am -
orxonox/branches/sound/src/Makefile.in
r2964 r3179 1 # Makefile.in generated by automake 1.8. 5from Makefile.am.1 # Makefile.in generated by automake 1.8.2 from Makefile.am. 2 2 # @configure_input@ 3 3 … … 49 49 CONFIG_HEADER = $(top_builddir)/config.h 50 50 CONFIG_CLEAN_FILES = 51 am__installdirs = "$(DESTDIR)$(bindir)"51 am__installdirs = $(DESTDIR)$(bindir) 52 52 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) 53 53 PROGRAMS = $(bin_PROGRAMS) … … 206 206 install-binPROGRAMS: $(bin_PROGRAMS) 207 207 @$(NORMAL_INSTALL) 208 test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"208 $(mkdir_p) $(DESTDIR)$(bindir) 209 209 @list='$(bin_PROGRAMS)'; for p in $$list; do \ 210 210 p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ … … 212 212 ; then \ 213 213 f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ 214 echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \215 $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f"|| exit 1; \214 echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \ 215 $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \ 216 216 else :; fi; \ 217 217 done … … 221 221 @list='$(bin_PROGRAMS)'; for p in $$list; do \ 222 222 f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ 223 echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \224 rm -f "$(DESTDIR)$(bindir)/$$f"; \223 echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ 224 rm -f $(DESTDIR)$(bindir)/$$f; \ 225 225 done 226 226 … … 296 296 $(AWK) ' { files[$$0] = 1; } \ 297 297 END { for (i in files) print i; }'`; \ 298 if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ 299 test -n "$$unique" || unique=$$empty_fix; \ 300 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 301 $$tags $$unique; \ 302 fi 298 test -z "$(ETAGS_ARGS)$$tags$$unique" \ 299 || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 300 $$tags $$unique 303 301 ctags: CTAGS 304 302 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ … … 355 353 all-am: Makefile $(PROGRAMS) $(HEADERS) 356 354 installdirs: 357 for dir in "$(DESTDIR)$(bindir)"; do \ 358 test -z "$$dir" || $(mkdir_p) "$$dir"; \ 359 done 355 $(mkdir_p) $(DESTDIR)$(bindir) 360 356 install: install-am 361 357 install-exec: install-exec-am -
orxonox/branches/sound/src/sound_control.cc
r2972 r3179 18 18 using namespace std; 19 19 20 // global variables 21 SoundControl* SoundControl::instance = NULL; // singleton reference 20 int sfx_channel1 = -1; 21 int sfx_channel2 = -1; 22 int finished = 0; 23 SoundControl* SoundControl::sound = SoundControl::getInstance(); 24 SoundControl* SoundControl::instance = 0; 22 25 int volume = SDL_MIX_MAXVOLUME; 23 int done = 0;24 26 int track_number = 1; 25 static Mix_Music* music = NULL; 26 int audio_rate = MIX_DEFAULT_FREQUENCY, audio_channels = MIX_DEFAULT_CHANNELS, audio_buffers = 16384, bits = 0; 27 Mix_Music* music = NULL; 28 int audio_rate = 44100, audio_channels = MIX_DEFAULT_CHANNELS, 29 audio_buffers = 16384, bits = 0; 27 30 Uint16 audio_format = MIX_DEFAULT_FORMAT; 31 SDL_Event event; 28 32 29 33 30 34 /** 31 35 \brief standard constructor 32 33 This constructor builds a SoundControl Object, which waits for callers. 36 This constructor builds a SoundControl Object and initialises it . 34 37 All sound output is handled by this singleton object. 35 38 */ 36 SoundControl::SoundControl () { 37 38 /* 39 initializing sound and calling Mix_OpenAudio 40 if(SDL_Init(SDL_INIT_AUDIO)<0){ 39 SoundControl::SoundControl() { 40 if(SDL_Init(SDL_INIT_AUDIO)<0) { 41 41 printf("SDL_Init: INIT_AUDIO error.\n"); 42 42 } 43 */ 44 45 if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)){ 43 if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) { 46 44 printf("Mix_OpenAudio: Failed to open audio!\n"); 47 45 } 48 49 46 initialise(); 50 47 } 51 48 52 53 49 /** 54 50 \brief Default destructor 55 51 */ 56 SoundControl::~SoundControl () {52 SoundControl::~SoundControl() { 57 53 } 58 54 59 55 /** 60 \brief Returns a reference to the singleton56 \brief Returns a reference to the SoundControl singleton 61 57 */ 62 58 SoundControl* SoundControl::getInstance() { 63 if (instance == NULL) {59 if (instance == 0) { 64 60 instance = new SoundControl; 65 61 } … … 68 64 69 65 void SoundControl::deleteInstance() { 70 delete instance; 71 instance = NULL; 72 } 73 74 /** 75 \brief Is called by SoundControl object to initiate all values 66 } 67 68 /** 69 \brief Is called by SoundControl object to initiate all values and to output some text 76 70 */ 77 71 void SoundControl::initialise() { 78 79 // Print some info80 72 Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); 81 73 bits=audio_format&0xFF; … … 84 76 } 85 77 86 87 /** 88 \brief Sets the number of output Channels (should not be used) 89 */ 90 void SoundControl::setNumberOfChannels (int number_of_channels) { 78 /** 79 \brief Sets the number of output Channels 80 */ 81 void SoundControl::setNumberOfChannels(int number_of_channels) { 91 82 Mix_AllocateChannels(number_of_channels); 92 83 } 93 84 94 95 /** 96 \brief May be called from any WorldEntity to play a .xm file 85 /** 86 \brief Static function to play a .xm file 97 87 \param filename: self-explanatory 98 88 */ 99 int SoundControl::playMod(char* fileName) {89 void SoundControl::playMod(char* fileName) { 100 90 Mix_Chunk* chunk = NULL; 101 91 chunk = Mix_LoadWAV(fileName); … … 105 95 } 106 96 107 108 /** 109 \brief May be called from any WorldEntity to play a .wav file 97 /** 98 \brief Static function to play a .wav file 110 99 \param filename: self-explanatory 111 100 */ 112 int SoundControl::playWav(char* fileName) {101 void SoundControl::playWav(char* fileName) { 113 102 Mix_Chunk* chunk = NULL; 114 103 chunk = Mix_LoadWAV(fileName); … … 118 107 } 119 108 120 121 /** 122 \brief May be called from any WorldEntity to play a .ogg file 109 /** 110 \brief Static function to play an .ogg file 123 111 \param filename: self-explanatory 124 112 */ 125 int SoundControl::playOgg(char* fileName) {113 void SoundControl::playOgg(char* fileName) { 126 114 Mix_Music* music = NULL; 127 115 music = Mix_LoadMUS(fileName); 128 if(Mix_PlayMusic(music, 1) == -1) {116 if(Mix_PlayMusic(music, 1) == -1) { 129 117 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 130 118 } … … 132 120 } 133 121 134 135 122 /** 136 123 \brief Heightens the overall volume of output 137 124 */ 138 void SoundControl::volumeUp 125 void SoundControl::volumeUp() { 139 126 volume = (volume + 1) << 1; 140 127 if(volume > SDL_MIX_MAXVOLUME) … … 147 134 \brief Lowers the overall volume of output 148 135 */ 149 void SoundControl::volumeDown 136 void SoundControl::volumeDown() { 150 137 volume >>= 1; 151 138 Mix_VolumeMusic(volume); 152 139 } 153 140 154 155 141 /** 156 142 \brief Rewinds music to the beginning 157 143 */ 158 void SoundControl::trackRewind 144 void SoundControl::trackRewind() { 159 145 Mix_RewindMusic(); 160 146 } 161 147 162 163 148 /** 164 149 \brief Rewinds the music 5 seconds 165 150 */ 166 void SoundControl::forwardMusic 151 void SoundControl::forwardMusic() { 167 152 Mix_SetMusicPosition(+5); 168 153 } 169 170 154 171 155 /** … … 176 160 } 177 161 178 179 162 /** 180 163 \brief Pauses music output 181 164 */ 182 void SoundControl::pauseMusic 165 void SoundControl::pauseMusic() { 183 166 Mix_PauseMusic(); 184 167 } 185 168 186 187 /** 188 \brief this function pauses music output 189 */ 190 void SoundControl::resumeMusic () { 169 /** 170 \brief Pauses music output 171 */ 172 void SoundControl::resumeMusic() { 191 173 Mix_ResumeMusic(); 192 174 } 193 175 194 176 /** 195 \brief Selects the track of all orxonox tracks 196 */ 197 void SoundControl::trackSelect() { 198 switch (track_number) { 199 case 1: 200 music = Mix_LoadMUS("luke_grey_orxonox1.ogg"); 201 if(Mix_PlayMusic(music, 1) == -1){ 202 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 203 } 204 Mix_HookMusicFinished(musicDone); 205 break; 206 case 2: 207 music = Mix_LoadMUS("luke_grey_orxonox2.ogg"); 208 if(Mix_PlayMusic(music, 1) == -1){ 209 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 210 } 211 Mix_HookMusicFinished(musicDone); 212 break; 213 case 3: 214 music = Mix_LoadMUS("luke_grey_orxonox3.ogg"); 215 if(Mix_PlayMusic(music, 1) == -1){ 216 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 217 } 218 Mix_HookMusicFinished(musicDone); 219 break; 220 case 4: 221 music = Mix_LoadMUS("luke_grey_and_aquarius_orxonox.ogg"); 222 if(Mix_PlayMusic(music, 1) == -1){ 223 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 224 } 225 Mix_HookMusicFinished(musicDone); 226 break; 227 case 5: 228 music = Mix_LoadMUS("nomenes_orxonox.ogg"); 229 if(Mix_PlayMusic(music, 1) == -1){ 230 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 231 } 232 Mix_HookMusicFinished(musicDone); 233 break; 234 case 6: 235 music = Mix_LoadMUS("nomenes_funkadudu.ogg"); 236 if(Mix_PlayMusic(music, 1) == -1){ 237 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 238 } 239 Mix_HookMusicFinished(musicDone); 240 break; 241 } 242 } 243 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 } 244 189 245 190 /** … … 251 196 music = NULL; 252 197 } 198 199 /** 200 \brief Handles input events 201 */ 202 void SoundControl::handleKey(SDL_KeyboardEvent key) { 203 switch(key.keysym.sym) { 204 case SDLK_a: 205 if(key.type == SDL_KEYDOWN) { 206 if(sfx_channel1 < 0) { 207 sfx_channel1 = 1; 208 sound->playWav("sound1.wav"); 209 } 210 } else { 211 Mix_HaltChannel(sfx_channel1); 212 sfx_channel1 = -1; 213 } 214 break; 215 case SDLK_s: 216 if(key.type == SDL_KEYDOWN) { 217 if(sfx_channel2 < 0) { 218 sfx_channel2 = 1; 219 sound->playWav("sound2.wav"); 220 } 221 } else { 222 Mix_HaltChannel(sfx_channel2); 223 sfx_channel2 = -1; 224 } 225 break; 226 case SDLK_m: 227 if(key.state == SDL_PRESSED) { 228 sound->playOgg("music.ogg"); 229 } 230 break; 231 case SDLK_q: 232 finished = 1; 233 break; 234 default: 235 break; 236 } 237 } 238 239 int SoundControl::main(int argc, char* argv[]) { 240 SDL_Surface* screen; 241 SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO); 242 screen = SDL_SetVideoMode(320, 240, 0, 0); 243 while(!finished) { 244 while(SDL_PollEvent(&event)) { 245 switch(event.type) { 246 case SDL_QUIT: 247 finished = 1; 248 break; 249 case SDL_KEYDOWN: 250 case SDL_KEYUP: 251 SoundControl::handleKey(event.key); 252 break; 253 default: 254 break; 255 } 256 } 257 SDL_Delay(50); 258 } 259 deleteInstance(); 260 SDL_Quit(); 261 return 0; 262 } -
orxonox/branches/sound/src/sound_control.h
r2972 r3179 7 7 8 8 class SoundControl { 9 10 9 public: 11 10 static SoundControl* getInstance(); 12 11 static void deleteInstance(); 12 13 13 void setNumberOfChannels(int number_of_channels); 14 intplayMod(char* filename);15 intplayWav(char* filename);16 intplayOgg(char* filename);14 static void playMod(char* filename); 15 static void playWav(char* filename); 16 static void playOgg(char* filename); 17 17 void volumeUp(); 18 18 void volumeDown(); … … 22 22 void pauseMusic(); 23 23 void resumeMusic(); 24 void trackSelect(); 24 void fadeInMusic(int time); 25 void fadeOutMusic(int time); 25 26 static void musicDone(); 27 28 void handleKey(SDL_KeyboardEvent key); 29 int main(int argc, char* argv[]); 30 31 static SoundControl* sound; 32 int volume; 33 int track_number; 34 int audio_rate, audio_channels, audio_buffers; 35 int done; 36 Uint16 audio_format; 37 int sfx_channel1; 38 int sfx_channel2; 39 int finished; 26 40 27 protected: 28 void initialise(); 41 protected: 29 42 SoundControl(); 30 43 ~SoundControl(); 44 void initialise(); 31 45 32 private:46 private: 33 47 static SoundControl* instance; 34 48 }; -
orxonox/branches/sound/src/sound_test.cc
r2972 r3179 32 32 33 33 34 int main( void) {34 int main(int argc, char *argv[]) { 35 35 SoundTest(); 36 36 SDL_Surface *screen;
Note: See TracChangeset
for help on using the changeset viewer.