home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************\
- Copyright (C) James Boer, 2002.
- All rights reserved worldwide.
-
- This software is provided "as is" without express or implied
- warranties. You may freely copy and compile this source into
- applications you distribute provided that the copyright text
- below is included in the resulting source code, for example:
- "Portions Copyright (C) James Boer, 2002"
- \***********************************************************/
-
- #include "stdafx.h"
- #include "audiotest.h"
- #include "Listener.h"
- #include "EAXListener.h"
-
- #include "AudioTestDlg.h"
- #include "System.h"
- #include "Sound2D.h"
- #include "Sound3D.h"
- #include "Segment.h"
-
- using namespace Audio;
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CListener property page
-
- IMPLEMENT_DYNCREATE(CListener, CPropertyPage)
-
- CListener::CListener() : CPropertyPage(CListener::IDD)
- {
- //{{AFX_DATA_INIT(CListener)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_pListener = 0;
- }
-
- CListener::~CListener()
- {
- }
-
- void CListener::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CListener)
- DDX_Control(pDX, IDC_SLIDER_LISTENER_POSZ, m_ZPos);
- DDX_Control(pDX, IDC_SLIDER_LISTENER_POSY, m_YPos);
- DDX_Control(pDX, IDC_SLIDER_LISTENER_POSX, m_XPos);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CListener, CPropertyPage)
- //{{AFX_MSG_MAP(CListener)
- ON_WM_DESTROY()
- ON_BN_CLICKED(IDC_LISTENER_EAX, OnListenerEAX)
- ON_WM_HSCROLL()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CListener message handlers
-
-
-
- BOOL CListener::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
-
- if(AudioMgr()->IsInitialized())
- AudioMgr()->GetListener(m_pListener);
-
- m_XPos.SetRange(0, 10000, TRUE);
- m_YPos.SetRange(0, 10000, TRUE);
- m_ZPos.SetRange(0, 10000, TRUE);
- m_XPos.SetPos(5000);
- m_YPos.SetPos(5000);
- m_ZPos.SetPos(5000);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-
- void CListener::OnDestroy()
- {
- CPropertyPage::OnDestroy();
- }
-
- void CListener::OnListenerEAX()
- {
- if(!m_pTestDlg->m_pEAXListener)
- {
- m_pTestDlg->m_pEAXListener = new CEAXListener;
- m_pTestDlg->m_pEAXListener->m_pTestDlg = m_pTestDlg;
- m_pTestDlg->m_pEAXListener->Create(IDD_EAX_LISTENER, this);
- m_pTestDlg->m_pEAXListener->ShowWindow(SW_SHOW);
- }
-
- }
-
- void CListener::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- if(pScrollBar->IsKindOf(RUNTIME_CLASS(CSliderCtrl)))
- {
- CSliderCtrl* pSlider = reinterpret_cast<CSliderCtrl*>(pScrollBar);
- if(!pSlider)
- return;
- if(pSlider == &m_XPos)
- {
- AUDIOVECTOR pos;
- m_pListener->GetPosition(pos);
- pos.x = ((float(pSlider->GetPos()) - 5000.0f) / 10000.0f) * 20.0f;
- m_pListener->SetPosition(pos);
- }
- else if(pSlider == &m_YPos)
- {
- AUDIOVECTOR pos;
- m_pListener->GetPosition(pos);
- pos.y = ((float(pSlider->GetPos()) - 5000.0f) / 10000.0f) * 20.0f;
- m_pListener->SetPosition(pos);
- }
- else if(pSlider == &m_ZPos)
- {
- AUDIOVECTOR pos;
- m_pListener->GetPosition(pos);
- pos.z = ((float(pSlider->GetPos()) - 5000.0f) / 10000.0f) * 20.0f;
- m_pListener->SetPosition(pos);
- }
- }
- CPropertyPage::OnHScroll(nSBCode, nPos, pScrollBar);
- }
-