Changeset 2815 in orxonox.OLD for orxonox/branches/sound/src/sound_control.cc
- Timestamp:
- Nov 11, 2004, 6:16:00 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/sound/src/sound_control.cc
r2793 r2815 24 24 \brief standard constructor 25 25 26 This constructor builds a SoundControl Object, which waits for callers 27 calling its functions to output sound. All sound output is handles by this 28 object, which must only be constructed once. 26 This constructor builds a SoundControl Object, which waits for callers. 27 All sound output is handled by this singleton object. 29 28 */ 30 29 SoundControl::SoundControl () { … … 40 39 exit(1); 41 40 } 42 41 43 42 if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)){ 44 43 printf("Mix_OpenAudio: \n"); 45 44 exit(1); 46 45 } 47 48 postConstruction(); 49 } 50 51 SoundControl::SoundControl (int audio_rate audiorate, Uint16 audio_format audioformat, int audio_channels audiochannels, int audio_buffers audiobuffers) { 52 53 //setup parameters 54 int audio_rate = audiorate, audio_channels = audiochannels, audio_buffers = audiobuffers, bits = 0; 55 Uint16 audio_format = audioformat; 56 Mix_Music* music = NULL; 57 58 //initializing sound and calling Mix_OpenAudio 59 if(SDL_Init(SDL_INIT_AUDIO)<0){ 60 printf("SDL_Init: \n"); 61 exit(1); 62 } 63 64 if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)){ 65 printf("Mix_OpenAudio: \n"); 66 exit(1); 67 } 68 69 postConstruction(); 70 } 71 72 73 /** 74 \brief standard destructor 46 47 initialise(); 48 } 49 50 51 /** 52 \brief Destructor for the singleton instance 75 53 */ 76 54 SoundControl::~SoundControl () { 77 SoundControl* SoundControl::singleton = NULL; 78 } 79 80 SoundControl* SoundControl::singleton = NULL; 55 instance = NULL; 56 } 57 58 /** 59 \brief Returns a reference to the singleton 60 */ 61 SoundControl* SoundControl::getObject(){ 62 static SoundControl instance; 63 return &instance; 64 } 81 65 82 66 … … 84 68 \brief Is called by SoundControl object to initiate all values 85 69 */ 86 void SoundControl:: postConstruction() {70 void SoundControl::initialise() { 87 71 88 72 // Print some info … … 99 83 100 84 /** 101 \brief Sets the number of output Channels 85 \brief Sets the number of output Channels (should not be used) 102 86 */ 103 87 void SoundControl::setNumberOfChannels (int number_of_channels) { … … 220 204 break; 221 205 case 4: 222 music = Mix_LoadMUS("luke_grey_and 206 music = Mix_LoadMUS("luke_grey_and_aquarius_orxonox.ogg"); 223 207 break; 224 208 case 5: 225 209 music = Mix_LoadMUS("nomenes_orxonox.ogg"); 226 210 break; 211 case 6: 212 music = Mix_LoadMUS("nomenes_funkadudu.ogg"); 213 break; 227 214 } 228 215 }
Note: See TracChangeset
for help on using the changeset viewer.