Changeset 3512 in orxonox.OLD for orxonox/branches/soundEngine
- Timestamp:
- Mar 12, 2005, 12:41:09 AM (20 years ago)
- Location:
- orxonox/branches/soundEngine/src
- Files:
-
- 3 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 -
orxonox/branches/soundEngine/src/sound_control.h
r3509 r3512 2 2 #define SOUNDCONTROL_CLASS_H 3 3 4 #include <SDL/SDL.h>4 #include "stdincl.h" 5 5 #include <SDL/SDL_mixer.h> 6 #include <stdio.h>7 6 8 7 class SoundControl { … … 37 36 static SoundControl* singletonRef; 38 37 38 bool isInit; 39 39 40 public: 41 40 42 Mix_Music* music; 41 43 static SoundControl* sound; 42 44 int bits; 43 45 int volume; 46 44 47 int track_number; 45 int audio_rate, audio_channels, audio_buffers; 48 int audio_rate; 49 int audio_channels; 50 int audio_buffers; 46 51 int done; 47 Uint16 audio_format;48 52 int sfx_channel1; 49 53 int sfx_channel2; 50 54 int finished; 55 56 Uint16 audio_format; 51 57 }; 52 58 -
orxonox/branches/soundEngine/src/sound_test.cc
r3509 r3512 3 3 #include "sound_control.h" 4 4 5 int verbose = 3; 5 6 6 7 /** … … 51 52 SoundControl* soundControl = SoundControl::getInstance(); 52 53 53 SDL_Init(SDL_INIT_VIDEO |SDL_INIT_AUDIO);54 SDL_Init(SDL_INIT_VIDEO); 54 55 screen = SDL_SetVideoMode(320, 240, 0, 0); 55 56 while(!soundControl->finished) {
Note: See TracChangeset
for help on using the changeset viewer.