effect.cpp

来自「游戏音频程序设计-Beginning.Game.Audio.Programmin」· C++ 代码 · 共 167 行

CPP
167
字号
// Effect.cpp: implementation of the CEffect class.
//
//////////////////////////////////////////////////////////////////////

#include "Effect.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

namespace AudioEngine {

CEffect::CEffect()
{

}

CEffect::~CEffect()
{

}

void CChorusEffect::SetAllParameters(IDirectMusicAudioPath8 *audiopath)
{
  HRESULT hr;
  IDirectSoundFXChorus8* effect = NULL;
  
  // get the effect's interface
  hr = audiopath->GetObjectInPath(DMUS_PCHANNEL_ALL,
      DMUS_PATH_BUFFER_DMO, 0, GUID_All_Objects, 0, IID_IDirectSoundFXChorus8,
      (LPVOID*) &effect);
  ThrowIfFailed(hr, "CChorusEffect::SetAllParameters(): couldn't get effect interface.");

  // set the effect's params
  hr = effect->SetAllParameters(&m_Params);

  // release the effect's interface
  SAFE_RELEASE(effect);
}

void CCompressorEffect::SetAllParameters(IDirectMusicAudioPath8 *audiopath)
{
  HRESULT hr;
  IDirectSoundFXCompressor8* effect = NULL;
  
  // get the effect's interface
  hr = audiopath->GetObjectInPath(DMUS_PCHANNEL_ALL,
      DMUS_PATH_BUFFER_DMO, 0, GUID_All_Objects, 0, IID_IDirectSoundFXCompressor8,
      (LPVOID*) &effect);
  ThrowIfFailed(hr, "CCompressorEffect::SetAllParameters(): couldn't get effect interface.");

  // set the effect's params
  hr = effect->SetAllParameters(&m_Params);

  // release the effect's interface
  SAFE_RELEASE(effect);
}

void CDistortionEffect::SetAllParameters(IDirectMusicAudioPath8 *audiopath)
{
  HRESULT hr;
  IDirectSoundFXDistortion8* effect = NULL;
  
  // get the effect's interface
  hr = audiopath->GetObjectInPath(DMUS_PCHANNEL_ALL,
      DMUS_PATH_BUFFER_DMO, 0, GUID_All_Objects, 0, IID_IDirectSoundFXDistortion8,
      (LPVOID*) &effect);
  ThrowIfFailed(hr, "CDistortionEffect::SetAllParameters(): couldn't get effect interface.");

  // set the effect's params
  hr = effect->SetAllParameters(&m_Params);

  // release the effect's interface
  SAFE_RELEASE(effect);
}

void CEchoEffect::SetAllParameters(IDirectMusicAudioPath8 *audiopath)
{
  HRESULT hr;
  IDirectSoundFXEcho8* effect = NULL;
  
  // get the effect's interface
  hr = audiopath->GetObjectInPath(DMUS_PCHANNEL_ALL,
      DMUS_PATH_BUFFER_DMO, 0, GUID_All_Objects, 0, IID_IDirectSoundFXEcho8,
      (LPVOID*) &effect);
  ThrowIfFailed(hr, "CEchoEffect::SetAllParameters(): couldn't get effect interface.");

  // set the effect's params
  hr = effect->SetAllParameters(&m_Params);

  // release the effect's interface
  SAFE_RELEASE(effect);
}

void CFlangeEffect::SetAllParameters(IDirectMusicAudioPath8 *audiopath)
{
  HRESULT hr;
  IDirectSoundFXFlanger8* effect = NULL;
  
  // get the effect's interface
  hr = audiopath->GetObjectInPath(DMUS_PCHANNEL_ALL,
      DMUS_PATH_BUFFER_DMO, 0, GUID_All_Objects, 0, IID_IDirectSoundFXFlanger8,
      (LPVOID*) &effect);
  ThrowIfFailed(hr, "CFlangeEffect::SetAllParameters(): couldn't get effect interface.");

  // set the effect's params
  hr = effect->SetAllParameters(&m_Params);

  // release the effect's interface
  SAFE_RELEASE(effect);
}

void CGargleEffect::SetAllParameters(IDirectMusicAudioPath8 *audiopath)
{
  HRESULT hr;
  IDirectSoundFXGargle8* effect = NULL;
  
  // get the effect's interface
  hr = audiopath->GetObjectInPath(DMUS_PCHANNEL_ALL,
      DMUS_PATH_BUFFER_DMO, 0, GUID_All_Objects, 0, IID_IDirectSoundFXGargle8,
      (LPVOID*) &effect);
  ThrowIfFailed(hr, "CGargleEffect::SetAllParameters(): couldn't get effect interface.");

  // set the effect's params
  hr = effect->SetAllParameters(&m_Params);

  // release the effect's interface
  SAFE_RELEASE(effect);
}

void CParamEqEffect::SetAllParameters(IDirectMusicAudioPath8 *audiopath)
{
  HRESULT hr;
  IDirectSoundFXParamEq8* effect = NULL;
  
  // get the effect's interface
  hr = audiopath->GetObjectInPath(DMUS_PCHANNEL_ALL,
      DMUS_PATH_BUFFER_DMO, 0, GUID_All_Objects, 0, IID_IDirectSoundFXParamEq8,
      (LPVOID*) &effect);
  ThrowIfFailed(hr, "CParamEqEffect::SetAllParameters(): couldn't get effect interface.");

  // set the effect's params
  hr = effect->SetAllParameters(&m_Params);

  // release the effect's interface
  SAFE_RELEASE(effect);
}

void CWavesReverbEffect::SetAllParameters(IDirectMusicAudioPath8 *audiopath)
{
  HRESULT hr;
  IDirectSoundFXWavesReverb8* effect = NULL;
  
  // get the effect's interface
  hr = audiopath->GetObjectInPath(DMUS_PCHANNEL_ALL,
      DMUS_PATH_BUFFER_DMO, 0, GUID_All_Objects, 0, IID_IDirectSoundFXWavesReverb8,
      (LPVOID*) &effect);
  ThrowIfFailed(hr, "CWavesReverbEffect::SetAllParameters(): couldn't get effect interface.");

  // set the effect's params
  hr = effect->SetAllParameters(&m_Params);

  // release the effect's interface
  SAFE_RELEASE(effect);
}

} // namespace

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?