⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3dsoundeffect.cpp

📁 游戏音频程序设计-Beginning.Game.Audio.Programming
💻 CPP
字号:
// 3DSoundEffect.cpp: implementation of the C3DSoundEffect class.
//
//////////////////////////////////////////////////////////////////////

#include "3DSoundEffect.h"
#include "DirectMusicSegment.h"

#include "AudioManager.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

namespace AudioEngine {

C3DSoundEffect::C3DSoundEffect(CAudioManager *mgr) : CDirectMusicSegment(mgr)
{
  ZeroMemory(&m_Props, sizeof(DS3DLISTENER));
  m_Props.dwSize = sizeof(DS3DLISTENER);
  m_Props.vConeOrientation.y = -1;
  m_Props.flMinDistance = 1;
  m_Props.flMaxDistance = 10;
  m_Props.dwInsideConeAngle = 360;
  m_Props.dwOutsideConeAngle = 360;
  m_Props.lConeOutsideVolume = DSBVOLUME_MIN;
  //SetHeadRelativeMode(false);
  
  m_AudioPath = NULL;
  
  // create our 3D audiopath
  HRESULT hr = m_Manager->GetPerformance()->CreateStandardAudioPath(
    DMUS_APATH_DYNAMIC_3D, CAudioManager::NUMCHANNELS, TRUE, &m_AudioPath);
  ThrowIfFailed(hr, "C3DSoundEffect: couldn't create 3D audio path!");

  // get our 3D sound buffer from that new audiopath
  hr = m_AudioPath->GetObjectInPath(DMUS_PCHANNEL_ALL, DMUS_PATH_BUFFER, 0, GUID_NULL, 0, 
    IID_IDirectSound3DBuffer8, (LPVOID*)&m_3DBuffer);
  ThrowIfFailed(hr, "C3DSoundEffect: couldn't get 3D DirectSound buffer from audio path!");
}

C3DSoundEffect::~C3DSoundEffect()
{
  SAFE_RELEASE(m_3DBuffer);
  SAFE_RELEASE(m_AudioPath);
}

void C3DSoundEffect::RefreshProps()
{
  HRESULT hr = m_3DBuffer->SetAllParameters(&m_Props, DS3D_DEFERRED);
  ThrowIfFailed(hr, "C3DSoundEffect::RefreshProps(): Error calling SetAllParameters");
}

} // namespace

⌨️ 快捷键说明

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