Exemplo n.º 1
0
void Audio::PlaySoundEffect(unsigned int sound)
{
    if (m_engineExperiencedCriticalError) {
        return;
    }

    if (m_soundEffects.end() == m_soundEffects.find(sound))
        return;

    StopSoundEffect(sound);

    ThrowIfFailed(
		m_soundEffects[sound].m_soundEffectSourceVoice->SubmitSourceBuffer(&m_soundEffects[sound].m_audioBuffer)
		);

	XAUDIO2_BUFFER buf = {0};
	XAUDIO2_VOICE_STATE state = {0};

    if (m_engineExperiencedCriticalError) {
        // If there's an error, then we'll recreate the engine on the next render pass
        return;
    }

	SoundEffectData* soundEffect = &m_soundEffects[sound];
	HRESULT hr = soundEffect->m_soundEffectSourceVoice->Start();
	if FAILED(hr)
    {
        m_engineExperiencedCriticalError = true;
        return;
    }

	m_soundEffects[sound].m_soundEffectStarted = true;
}
Exemplo n.º 2
0
void Audio::StopAllSoundEffects(bool bReleaseData)
{
    if (m_engineExperiencedCriticalError) {
        return;
    }

    EffectList::iterator iter;
	for (iter = m_soundEffects.begin(); iter != m_soundEffects.end(); iter++)
	{
        if (iter->first != m_backgroundID){
            StopSoundEffect(iter->first);
            if (bReleaseData)
            {
                UnloadSoundEffect(iter->first);  
            }            
        }
	}
    if (bReleaseData)
    {
        for (iter = m_soundEffects.begin(); iter != m_soundEffects.end();)
        {
            if (iter->first != m_backgroundID){                
                m_soundEffects.erase(iter++);
            }
            else
            {
                iter++;
            }
        }
    }  
}
Exemplo n.º 3
0
void Audio::PlaySoundEffect(unsigned int sound)
{
    if (m_engineExperiencedCriticalError) {
        return;
    }

    if (m_soundEffects.end() == m_soundEffects.find(sound))
        return;

    StopSoundEffect(sound);

    if (FAILED(m_soundEffects[sound].m_soundEffectSourceVoice->SubmitSourceBuffer(&m_soundEffects[sound].m_audioBuffer)))
    {
        m_engineExperiencedCriticalError = true;
    }

    if (m_engineExperiencedCriticalError) {
        // If there's an error, then we'll recreate the engine on the next render pass
        return;
    }

	SoundEffectData* soundEffect = &m_soundEffects[sound];
	HRESULT hr = soundEffect->m_soundEffectSourceVoice->Start();
	if FAILED(hr)
    {
        m_engineExperiencedCriticalError = true;
        return;
    }

    m_soundEffects[sound].m_soundEffectStarted = true;
    m_soundEffects[sound].m_soundEffectPaused = false;
}
Exemplo n.º 4
0
void Audio::StopBackgroundMusic(bool bReleaseData)
{
    if (m_engineExperiencedCriticalError) {
        return;
    }

    StopSoundEffect(m_backgroundID);

    if (bReleaseData)
        UnloadSoundEffect(m_backgroundID);
}
Exemplo n.º 5
0
void Audio::StopAllSoundEffects()
{
    if (m_engineExperiencedCriticalError) {
        return;
    }

    EffectList::iterator iter;
	for (iter = m_soundEffects.begin(); iter != m_soundEffects.end(); iter++)
	{
        StopSoundEffect(iter->first);
	}
}
Exemplo n.º 6
0
void Audio::RewindSoundEffect(unsigned int sound)
{
    if (m_engineExperiencedCriticalError) {
        return;
    }

    if (m_soundEffects.end() == m_soundEffects.find(sound))
        return;

    StopSoundEffect(sound);
    PlaySoundEffect(sound);
}
void SoundLevel(const char *szSndName, C4Object *pObj, int32_t iLevel)
{
	// Sound level zero? Stop
	if (!iLevel) { StopSoundEffect(szSndName, pObj); return; }
	// Find or create instance
	C4SoundInstance *pInst = Application.SoundSystem.FindInstance(szSndName, pObj);
	if (!pInst) pInst = StartSoundEffect(szSndName, true, iLevel, pObj);
	if (!pInst) return;
	// Set volume
	pInst->SetVolume(iLevel);
	pInst->Execute();
}
Exemplo n.º 8
0
int32_t FnFxFireStop(C4AulContext *ctx, C4Object *pObj, int32_t iNumber,
                     int32_t iReason, bool fTemp) {
  // safety
  if (!pObj) return FALSE;
  // only if real removal is done
  if (fTemp) {
    // but fake being not on fire, so higher-priority effects get the status
    // right
    pObj->SetOnFire(false);
    return TRUE;
  }
  // alter OnFire-flag
  pObj->SetOnFire(false);
  // stop sound
  if (pObj->Def->Mass >= 100) StopSoundEffect("Fire", pObj);
  // done, success
  return TRUE;
}