Пример #1
0
int sound_init () {
  //Initialize SDL_mixer
  if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 1024 ) == -1 ) return false;

  for (int c = 0; c < MAXSound; c++)
    soundEffects[c] = Mix_LoadWAV( filemgr.get_media(sound_files[c]).c_str() );

  ambience = Mix_LoadMUS( filemgr.get_media(music_files[0]).c_str() );

  if (ambience == NULL) return 0;
  return 1;
}
Пример #2
0
int default_ambience (int selection) {
  if ((selection < 0) || (selection > num_music_files)) selection = 0;
  if (current_music == music_files[selection]) return 2;
  if( Mix_PlayingMusic() == 0 ) Mix_HaltMusic();
  Mix_FreeMusic(ambience);
  ambience = Mix_LoadMUS( filemgr.get_media(music_files[selection]).c_str() );
  if (ambience == NULL) return 0;
  current_music = music_files[selection];
  return 1;
}
Пример #3
0
// Loads a media-located music file.
int load_ambience(string filename) {
  if (filename == current_music) return 2;
  if( Mix_PlayingMusic() == 0 ) Mix_HaltMusic();
  Mix_FreeMusic(ambience);
  
  ambience = Mix_LoadMUS( filemgr.get_media(filename).c_str() );
  if (ambience == NULL) {
    default_ambience(0);
    return 0;
  }
  current_music = filename;
  return 1;
}