home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Game Audio Programming
/
GameAudioProgramming.iso
/
Game_Audio
/
AudioTest
/
EAXBuffer.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2002-06-25
|
11KB
|
341 lines
// EAXBuffer.cpp : implementation file
//
#include "stdafx.h"
#include "audiotest.h"
#include "AudioTestDlg.h"
#include "EAXBuffer.h"
#include "Sound3D.h"
#include "Audio.h"
using namespace Audio;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEAXBuffer dialog
CEAXBuffer::CEAXBuffer(CWnd* pParent /*=NULL*/)
: CDialog(CEAXBuffer::IDD, pParent)
{
//{{AFX_DATA_INIT(CEAXBuffer)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pTestDlg = 0;
}
void CEAXBuffer::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEAXBuffer)
DDX_Control(pDX, IDC_SLIDER_ROOMEFFECT_VOLUMEHF, m_SliderRoomEffectVolumeHF);
DDX_Control(pDX, IDC_SLIDER_ROOMEFFECT_VOLUME, m_SliderRoomEffectVolume);
DDX_Control(pDX, IDC_SLIDER_ROOMEFFECT_ROLLOFF_FACTOR, m_SliderRoomEffectRolloffFactor);
DDX_Control(pDX, IDC_SLIDER_OUTSIDE_HF_VOLUME, m_SliderOutsideHFVolume);
DDX_Control(pDX, IDC_SLIDER_OCCLUSION_VOLUME, m_SliderOcclusionVolume);
DDX_Control(pDX, IDC_SLIDER_OCCLUSION_ROOM_RATIO, m_SliderOcclusionRoomRatio);
DDX_Control(pDX, IDC_SLIDER_OCCLUSION_LFRATIO, m_SliderOcclusionLFRatio);
DDX_Control(pDX, IDC_SLIDER_OBSTRUCTION_VOLUME, m_SliderObstructionVolume);
DDX_Control(pDX, IDC_SLIDER_OBSTRUCTION_LFRATIO, m_SliderObstructionLFRatio);
DDX_Control(pDX, IDC_SLIDER_DIRECTPATH_VOLUMEHF, m_SliderDirectPathVolumeHF);
DDX_Control(pDX, IDC_SLIDER_DIRECTPATH_VOLUME, m_SliderDirectPathVolume);
DDX_Control(pDX, IDC_SLIDER_BUFFER_AIR_ABSORPTION_FACTOR, m_SliderBufferAirAbsorptionFactor);
DDX_Control(pDX, IDC_EDIT_ROOMEFFECT_VOLUMEHF, m_EditRoomEffectVolumeHF);
DDX_Control(pDX, IDC_EDIT_ROOMEFFECT_VOLUME, m_EditRoomEffectVolume);
DDX_Control(pDX, IDC_EDIT_ROOMEFFECT_ROLLOFF_FACTOR, m_EditRoomEffectRolloffFactor);
DDX_Control(pDX, IDC_EDIT_OUTSIDE_HF_VOLUME, m_EditOutsideHFVolume);
DDX_Control(pDX, IDC_EDIT_OCCLUSION_VOLUME, m_EditOcclusionVolume);
DDX_Control(pDX, IDC_EDIT_OCCLUSION_ROOM_RATIO, m_EditOcclusionRoomRatio);
DDX_Control(pDX, IDC_EDIT_OCCLUSION_LFRATIO, m_EditOcclusionLFRatio);
DDX_Control(pDX, IDC_EDIT_OBSTRUCTION_VOLUME, m_EditObstructionVolume);
DDX_Control(pDX, IDC_EDIT_OBSTRUCTION_LFRATIO, m_EditObstructionLFRatio);
DDX_Control(pDX, IDC_EDIT_DIRECTPATH_VOLUMEHF, m_EditDirectPathVolumeHF);
DDX_Control(pDX, IDC_EDIT_DIRECTPATH_VOLUME, m_EditDirectPathVolume);
DDX_Control(pDX, IDC_EDIT_BUFFER_AIR_ABSORPTION_FACTOR, m_EditAirAbsorptionFactor);
DDX_Control(pDX, IDC_CHECK_AUTO_ROOM_EFFECT_HF, m_CheckAutoRoomEffectHF);
DDX_Control(pDX, IDC_CHECK_AUTO_ROOM_EFFECT, m_CheckAutoRoomEffect);
DDX_Control(pDX, IDC_CHECK_AUTO_DIRECT_PATH_HF, m_CheckAutoDirectPathHF);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEAXBuffer, CDialog)
//{{AFX_MSG_MAP(CEAXBuffer)
ON_WM_HSCROLL()
ON_BN_CLICKED(IDC_CHECK_AUTO_DIRECT_PATH_HF, OnCheckAutoDirectPathHF)
ON_BN_CLICKED(IDC_CHECK_AUTO_ROOM_EFFECT_HF, OnCheckAutoRoomEffectHF)
ON_BN_CLICKED(IDC_CHECK_AUTO_ROOM_EFFECT, OnCheckAutoRoomEffect)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEAXBuffer message handlers
BOOL CEAXBuffer::OnInitDialog()
{
CDialog::OnInitDialog();
EAXBufferProps props;
m_SliderRoomEffectVolumeHF.SetRange(-10000, 0, TRUE);
m_SliderRoomEffectVolume.SetRange(-10000, 1000, TRUE);
m_SliderRoomEffectRolloffFactor.SetRange(0, 1000, TRUE);
m_SliderOutsideHFVolume.SetRange(-10000, 0, TRUE);
m_SliderOcclusionVolume.SetRange(-10000, 0, TRUE);
m_SliderOcclusionRoomRatio.SetRange(0, 1000, TRUE);
m_SliderOcclusionLFRatio.SetRange(0, 1000, TRUE);
m_SliderObstructionVolume.SetRange(-10000, 0, TRUE);
m_SliderObstructionLFRatio.SetRange(0, 100, TRUE);
m_SliderDirectPathVolumeHF.SetRange(-10000, 0, TRUE);
m_SliderDirectPathVolume.SetRange(-10000, 1000, TRUE);
m_SliderBufferAirAbsorptionFactor.SetRange(0, 1000, TRUE);
UpdateControls();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CEAXBuffer::PostNcDestroy()
{
CDialog::PostNcDestroy();
if(m_pTestDlg)
m_pTestDlg->m_pEAXBuffer = 0;
delete this;
}
void CEAXBuffer::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if(pScrollBar->IsKindOf(RUNTIME_CLASS(CSliderCtrl)))
{
CSliderCtrl* pSlider = reinterpret_cast<CSliderCtrl*>(pScrollBar);
if(!pSlider)
return;
ISound3D* pSound3D = m_pTestDlg->m_pSound3D->GetCurrentSound();
if(pSlider == &m_SliderRoomEffectVolumeHF)
{
if(pSound3D)
pSound3D->EAX()->SetRoomHF(pSlider->GetPos());
else
m_Props.lRoomHF = pSlider->GetPos();
}
else if(pSlider == &m_SliderRoomEffectVolume)
{
if(pSound3D)
pSound3D->EAX()->SetRoom(pSlider->GetPos());
else
m_Props.lRoom = pSlider->GetPos();
}
else if(pSlider == &m_SliderRoomEffectRolloffFactor)
{
if(pSound3D)
pSound3D->EAX()->SetRoomRolloffFactor(float(pSlider->GetPos()) / 100.0f);
else
m_Props.flRoomRolloffFactor = float(pSlider->GetPos()) / 100.0f;
}
else if(pSlider == &m_SliderOutsideHFVolume)
{
if(pSound3D)
pSound3D->EAX()->SetOutsideVolumeHF(pSlider->GetPos());
else
m_Props.lOutsideVolumeHF = pSlider->GetPos();
}
else if(pSlider == &m_SliderOcclusionVolume)
{
if(pSound3D)
pSound3D->EAX()->SetOcclusion(pSlider->GetPos());
else
m_Props.lOcclusion = pSlider->GetPos();
}
else if(pSlider == &m_SliderOcclusionRoomRatio)
{
if(pSound3D)
pSound3D->EAX()->SetOcclusionRoomRatio(float(pSlider->GetPos()) / 100.0f);
else
m_Props.flOcclusionRoomRatio = float(pSlider->GetPos()) / 100.0f;
}
else if(pSlider == &m_SliderOcclusionLFRatio)
{
if(pSound3D)
pSound3D->EAX()->SetOcclusionLFRatio(float(pSlider->GetPos()) / 100.0f);
else
m_Props.flOcclusionLFRatio = float(pSlider->GetPos()) / 100.0f;
}
else if(pSlider == &m_SliderObstructionVolume)
{
if(pSound3D)
pSound3D->EAX()->SetObstruction(pSlider->GetPos());
else
m_Props.lObstruction = pSlider->GetPos();
}
else if(pSlider == &m_SliderObstructionLFRatio)
{
if(pSound3D)
pSound3D->EAX()->SetObstructionLFRatio(float(pSlider->GetPos()) / 100.0f);
else
m_Props.flObstructionLFRatio = float(pSlider->GetPos()) / 100.0f;
}
else if(pSlider == &m_SliderDirectPathVolumeHF)
{
if(pSound3D)
pSound3D->EAX()->SetDirectHF(pSlider->GetPos());
else
m_Props.lDirectHF = pSlider->GetPos();
}
else if(pSlider == &m_SliderDirectPathVolume)
{
if(pSound3D)
pSound3D->EAX()->SetDirect(pSlider->GetPos());
else
m_Props.lDirect = pSlider->GetPos();
}
else if(pSlider == &m_SliderBufferAirAbsorptionFactor)
{
if(pSound3D)
pSound3D->EAX()->SetAirAbsorptionFactor(float(pSlider->GetPos()) / 100.0f);
else
m_Props.flAirAbsorptionFactor = float(pSlider->GetPos()) / 100.0f;
}
UpdateControls();
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CEAXBuffer::OnOK()
{
CDialog::DestroyWindow();
}
void CEAXBuffer::UpdateControls()
{
ISound3D* pSound3D = m_pTestDlg->m_pSound3D->GetCurrentSound();
if(pSound3D)
pSound3D->EAX()->GetProperties(m_Props);
CString sVal;
m_SliderRoomEffectVolumeHF.SetPos(m_Props.lRoomHF);
sVal.Format("%d", m_Props.lRoomHF);
m_EditRoomEffectVolumeHF.SetWindowText(sVal);
m_SliderRoomEffectVolume.SetPos(m_Props.lRoom);
sVal.Format("%d", m_Props.lRoom);
m_EditRoomEffectVolume.SetWindowText(sVal);
m_SliderRoomEffectRolloffFactor.SetPos(m_Props.flRoomRolloffFactor * 100);
sVal.Format("%.2f", m_Props.flRoomRolloffFactor);
m_EditRoomEffectRolloffFactor.SetWindowText(sVal);
m_SliderOutsideHFVolume.SetPos(m_Props.lOutsideVolumeHF);
sVal.Format("%d", m_Props.lOutsideVolumeHF);
m_EditOutsideHFVolume.SetWindowText(sVal);
m_SliderOcclusionVolume.SetPos(m_Props.lOcclusion);
sVal.Format("%d", m_Props.lOcclusion);
m_EditOcclusionVolume.SetWindowText(sVal);
m_SliderOcclusionRoomRatio.SetPos(m_Props.flOcclusionRoomRatio * 100);
sVal.Format("%.2f", m_Props.flOcclusionRoomRatio);
m_EditOcclusionRoomRatio.SetWindowText(sVal);
m_SliderOcclusionLFRatio.SetPos(m_Props.flOcclusionLFRatio * 100);
sVal.Format("%.2f", m_Props.flOcclusionLFRatio);
m_EditOcclusionLFRatio.SetWindowText(sVal);
m_SliderObstructionVolume.SetPos(m_Props.lObstruction);
sVal.Format("%d", m_Props.lObstruction);
m_EditObstructionVolume.SetWindowText(sVal);
m_SliderObstructionLFRatio.SetPos(m_Props.flObstructionLFRatio * 100);
sVal.Format("%.2f", m_Props.flObstructionLFRatio);
m_EditObstructionLFRatio.SetWindowText(sVal);
m_SliderDirectPathVolumeHF.SetPos(m_Props.lDirectHF);
sVal.Format("%d", m_Props.lDirectHF);
m_EditDirectPathVolumeHF.SetWindowText(sVal);
m_SliderDirectPathVolume.SetPos(m_Props.lDirect);
sVal.Format("%d", m_Props.lDirect);
m_EditDirectPathVolume.SetWindowText(sVal);
m_SliderBufferAirAbsorptionFactor.SetPos(m_Props.flAirAbsorptionFactor * 100);
sVal.Format("%.2f", m_Props.flAirAbsorptionFactor);
m_EditAirAbsorptionFactor.SetWindowText(sVal);
if((m_Props.dwFlags & EAXBUFFERFLAGS_DIRECTHFAUTO) == EAXBUFFERFLAGS_DIRECTHFAUTO)
m_CheckAutoDirectPathHF.SetCheck(1);
else
m_CheckAutoDirectPathHF.SetCheck(0);
if((m_Props.dwFlags & EAXBUFFERFLAGS_ROOMHFAUTO) == EAXBUFFERFLAGS_ROOMHFAUTO)
m_CheckAutoRoomEffectHF.SetCheck(1);
else
m_CheckAutoRoomEffectHF.SetCheck(0);
if((m_Props.dwFlags & EAXBUFFERFLAGS_ROOMAUTO) == EAXBUFFERFLAGS_ROOMAUTO)
m_CheckAutoRoomEffect.SetCheck(1);
else
m_CheckAutoRoomEffect.SetCheck(0);
}
void CEAXBuffer::OnCheckAutoDirectPathHF()
{
ISound3D* pSound3D = m_pTestDlg->m_pSound3D->GetCurrentSound();
if(pSound3D)
pSound3D->EAX()->GetProperties(m_Props);
if(m_CheckAutoDirectPathHF.GetCheck())
m_Props.dwFlags |= EAXBUFFERFLAGS_DIRECTHFAUTO;
else
m_Props.dwFlags &= ~EAXBUFFERFLAGS_DIRECTHFAUTO;
if(pSound3D)
pSound3D->EAX()->SetFlags(m_Props.dwFlags);
}
void CEAXBuffer::OnCheckAutoRoomEffectHF()
{
ISound3D* pSound3D = m_pTestDlg->m_pSound3D->GetCurrentSound();
if(pSound3D)
pSound3D->EAX()->GetProperties(m_Props);
if(m_CheckAutoRoomEffectHF.GetCheck())
m_Props.dwFlags |= EAXBUFFERFLAGS_ROOMHFAUTO;
else
m_Props.dwFlags &= ~EAXBUFFERFLAGS_ROOMHFAUTO;
if(pSound3D)
pSound3D->EAX()->SetFlags(m_Props.dwFlags);
}
void CEAXBuffer::OnCheckAutoRoomEffect()
{
ISound3D* pSound3D = m_pTestDlg->m_pSound3D->GetCurrentSound();
if(pSound3D)
pSound3D->EAX()->GetProperties(m_Props);
if(m_CheckAutoRoomEffect.GetCheck())
m_Props.dwFlags |= EAXBUFFERFLAGS_ROOMAUTO;
else
m_Props.dwFlags &= ~EAXBUFFERFLAGS_ROOMAUTO;
if(pSound3D)
pSound3D->EAX()->SetFlags(m_Props.dwFlags);
}