Changeset 3512 in orxonox.OLD for orxonox/branches/soundEngine/src/sound_control.cc
- Timestamp:
- Mar 12, 2005, 12:41:09 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/soundEngine/src/sound_control.cc
r3510 r3512 16 16 #include "sound_control.h" 17 17 18 18 19 using namespace std; 19 20 … … 28 29 */ 29 30 SoundControl::SoundControl() { 30 init();31 this->init(); 31 32 32 33 } … … 66 67 this->bits = 0; 67 68 this->audio_format = MIX_DEFAULT_FORMAT; 69 70 // initialize SDL 71 this->isInit = false; 72 if (!SDL_Init(SDL_INIT_AUDIO)) 73 { 74 PRINTF(1)("SDL-sound could not be initialized\n"); 75 return; 76 } 77 else 78 this->isInit = true; 68 79 69 70 Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); 71 bits=audio_format&0xFF; 72 printf("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", audio_rate, bits, audio_channels > 1 ? "stereo" : "mono", audio_buffers ); 73 Mix_VolumeMusic(volume); 74 75 if(SDL_Init(SDL_INIT_AUDIO)<0) 76 printf("SDL_Init: INIT_AUDIO error.\n"); 77 if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) 78 printf("Mix_OpenAudio: Failed to open audio!\n"); 80 Mix_QuerySpec(&this->audio_rate, &this->audio_format, &this->audio_channels); 81 this->bits=this->audio_format&0xFF; 82 PRINTF(3)("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", this->audio_rate, this->bits, this->audio_channels > 1 ? "stereo" : "mono", this->audio_buffers ); 83 Mix_VolumeMusic(this->volume); 84 85 if(Mix_OpenAudio(this->audio_rate, this->audio_format, this->audio_channels, this->audio_buffers)) 86 PRINTF(1)("Mix_OpenAudio: Failed to open audio!\n"); 79 87 80 88 … … 115 123 */ 116 124 void SoundControl::playOgg(char* fileName) { 117 Mix_Music* music = NULL; 118 music = Mix_LoadMUS(fileName); 125 Mix_Music* music = Mix_LoadMUS(fileName); 119 126 if(Mix_PlayMusic(music, 1) == -1) { 120 127 printf("Mix_PlayMusic: %s\n",Mix_GetError()); … … 127 134 */ 128 135 void SoundControl::volumeUp() { 129 volume = (volume + 1) << 1;130 if( volume > SDL_MIX_MAXVOLUME)131 volume = SDL_MIX_MAXVOLUME;132 Mix_VolumeMusic( volume);136 this->volume = (this->volume++) << 1; 137 if(this->volume > SDL_MIX_MAXVOLUME) 138 this->volume = SDL_MIX_MAXVOLUME; 139 Mix_VolumeMusic(this->volume); 133 140 } 134 141 … … 138 145 */ 139 146 void SoundControl::volumeDown() { 140 volume >>= 1; 141 Mix_VolumeMusic(volume); 147 this->volume >>= 1; 148 if(this->volume < 0) 149 this->volume = 1; 150 Mix_VolumeMusic(this->volume); 142 151 } 143 152
Note: See TracChangeset
for help on using the changeset viewer.