Example #1
0
  void SoundManager::PlaySound(const std::string& filename, Player* p, SoundType type) {
    if (p->getPlayingSound()==true && type == PRIMARY)
      return;

    Mix_Chunk* sound = Mix_LoadWAV(filename.c_str());
    if (sound == NULL) {
      printf( "Failed to load Sound: SDL_mixer Error: %s\n", Mix_GetError() );
      return;
    }

    Mix_VolumeMusic(14);
    Mix_Fading(MIX_FADING_IN);
    int channel = Mix_PlayChannel(-1, sound, 0);

    if (channel == -1) {
      printf("Unable to play Ogg file: %s\n", Mix_GetError());
      return;
    }

    if (type==PRIMARY)
      p->setPlayingSound(true);

    SoundInfo info;
    info.chunk = sound;
    info.type = type;
    sounds[channel] = info;
  }
Example #2
0
  void SoundManager::PlayMusic(const std::string& filename) {
    if (music!=nullptr) {
      Mix_FreeMusic(music);
      music = nullptr;
    }


    music = Mix_LoadMUS(filename.c_str());
    if (music == NULL) {
      printf( "Failed to load Music: SDL_mixer Error: %s\n", Mix_GetError() );
      return;
    }

    Mix_VolumeMusic(14);
    Mix_Fading(MIX_FADING_IN);

    if (Mix_PlayMusic(music, 0) == -1) {
      printf("Unable to play Ogg file: %s\n", Mix_GetError());
      return;
    }
  }
Example #3
0
      void AudioPlayer::play() {
	Mix_VolumeMusic(14);
	Mix_Fading(MIX_FADING_IN);
	if(Mix_PlayMusic(music, 0) == -1) { printf("Unable to play Ogg file: %s\n", Mix_GetError()); } 
      }
Example #4
0
//is fading in
bool CChannel::IsFadingIn()
{
	//return
	return(Mix_Fading(m_Channel)==MIX_FADING_IN);
}
Example #5
0
//is fading
bool CChannel::IsFading()
{
	//return
	return(Mix_Fading(m_Channel)==MIX_NO_FADING);
}
Example #6
0
//is fading out
bool CChannel::IsFadingOut()
{
	//return
	return(Mix_Fading(m_Channel)==MIX_FADING_OUT);
}