Example #1
0
// Lecture des sons. Ils sont lu par streaming c'est à dire qu'ils sont chargés pendant la lecture.
void CSoundManager::Jouer
(
	std::string const & Filename, 
	ECanaux Canal, 
	bool bLoop
)
{
	if (!m_bCanauxJeu && Canal != CANAL_MUSIQUE)
		return;

	if (m_pSon[Canal])
		FSOUND_Stream_Close (m_pSon[Canal]);

	// Si bLoop == true alors le son boucle.
	if (bLoop)
	{
		FSOUND_SetLoopMode (0, FSOUND_LOOP_NORMAL);
		m_pSon[Canal] = FSOUND_Stream_Open((DIRECTORY + Filename).c_str(), FSOUND_LOOP_NORMAL, 0, 0);
		FSOUND_SetVolume (Canal, 64);
		FSOUND_SetVolumeAbsolute (Canal, 64);
	}
	// Sinon il est jouer une seule fois.
	else
	{
		m_pSon[Canal] = FSOUND_Stream_Open((DIRECTORY + Filename).c_str(), FSOUND_NORMAL, 0, 0);
		FSOUND_SetVolume (Canal, 255);
		FSOUND_SetVolumeAbsolute (Canal, 255);
	}

	FSOUND_Stream_Play (Canal, m_pSon[Canal]);
}
Example #2
0
bool CMusicChannelFMod::playStream()
{
	if (FSOUND_Stream_GetOpenState(_MusicStream) == -3)
	{
		nlwarning("NLSOUND FMod Driver: stream failed to open. (file not found, out of memory or other error)");
		FSOUND_Stream_Close(_MusicStream); _MusicStream = NULL; 
		return false;
	}

	// Start playing
	if ((_MusicChannel = FSOUND_Stream_PlayEx(FSOUND_FREE, _MusicStream, NULL, true)) == -1)
		return false;

	// stereo pan (as reccomended)
	FSOUND_SetPan(_MusicChannel, FSOUND_STEREOPAN);
	// update volume
	int vol255 = (int)(_Gain * 255.0f);
	FSOUND_SetVolumeAbsolute(_MusicChannel, vol255);
	// Set a callback to know if stream has ended
	_CallBackEnded = false;
	FSOUND_Stream_SetEndCallback(_MusicStream, streamEndCallBack, static_cast<void *>(this));
	// unpause
	FSOUND_SetPaused(_MusicChannel, false);

	return true;
}
Example #3
0
/** Set the music volume (if any music played). (volume value inside [0 , 1]) (default: 1)
 *	NB: the volume of music is NOT affected by IListener::setGain()
 */
void CMusicChannelFMod::setVolume(float gain)
{
	_Gain = gain;
	if (_MusicStream && _MusicChannel != -1)
	{
		int vol255 = (int)(gain * 255.0f);
		FSOUND_SetVolumeAbsolute(_MusicChannel, vol255);
	}
}
void LLAudioEngine_FMOD::setInternetStreamGain(F32 vol)
{
	mInternetStreamGain = vol;

	if (mInternetStreamChannel != -1)
	{
		vol = llclamp(vol, 0.f, 1.f);
		int vol_int = llround(vol * 255.f);
		FSOUND_SetVolumeAbsolute(mInternetStreamChannel, vol_int);
	}
}
//-----------------------------------------------------------------------
void LLAudioEngine_FMOD::setInternalGain(F32 gain)
{
	if (!mInited)
	{
		return;
	}

	gain = llclamp( gain, 0.0f, 1.0f );
	FSOUND_SetSFXMasterVolume( llround( 255.0f * gain ) );

	if ( mInternetStreamChannel != -1 )
	{
		F32 clamp_internet_stream_gain = llclamp( mInternetStreamGain, 0.0f, 1.0f );
		FSOUND_SetVolumeAbsolute( mInternetStreamChannel, llround( 255.0f * clamp_internet_stream_gain ) );
	}
}
void CAudioManager::SetVolume(int id, int vol){
  if(m_bValidAudio == false)
    return;
  if(vol < 0)
    vol = 0;
  if(vol > 255)
    vol = 255;

  for(int i = 0; i < m_AudioClip.size(); i++){
    if(m_AudioClip[i].AudioID == id && IsPlaying(id) == true){
      if(!FSOUND_SetVolumeAbsolute(m_AudioClip[i].channelPlaying, vol)){
        return;
      }
      else
        return;
    }
  }//for
}