VFmodSoundObject *RPG_VisionEffectHelper::CreateSoundEffect(RPG_VisionEffectSoundParams const& params)
{
    VASSERT(VFmodManager::GlobalManager().IsInitialized()); // ensure that the native Fmod system has been correctly initialized

    VFmodSoundResource *soundResource = static_cast<VFmodSoundResource *> (GetEffectResource("FmodSoundResource", params.m_soundFilename));
    VASSERT_MSG(soundResource, params.m_soundFilename);
    if (soundResource)
    {
        VFmodSoundObject *soundObject = soundResource->CreateInstance(params.m_position, VFMOD_FLAG_NONE);
        VASSERT_MSG(soundObject->IsValid(), params.m_soundFilename);
        if (soundObject->IsValid())
        {
            soundObject->Play();
        }
    }

    return NULL;
}
void VFmodAnimationEventSoundTrigger::OnAnimationEvent() 
{
  // Get the active event trigger info
  VFmodEventSoundTriggerInfo_t* info = (VFmodEventSoundTriggerInfo_t*) m_pActiveTriggerInfo;

  // Check if effect file is specified
  if (info == NULL || info->m_spSoundResource == NULL)
    return; 
  
  // Get entity position
  VisBaseEntity_cl* pEntity = (VisBaseEntity_cl *)m_pOwner;
  hkvVec3 vPos = pEntity->GetPosition();

  // Trigger sound effect  
  VFmodSoundObject* pSound = info->m_spSoundResource->CreateInstance(vPos, VFMOD_FLAG_NONE);
  if(pSound)
    pSound->Play();
}
Ejemplo n.º 3
0
// -------------------------------------------------------------------------- //
// Instances                                                
// -------------------------------------------------------------------------- //
VFmodSoundObject* VFmodManager::CreateSoundInstance(const char *szFilename, int iResourceUsageFlags, int iInstanceFlags, int iPriority)
{
  VFmodSoundResource *pRes = LoadSoundResource(szFilename, iResourceUsageFlags);
  if (!pRes)
    return NULL;

  // Note: Create all sound objects here as paused as we need to set AND update the
  // correct distance and attenuation first! Call Play() afterwards it set.
  VFmodSoundObject* pObj = pRes->CreateInstance(hkvVec3(0.0f,0.0f,0.0f), iInstanceFlags | VFMOD_FLAG_PAUSED, iPriority);
  if (pObj)
  {
    // Force sound source position update
    pObj->OnObject3DChanged(VisObject3D_cl::VIS_OBJECT3D_POSCHANGED);

    // Play if set
    if((iInstanceFlags & VFMOD_FLAG_PAUSED) == 0)
      pObj->Play();
  }

  return pObj;
}
Ejemplo n.º 4
0
int VFmodManager::GetActiveSourceVoiceCount() const
{
  int iActiveSourceCount = 0;

  int iSoundInstanceCount = m_soundInstances.Count();
  for (int i=0;i<iSoundInstanceCount;i++)
  {
    VFmodSoundObject* pInst = m_soundInstances.GetAt(i);
    if (pInst->IsPlaying())
      iActiveSourceCount++;
  }

  int iEventCount = m_events.Count();
  for (int i=0;i<iEventCount;i++)
  {
    VFmodEvent* pEvent = m_events.GetAt(i);
    if (pEvent->IsPlaying())
      iActiveSourceCount++;
  }

  return iActiveSourceCount;
}