Initial commit: ROW Client source code

Game client codebase including:
- CharacterActionControl: Character and creature management
- GlobalScript: Network, items, skills, quests, utilities
- RYLClient: Main client application with GUI and event handlers
- Engine: 3D rendering engine (RYLGL)
- MemoryManager: Custom memory allocation
- Library: Third-party dependencies (DirectX, boost, etc.)
- Tools: Development utilities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-29 16:24:34 +09:00
commit e067522598
5135 changed files with 1745744 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,823 @@
//----------------------------------------------------------------------------
// File: Play3DSound.cpp
//
// Desc: Main application file for the Play3DSound sample. This sample shows how
// to load a wave file and play it using a 3D DirectSound buffer.
//
// Copyright (c) 1999-2001 Microsoft Corp. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <commctrl.h>
#include <commdlg.h>
#include <mmreg.h>
#include <mmsystem.h>
#include <dxerr8.h>
#include <dsound.h>
#include <math.h>
#include <stdio.h>
#include "resource.h"
#include "DSUtil.h"
#include "DXUtil.h"
//-----------------------------------------------------------------------------
// Function-prototypes
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
VOID OnInitDialog( HWND hDlg );
HRESULT InitDirectSound( HWND hDlg );
HRESULT FreeDirectSound();
VOID SetSlidersPos( HWND hDlg, FLOAT fDopplerValue, FLOAT fRolloffValue, FLOAT fMinDistValue, FLOAT fMaxDistValue );
VOID OnOpenSoundFile( HWND hDlg );
VOID LoadWaveFileIntoBuffer( HWND hDlg, TCHAR* strFileName );
INT_PTR CALLBACK AlgorithmDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
HRESULT OnPlaySound( HWND hDlg );
VOID OnSliderChanged( HWND hDlg );
VOID Set3DParameters( FLOAT fDopplerFactor, FLOAT fRolloffFactor, FLOAT fMinDistance, FLOAT fMaxDistance );
VOID EnablePlayUI( HWND hDlg, BOOL bEnable );
VOID OnMovementTimer( HWND hDlg );
VOID UpdateGrid( HWND hDlg, FLOAT x, FLOAT y );
VOID SetObjectProperties( D3DVECTOR* pvPosition, D3DVECTOR* pvVelocity );
FLOAT ConvertLinearSliderPosToLogScale( LONG lSliderPos );
LONG ConvertLogScaleToLinearSliderPosTo( FLOAT fValue );
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
#define ORBIT_MAX_RADIUS 5.0f
#define IDT_MOVEMENT_TIMER 1
CSoundManager* g_pSoundManager = NULL;
CSound* g_pSound = NULL;
LPDIRECTSOUND3DBUFFER g_pDS3DBuffer = NULL; // 3D sound buffer
LPDIRECTSOUND3DLISTENER g_pDSListener = NULL; // 3D listener object
DS3DBUFFER g_dsBufferParams; // 3D buffer properties
DS3DLISTENER g_dsListenerParams; // Listener properties
BOOL g_bDeferSettings = FALSE;
BOOL g_bAllowMovementTimer = TRUE;
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: Entry point for the application. Since we use a simple dialog for
// user interaction we don't need to pump messages.
//-----------------------------------------------------------------------------
INT APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine,
INT nCmdShow )
{
// Init the common control dll
InitCommonControls();
// Display the main dialog box.
DialogBox( hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDlgProc );
return TRUE;
}
//-----------------------------------------------------------------------------
// Name: MainDlgProc()
// Desc: Handles dialog messages
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
HRESULT hr;
switch( msg )
{
case WM_INITDIALOG:
OnInitDialog( hDlg );
break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDC_SOUNDFILE:
OnOpenSoundFile( hDlg );
break;
case IDCANCEL:
EndDialog( hDlg, IDCANCEL );
break;
case IDC_PLAY:
if( FAILED( hr = OnPlaySound( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnPlaySound"), hr );
MessageBox( hDlg, "Error playing DirectSound buffer."
"Sample will now exit.", "DirectSound Sample",
MB_OK | MB_ICONERROR );
EndDialog( hDlg, IDABORT );
}
break;
case IDC_STOP:
if( g_pSound )
{
g_pSound->Stop();
g_pSound->Reset();
}
// Update the UI controls to show the sound as stopped
EnablePlayUI( hDlg, TRUE );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Sound stopped.") );
break;
case IDC_DEFER:
g_bDeferSettings = !g_bDeferSettings;
OnSliderChanged( hDlg );
break;
case IDC_APPLY:
// Call the IDirectSound3DListener::CommitDeferredSettings
// method to execute all of the deferred commands at once.
// This is many times more efficent than recomputing everything
// for every call.
if( g_pDSListener )
g_pDSListener->CommitDeferredSettings();
break;
default:
return FALSE; // Didn't handle message
}
break;
case WM_TIMER:
if( wParam == IDT_MOVEMENT_TIMER )
OnMovementTimer( hDlg );
break;
case WM_NOTIFY:
OnSliderChanged( hDlg );
break;
case WM_DESTROY:
// Cleanup everything
KillTimer( hDlg, 1 );
SAFE_RELEASE( g_pDSListener );
SAFE_RELEASE( g_pDS3DBuffer );
SAFE_DELETE( g_pSound );
SAFE_DELETE( g_pSoundManager );
break;
default:
return FALSE; // Didn't handle message
}
return TRUE; // Handled message
}
//-----------------------------------------------------------------------------
// Name: OnInitDialog()
// Desc: Initializes the dialogs (sets up UI controls, etc.)
//-----------------------------------------------------------------------------
VOID OnInitDialog( HWND hDlg )
{
HRESULT hr;
// Load the icon
#ifdef _WIN64
HINSTANCE hInst = (HINSTANCE) GetWindowLongPtr( hDlg, GWLP_HINSTANCE );
#else
HINSTANCE hInst = (HINSTANCE) GetWindowLong( hDlg, GWL_HINSTANCE );
#endif
HICON hIcon = LoadIcon( hInst, MAKEINTRESOURCE( IDR_MAINFRAME ) );
// Create a static IDirectSound in the CSound class.
// Set coop level to DSSCL_PRIORITY, and set primary buffer
// format to stereo, 22kHz and 16-bit output.
g_pSoundManager = new CSoundManager();
hr = g_pSoundManager->Initialize( hDlg, DSSCL_PRIORITY, 2, 22050, 16 );
// Get the 3D listener, so we can control its params
hr |= g_pSoundManager->Get3DListenerInterface( &g_pDSListener );
if( FAILED(hr) )
{
DXTRACE_ERR( TEXT("Get3DListenerInterface"), hr );
MessageBox( hDlg, "Error initializing DirectSound. Sample will now exit.",
"DirectSound Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, IDABORT );
return;
}
// Get listener parameters
g_dsListenerParams.dwSize = sizeof(DS3DLISTENER);
g_pDSListener->GetAllParameters( &g_dsListenerParams );
// Set the icon for this dialog.
PostMessage( hDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon ); // Set big icon
PostMessage( hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon ); // Set small icon
// Create a timer to periodically move the 3D object around
SetTimer( hDlg, IDT_MOVEMENT_TIMER, 0, NULL );
// Set the UI controls
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("No file loaded.") );
// Get handles to dialog items
HWND hDopplerSlider = GetDlgItem( hDlg, IDC_DOPPLER_SLIDER );
HWND hRolloffSlider = GetDlgItem( hDlg, IDC_ROLLOFF_SLIDER );
HWND hMinDistSlider = GetDlgItem( hDlg, IDC_MINDISTANCE_SLIDER );
HWND hMaxDistSlider = GetDlgItem( hDlg, IDC_MAXDISTANCE_SLIDER );
HWND hVertSlider = GetDlgItem( hDlg, IDC_VERTICAL_SLIDER );
HWND hHorzSlider = GetDlgItem( hDlg, IDC_HORIZONTAL_SLIDER );
// Set the range and position of the sliders
PostMessage( hDopplerSlider, TBM_SETRANGEMAX, TRUE, 40L );
PostMessage( hDopplerSlider, TBM_SETRANGEMIN, TRUE, 0L );
PostMessage( hRolloffSlider, TBM_SETRANGEMAX, TRUE, 40L );
PostMessage( hRolloffSlider, TBM_SETRANGEMIN, TRUE, 0L );
PostMessage( hMinDistSlider, TBM_SETRANGEMAX, TRUE, 40L );
PostMessage( hMinDistSlider, TBM_SETRANGEMIN, TRUE, 1L );
PostMessage( hMaxDistSlider, TBM_SETRANGEMAX, TRUE, 40L );
PostMessage( hMaxDistSlider, TBM_SETRANGEMIN, TRUE, 1L );
PostMessage( hVertSlider, TBM_SETRANGEMAX, TRUE, 100L );
PostMessage( hVertSlider, TBM_SETRANGEMIN, TRUE, -100L );
PostMessage( hVertSlider, TBM_SETPOS, TRUE, 100L );
PostMessage( hHorzSlider, TBM_SETRANGEMAX, TRUE, 100L );
PostMessage( hHorzSlider, TBM_SETRANGEMIN, TRUE, -100L );
PostMessage( hHorzSlider, TBM_SETPOS, TRUE, 100L );
// Set the position of the sliders
SetSlidersPos( hDlg, 0.0f, 0.0f, ORBIT_MAX_RADIUS, ORBIT_MAX_RADIUS*2.0f );
}
//-----------------------------------------------------------------------------
// Name: SetSlidersPos()
// Desc: Sets the slider positions
//-----------------------------------------------------------------------------
VOID SetSlidersPos( HWND hDlg, FLOAT fDopplerValue, FLOAT fRolloffValue,
FLOAT fMinDistValue, FLOAT fMaxDistValue )
{
HWND hDopplerSlider = GetDlgItem( hDlg, IDC_DOPPLER_SLIDER );
HWND hRolloffSlider = GetDlgItem( hDlg, IDC_ROLLOFF_SLIDER );
HWND hMinDistSlider = GetDlgItem( hDlg, IDC_MINDISTANCE_SLIDER );
HWND hMaxDistSlider = GetDlgItem( hDlg, IDC_MAXDISTANCE_SLIDER );
LONG lDopplerSlider = ConvertLogScaleToLinearSliderPosTo( fDopplerValue );
LONG lRolloffSlider = ConvertLogScaleToLinearSliderPosTo( fRolloffValue );
LONG lMinDistSlider = ConvertLogScaleToLinearSliderPosTo( fMinDistValue );
LONG lMaxDistSlider = ConvertLogScaleToLinearSliderPosTo( fMaxDistValue );
PostMessage( hDopplerSlider, TBM_SETPOS, TRUE, lDopplerSlider );
PostMessage( hRolloffSlider, TBM_SETPOS, TRUE, lRolloffSlider );
PostMessage( hMinDistSlider, TBM_SETPOS, TRUE, lMinDistSlider );
PostMessage( hMaxDistSlider, TBM_SETPOS, TRUE, lMaxDistSlider );
}
//-----------------------------------------------------------------------------
// Name: OnOpenSoundFile()
// Desc: Called when the user requests to open a sound file
//-----------------------------------------------------------------------------
VOID OnOpenSoundFile( HWND hDlg )
{
GUID guid3DAlgorithm = GUID_NULL;
int nResult;
HRESULT hr;
static TCHAR strFileName[MAX_PATH] = TEXT("");
static TCHAR strPath[MAX_PATH] = TEXT("");
// Setup the OPENFILENAME structure
OPENFILENAME ofn = { sizeof(OPENFILENAME), hDlg, NULL,
TEXT("Wave Files\0*.wav\0All Files\0*.*\0\0"), NULL,
0, 1, strFileName, MAX_PATH, NULL, 0, strPath,
TEXT("Open Sound File"),
OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, 0, 0,
TEXT(".wav"), 0, NULL, NULL };
// Get the default media path (something like C:\WINDOWS\MEDIA)
if( '\0' == strPath[0] )
{
GetWindowsDirectory( strPath, MAX_PATH );
if( strcmp( &strPath[strlen(strPath)], TEXT("\\") ) )
strcat( strPath, TEXT("\\") );
strcat( strPath, TEXT("MEDIA") );
}
if( g_pSound )
{
g_pSound->Stop();
g_pSound->Reset();
}
// Update the UI controls to show the sound as loading a file
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), FALSE);
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), FALSE);
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Loading file...") );
// Stop the timer while dialogs are displayed
g_bAllowMovementTimer = FALSE;
// Display the OpenFileName dialog. Then, try to load the specified file
if( TRUE != GetOpenFileName( &ofn ) )
{
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Load aborted.") );
g_bAllowMovementTimer = TRUE;
return;
}
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
// Free any previous sound, and make a new one
SAFE_DELETE( g_pSound );
CWaveFile waveFile;
waveFile.Open( strFileName, NULL, WAVEFILE_READ );
WAVEFORMATEX* pwfx = waveFile.GetFormat();
if( pwfx == NULL )
{
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Invalid wave file format.") );
return;
}
if( pwfx->nChannels > 1 )
{
// Too many channels in wave. Sound must be mono when using DSBCAPS_CTRL3D
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Wave file must be mono for 3D control.") );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
return;
}
if( pwfx->wFormatTag != WAVE_FORMAT_PCM )
{
// Sound must be PCM when using DSBCAPS_CTRL3D
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Wave file must be PCM for 3D control.") );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
return;
}
// Get the software DirectSound3D emulation algorithm to use
// Ask the user for this sample, so display the algorithm dialog box.
nResult = (int)DialogBox( NULL, MAKEINTRESOURCE(IDD_3D_ALGORITHM),
NULL, AlgorithmDlgProc );
switch( nResult )
{
case -1: // User canceled dialog box
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Load aborted.") );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
return;
case 0: // User selected DS3DALG_NO_VIRTUALIZATION
guid3DAlgorithm = DS3DALG_NO_VIRTUALIZATION;
break;
case 1: // User selected DS3DALG_HRTF_FULL
guid3DAlgorithm = DS3DALG_HRTF_FULL;
break;
case 2: // User selected DS3DALG_HRTF_LIGHT
guid3DAlgorithm = DS3DALG_HRTF_LIGHT;
break;
}
// Load the wave file into a DirectSound buffer
hr = g_pSoundManager->Create( &g_pSound, strFileName, DSBCAPS_CTRL3D, guid3DAlgorithm );
if( FAILED( hr ) || hr == DS_NO_VIRTUALIZATION )
{
DXTRACE_ERR_NOMSGBOX( TEXT("Create"), hr );
if( DS_NO_VIRTUALIZATION == hr )
{
MessageBox( hDlg, "The 3D virtualization algorithm requested is not supported under this "
"operating system. It is available only on Windows 2000, Windows ME, and Windows 98 with WDM "
"drivers and beyond. Creating buffer with no virtualization.",
"DirectSound Sample", MB_OK );
}
// Unknown error, but not a critical failure, so just update the status
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Could not create sound buffer.") );
return;
}
// Get the 3D buffer from the secondary buffer
if( FAILED( hr = g_pSound->Get3DBufferInterface( 0, &g_pDS3DBuffer ) ) )
{
DXTRACE_ERR( TEXT("Get3DBufferInterface"), hr );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Could not get 3D buffer.") );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
return;
}
// Get the 3D buffer parameters
g_dsBufferParams.dwSize = sizeof(DS3DBUFFER);
g_pDS3DBuffer->GetAllParameters( &g_dsBufferParams );
// Set new 3D buffer parameters
g_dsBufferParams.dwMode = DS3DMODE_HEADRELATIVE;
g_pDS3DBuffer->SetAllParameters( &g_dsBufferParams, DS3D_IMMEDIATE );
DSBCAPS dsbcaps;
ZeroMemory( &dsbcaps, sizeof(DSBCAPS) );
dsbcaps.dwSize = sizeof(DSBCAPS);
LPDIRECTSOUNDBUFFER pDSB = g_pSound->GetBuffer( 0 );
pDSB->GetCaps( &dsbcaps );
if( ( dsbcaps.dwFlags & DSBCAPS_LOCHARDWARE ) != 0 )
SetDlgItemText( hDlg, IDC_STATUS, TEXT("File loaded using hardware mixing.") );
else
SetDlgItemText( hDlg, IDC_STATUS, TEXT("File loaded using software mixing.") );
// Update the UI controls to show the sound as the file is loaded
SetDlgItemText( hDlg, IDC_FILENAME, strFileName );
EnablePlayUI( hDlg, TRUE );
g_bAllowMovementTimer = TRUE;
// Remember the path for next time
strcpy( strPath, strFileName );
char* strLastSlash = strrchr( strPath, '\\' );
strLastSlash[0] = '\0';
// Set the slider positions
SetSlidersPos( hDlg, 0.0f, 0.0f, ORBIT_MAX_RADIUS, ORBIT_MAX_RADIUS*2.0f );
OnSliderChanged( hDlg );
}
//-----------------------------------------------------------------------------
// Name: AlgorithmDlgProc()
// Desc: Handles dialog messages
//-----------------------------------------------------------------------------
INT_PTR CALLBACK AlgorithmDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
// Default is DS3DALG_NO_VIRTUALIZATION for fastest performance
static int nDefaultRadio = IDC_NO_VIRT_RADIO;
switch( msg )
{
case WM_INITDIALOG:
// Default is DS3DALG_NO_VIRTUALIZATION for fastest performance
CheckRadioButton( hDlg, IDC_NO_VIRT_RADIO, IDC_LIGHT_VIRT_RADIO, nDefaultRadio );
return TRUE; // Message handled
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDCANCEL:
EndDialog( hDlg, -1 );
return TRUE; // Message handled
case IDOK:
if( IsDlgButtonChecked( hDlg, IDC_NO_VIRT_RADIO ) == BST_CHECKED )
{
nDefaultRadio = IDC_NO_VIRT_RADIO;
EndDialog( hDlg, 0 );
}
if( IsDlgButtonChecked( hDlg, IDC_HIGH_VIRT_RADIO ) == BST_CHECKED )
{
nDefaultRadio = IDC_HIGH_VIRT_RADIO;
EndDialog( hDlg, 1 );
}
if( IsDlgButtonChecked( hDlg, IDC_LIGHT_VIRT_RADIO ) == BST_CHECKED )
{
nDefaultRadio = IDC_LIGHT_VIRT_RADIO;
EndDialog( hDlg, 2 );
}
return TRUE; // Message handled
}
break;
}
return FALSE; // Message not handled
}
//-----------------------------------------------------------------------------
// Name: OnPlaySound()
// Desc: User hit the "Play" button
//-----------------------------------------------------------------------------
HRESULT OnPlaySound( HWND hDlg )
{
HRESULT hr;
if( NULL == g_pSound )
return E_FAIL;
// Play buffer always in looped mode just for this sample
if( FAILED( hr = g_pSound->Play( 0, DSBPLAY_LOOPING ) ) )
return DXTRACE_ERR( TEXT("Play"), hr );
// Update the UI controls to show the sound as playing
EnablePlayUI( hDlg, FALSE );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Sound playing.") );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnSliderChanged()
// Desc: Called when the dialog's slider bars are changed by the user, or need
// updating
//-----------------------------------------------------------------------------
VOID OnSliderChanged( HWND hDlg )
{
TCHAR strBuffer[10];
FLOAT fDopplerFactor;
FLOAT fRolloffFactor;
FLOAT fMinDistance;
FLOAT fMaxDistance;
// Get handles to dialog items
HWND hDopplerSlider = GetDlgItem( hDlg, IDC_DOPPLER_SLIDER );
HWND hRolloffSlider = GetDlgItem( hDlg, IDC_ROLLOFF_SLIDER );
HWND hMinDistSlider = GetDlgItem( hDlg, IDC_MINDISTANCE_SLIDER );
HWND hMaxDistSlider = GetDlgItem( hDlg, IDC_MAXDISTANCE_SLIDER );
// Get the position of the sliders
fDopplerFactor = ConvertLinearSliderPosToLogScale( (long)SendMessage( hDopplerSlider, TBM_GETPOS, 0, 0 ) );
fRolloffFactor = ConvertLinearSliderPosToLogScale( (long)SendMessage( hRolloffSlider, TBM_GETPOS, 0, 0 ) );
fMinDistance = ConvertLinearSliderPosToLogScale( (long)SendMessage( hMinDistSlider, TBM_GETPOS, 0, 0 ) );
fMaxDistance = ConvertLinearSliderPosToLogScale( (long)SendMessage( hMaxDistSlider, TBM_GETPOS, 0, 0 ) );
// Set the static text boxes
sprintf( strBuffer, TEXT("%.2f"), fDopplerFactor );
SetWindowText( GetDlgItem( hDlg, IDC_DOPPLERFACTOR ), strBuffer );
sprintf( strBuffer, TEXT("%.2f"), fRolloffFactor );
SetWindowText( GetDlgItem( hDlg, IDC_ROLLOFFFACTOR ), strBuffer );
sprintf( strBuffer, TEXT("%.2f"), fMinDistance );
SetWindowText( GetDlgItem( hDlg, IDC_MINDISTANCE ), strBuffer );
sprintf( strBuffer, TEXT("%.2f"), fMaxDistance );
SetWindowText( GetDlgItem( hDlg, IDC_MAXDISTANCE ), strBuffer );
// Set the options in the DirectSound buffer
Set3DParameters( fDopplerFactor, fRolloffFactor, fMinDistance, fMaxDistance );
EnableWindow( GetDlgItem( hDlg, IDC_APPLY ), g_bDeferSettings );
}
//-----------------------------------------------------------------------------
// Name: Set3DParameters()
// Desc: Set the 3D buffer parameters
//-----------------------------------------------------------------------------
VOID Set3DParameters( FLOAT fDopplerFactor, FLOAT fRolloffFactor,
FLOAT fMinDistance, FLOAT fMaxDistance )
{
// Every change to 3-D sound buffer and listener settings causes
// DirectSound to remix, at the expense of CPU cycles.
// To minimize the performance impact of changing 3-D settings,
// use the DS3D_DEFERRED flag in the dwApply parameter of any of
// the IDirectSound3DListener or IDirectSound3DBuffer methods that
// change 3-D settings. Then call the IDirectSound3DListener::CommitDeferredSettings
// method to execute all of the deferred commands at once.
DWORD dwApplyFlag = ( g_bDeferSettings ) ? DS3D_DEFERRED : DS3D_IMMEDIATE;
g_dsListenerParams.flDopplerFactor = fDopplerFactor;
g_dsListenerParams.flRolloffFactor = fRolloffFactor;
if( g_pDSListener )
g_pDSListener->SetAllParameters( &g_dsListenerParams, dwApplyFlag );
g_dsBufferParams.flMinDistance = fMinDistance;
g_dsBufferParams.flMaxDistance = fMaxDistance;
if( g_pDS3DBuffer )
g_pDS3DBuffer->SetAllParameters( &g_dsBufferParams, dwApplyFlag );
}
//-----------------------------------------------------------------------------
// Name: EnablePlayUI()
// Desc: Enables or disables the Play UI controls
//-----------------------------------------------------------------------------
VOID EnablePlayUI( HWND hDlg, BOOL bEnable )
{
if( bEnable )
{
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), FALSE );
SetFocus( GetDlgItem( hDlg, IDC_PLAY ) );
}
else
{
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), TRUE );
SetFocus( GetDlgItem( hDlg, IDC_STOP ) );
}
}
//-----------------------------------------------------------------------------
// Name: OnMovementTimer()
// Desc: Periodically updates the position of the object
//-----------------------------------------------------------------------------
VOID OnMovementTimer( HWND hDlg )
{
FLOAT fXScale;
FLOAT fYScale;
if( !g_bAllowMovementTimer )
return;
HWND hHorzSlider = GetDlgItem( hDlg, IDC_HORIZONTAL_SLIDER );
HWND hVertSlider = GetDlgItem( hDlg, IDC_VERTICAL_SLIDER );
fXScale = SendMessage( hHorzSlider, TBM_GETPOS, 0, 0 ) / 100.0f;
fYScale = SendMessage( hVertSlider, TBM_GETPOS, 0, 0 ) / 100.0f;
FLOAT t = timeGetTime()/1000.0f;
// Move the sound object around the listener. The maximum radius of the
// orbit is 27.5 units.
D3DVECTOR vPosition;
vPosition.x = ORBIT_MAX_RADIUS * fXScale * (FLOAT)sin(t);
vPosition.y = 0.0f;
vPosition.z = ORBIT_MAX_RADIUS * fYScale * (FLOAT)cos(t);
D3DVECTOR vVelocity;
vVelocity.x = ORBIT_MAX_RADIUS * fXScale * (FLOAT)sin(t+0.05f);
vVelocity.y = 0.0f;
vVelocity.z = ORBIT_MAX_RADIUS * fYScale * (FLOAT)cos(t+0.05f);
// Show the object's position on the dialog's grid control
UpdateGrid( hDlg, vPosition.x, vPosition.z );
// Set the sound buffer velocity and position
SetObjectProperties( &vPosition, &vVelocity );
}
//-----------------------------------------------------------------------------
// Name: UpdateGrid()
// Desc: Draws a red dot in the dialog's grid bitmap at the x,y coordinate.
//-----------------------------------------------------------------------------
VOID UpdateGrid( HWND hDlg, FLOAT x, FLOAT y )
{
static LONG s_lPixel[5] = { CLR_INVALID,CLR_INVALID,CLR_INVALID,CLR_INVALID,CLR_INVALID };
static LONG s_lX = 0;
static LONG s_lY = 0;
HWND hWndGrid = GetDlgItem( hDlg, IDC_RENDER_WINDOW );
HDC hDC = GetDC( hWndGrid );
RECT rc;
// Don't update the grid if a WM_PAINT will be called soon
BOOL bUpdateInProgress = GetUpdateRect(hDlg,NULL,FALSE);
if( bUpdateInProgress )
return;
if( s_lPixel[0] != CLR_INVALID )
{
// Replace pixels from that were overdrawn last time
SetPixel( hDC, s_lX-1, s_lY+0, s_lPixel[0] );
SetPixel( hDC, s_lX+0, s_lY-1, s_lPixel[1] );
SetPixel( hDC, s_lX+0, s_lY+0, s_lPixel[2] );
SetPixel( hDC, s_lX+0, s_lY+1, s_lPixel[3] );
SetPixel( hDC, s_lX+1, s_lY+0, s_lPixel[4] );
}
// Convert the world space x,y coordinates to pixel coordinates
GetClientRect( hWndGrid, &rc );
s_lX = (LONG)( ( x/ORBIT_MAX_RADIUS + 1 ) * ( rc.left + rc.right ) / 2 );
s_lY = (LONG)( (-y/ORBIT_MAX_RADIUS + 1 ) * ( rc.top + rc.bottom ) / 2 );
// Save the pixels before drawing the cross hair
s_lPixel[0] = GetPixel( hDC, s_lX-1, s_lY+0 );
s_lPixel[1] = GetPixel( hDC, s_lX+0, s_lY-1 );
s_lPixel[2] = GetPixel( hDC, s_lX+0, s_lY+0 );
s_lPixel[3] = GetPixel( hDC, s_lX+0, s_lY+1 );
s_lPixel[4] = GetPixel( hDC, s_lX+1, s_lY+0 );
// Draw a crosshair object in red pixels
SetPixel( hDC, s_lX-1, s_lY+0, 0x000000ff );
SetPixel( hDC, s_lX+0, s_lY-1, 0x000000ff );
SetPixel( hDC, s_lX+0, s_lY+0, 0x000000ff );
SetPixel( hDC, s_lX+0, s_lY+1, 0x000000ff );
SetPixel( hDC, s_lX+1, s_lY+0, 0x000000ff );
ReleaseDC( hWndGrid, hDC );
}
//-----------------------------------------------------------------------------
// Name: SetObjectProperties()
// Desc: Sets the position and velocity on the 3D buffer
//-----------------------------------------------------------------------------
VOID SetObjectProperties( D3DVECTOR* pvPosition, D3DVECTOR* pvVelocity )
{
// Every change to 3-D sound buffer and listener settings causes
// DirectSound to remix, at the expense of CPU cycles.
// To minimize the performance impact of changing 3-D settings,
// use the DS3D_DEFERRED flag in the dwApply parameter of any of
// the IDirectSound3DListener or IDirectSound3DBuffer methods that
// change 3-D settings. Then call the IDirectSound3DListener::CommitDeferredSettings
// method to execute all of the deferred commands at once.
memcpy( &g_dsBufferParams.vPosition, pvPosition, sizeof(D3DVECTOR) );
memcpy( &g_dsBufferParams.vVelocity, pvVelocity, sizeof(D3DVECTOR) );
if( g_pDS3DBuffer )
g_pDS3DBuffer->SetAllParameters( &g_dsBufferParams, DS3D_IMMEDIATE );
}
//-----------------------------------------------------------------------------
// Name: ConvertLinearSliderPosToLogScale()
// Desc: Converts a linear slider position to a quasi logrithmic scale
//-----------------------------------------------------------------------------
FLOAT ConvertLinearSliderPosToLogScale( LONG lSliderPos )
{
if( lSliderPos > 0 && lSliderPos <= 10 )
{
return lSliderPos*0.01f;
}
else if( lSliderPos > 10 && lSliderPos <= 20 )
{
return (lSliderPos-10)*0.1f;
}
else if( lSliderPos > 20 && lSliderPos <= 30 )
{
return (lSliderPos-20)*1.0f;
}
else if( lSliderPos > 30 && lSliderPos <= 40 )
{
return (lSliderPos-30)*10.0f;
}
return 0.0f;
}
//-----------------------------------------------------------------------------
// Name: ConvertLinearSliderPosToLogScale()
// Desc: Converts a quasi logrithmic scale to a slider position
//-----------------------------------------------------------------------------
LONG ConvertLogScaleToLinearSliderPosTo( FLOAT fValue )
{
if( fValue > 0.0f && fValue <= 0.1f )
{
return (LONG)(fValue/0.01f);
}
else if( fValue > 0.1f && fValue <= 1.0f )
{
return (LONG)(fValue/0.1f) + 10;
}
else if( fValue > 1.0f && fValue <= 10.0f )
{
return (LONG)(fValue/1.0f) + 20;
}
else if( fValue > 10.0f && fValue <= 100.0f )
{
return (LONG)(fValue/10.0f) + 30;
}
return 0;
}

View File

@@ -0,0 +1,143 @@
# Microsoft Developer Studio Project File - Name="Play3DSound" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=Play3DSound - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "play3dsound.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "play3dsound.mak" CFG="Play3DSound - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Play3DSound - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "Play3DSound - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "Play3DSound - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 comctl32.lib dxerr8.lib winmm.lib dsound.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
!ELSEIF "$(CFG)" == "Play3DSound - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 comctl32.lib dxerr8.lib winmm.lib dsound.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x200000,0x200000
!ENDIF
# Begin Target
# Name "Play3DSound - Win32 Release"
# Name "Play3DSound - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\Play3DSound.cpp
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\bitmap1.bmp
# End Source File
# Begin Source File
SOURCE=.\DirectX.ico
# End Source File
# Begin Source File
SOURCE=.\Play3DSound.rc
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# End Group
# Begin Group "Common"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\common\src\dsutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\dsutil.h
# End Source File
# Begin Source File
SOURCE=..\..\common\src\dxutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\dxutil.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\readme.txt
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "Play3DSound"=.\play3dsound.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,221 @@
# Microsoft Developer Studio Generated NMAKE File, Based on play3dsound.dsp
!IF "$(CFG)" == ""
CFG=Play3DSound - Win32 Debug
!MESSAGE No configuration specified. Defaulting to Play3DSound - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "Play3DSound - Win32 Release" && "$(CFG)" != "Play3DSound - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "play3dsound.mak" CFG="Play3DSound - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Play3DSound - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "Play3DSound - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
!IF "$(CFG)" == "Play3DSound - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\play3dsound.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\Play3DSound.obj"
-@erase "$(INTDIR)\Play3DSound.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\play3dsound.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\play3dsound.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\Play3DSound.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\play3dsound.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=comctl32.lib dxerr8.lib winmm.lib dsound.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\play3dsound.pdb" /machine:I386 /out:"$(OUTDIR)\play3dsound.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\Play3DSound.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\Play3DSound.res"
"$(OUTDIR)\play3dsound.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "Play3DSound - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\play3dsound.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\Play3DSound.obj"
-@erase "$(INTDIR)\Play3DSound.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\play3dsound.exe"
-@erase "$(OUTDIR)\play3dsound.ilk"
-@erase "$(OUTDIR)\play3dsound.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\play3dsound.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
MTL=midl.exe
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\Play3DSound.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\play3dsound.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=comctl32.lib dxerr8.lib winmm.lib dsound.lib dxguid.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\play3dsound.pdb" /debug /machine:I386 /out:"$(OUTDIR)\play3dsound.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\Play3DSound.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\Play3DSound.res"
"$(OUTDIR)\play3dsound.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("play3dsound.dep")
!INCLUDE "play3dsound.dep"
!ELSE
!MESSAGE Warning: cannot find "play3dsound.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "Play3DSound - Win32 Release" || "$(CFG)" == "Play3DSound - Win32 Debug"
SOURCE=.\Play3DSound.cpp
"$(INTDIR)\Play3DSound.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\Play3DSound.rc
"$(INTDIR)\Play3DSound.res" : $(SOURCE) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
SOURCE=..\..\common\src\dsutil.cpp
"$(INTDIR)\dsutil.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\..\common\src\dxutil.cpp
"$(INTDIR)\dxutil.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF

View File

@@ -0,0 +1,216 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "directx.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAIN DIALOGEX 0, 0, 298, 166
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Play3DSound"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "Sound &file...",IDC_SOUNDFILE,7,7,46,13
LTEXT "Static",IDC_FILENAME,68,7,223,13,SS_CENTERIMAGE,
WS_EX_CLIENTEDGE
LTEXT "Status",IDC_STATIC,7,26,42,13,SS_CENTERIMAGE
LTEXT "Static",IDC_STATUS,68,26,223,13,SS_CENTERIMAGE,
WS_EX_CLIENTEDGE
GROUPBOX "Sound properties",IDC_STATIC,7,45,200,94
LTEXT "Doppler factor",IDC_STATIC,17,60,50,13,SS_CENTERIMAGE
CTEXT "0",IDC_DOPPLERFACTOR,72,60,35,13,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CONTROL "Slider1",IDC_DOPPLER_SLIDER,"msctls_trackbar32",
TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,112,60,90,10
LTEXT "Rolloff factor",IDC_STATIC,17,75,42,13,SS_CENTERIMAGE
CTEXT "0",IDC_ROLLOFFFACTOR,72,75,35,13,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CONTROL "Slider2",IDC_ROLLOFF_SLIDER,"msctls_trackbar32",
TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,112,75,90,10
LTEXT "Min distance",IDC_STATIC,17,90,42,13,SS_CENTERIMAGE
CTEXT "0",IDC_MINDISTANCE,72,90,35,13,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CONTROL "Slider3",IDC_MINDISTANCE_SLIDER,"msctls_trackbar32",
TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,112,90,90,10
LTEXT "Max distance",IDC_STATIC,17,105,42,13,SS_CENTERIMAGE
CTEXT "0",IDC_MAXDISTANCE,72,105,35,13,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CONTROL "Slider3",IDC_MAXDISTANCE_SLIDER,"msctls_trackbar32",
TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,112,105,90,10
GROUPBOX "Sound movement",IDC_STATIC,212,45,75,94,BS_LEFT
CONTROL 130,IDC_RENDER_WINDOW,"Static",SS_BITMAP,222,65,46,42,
WS_EX_CLIENTEDGE
CONTROL "Slider1",IDC_VERTICAL_SLIDER,"msctls_trackbar32",
TBS_VERT | TBS_TOP | TBS_NOTICKS | WS_TABSTOP,272,60,10,
50
CONTROL "Slider1",IDC_HORIZONTAL_SLIDER,"msctls_trackbar32",
TBS_TOP | TBS_NOTICKS | WS_TABSTOP,217,110,55,10
PUSHBUTTON "&Play",IDC_PLAY,7,145,50,14,WS_DISABLED
PUSHBUTTON "&Stop",IDC_STOP,62,145,50,14,WS_DISABLED
PUSHBUTTON "E&xit",IDCANCEL,241,145,50,14
CONTROL "Defer Settings",IDC_DEFER,"Button",BS_AUTOCHECKBOX |
BS_PUSHLIKE | WS_TABSTOP,49,121,53,11
PUSHBUTTON "Apply Settings",IDC_APPLY,121,121,53,11
END
IDD_3D_ALGORITHM DIALOG DISCARDABLE 0, 0, 307, 66
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select 3D Algorithm "
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "OK",IDOK,196,45,50,14
PUSHBUTTON "Cancel",IDCANCEL,250,45,50,14
CONTROL "&No Virtualization (WDM or VxD. CPU efficient, but basic 3-D effect)",
IDC_NO_VIRT_RADIO,"Button",BS_AUTORADIOBUTTON,7,7,226,10
CONTROL "&High Quality (WDM only. Highest quality 3D audio effect, but uses more CPU)",
IDC_HIGH_VIRT_RADIO,"Button",BS_AUTORADIOBUTTON,7,18,261,
10
CONTROL "&Light Quality (WDM only. Good 3-D audio effect, but uses less CPU than High Quality)",
IDC_LIGHT_VIRT_RADIO,"Button",BS_AUTORADIOBUTTON,7,29,
287,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 291
TOPMARGIN, 7
BOTTOMMARGIN, 159
HORZGUIDE, 139
END
IDD_3D_ALGORITHM, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 300
TOPMARGIN, 7
BOTTOMMARGIN, 59
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_GRID_BITMAP BITMAP DISCARDABLE "bitmap1.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
BEGIN
"F", IDC_SOUNDFILE, VIRTKEY, ALT, NOINVERT
"H", IDC_HIGH_VIRT_RADIO, VIRTKEY, ALT, NOINVERT
"L", IDC_LIGHT_VIRT_RADIO, VIRTKEY, ALT, NOINVERT
"N", IDC_NO_VIRT_RADIO, VIRTKEY, ALT, NOINVERT
"P", IDC_PLAY, VIRTKEY, ALT, NOINVERT
"S", IDC_STOP, VIRTKEY, ALT, NOINVERT
"X", IDCANCEL, VIRTKEY, ALT, NOINVERT
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,74 @@
//-----------------------------------------------------------------------------
//
// Sample Name: Play3DSound Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
Description
===========
The Play3DSound sample shows how to create a 3-D sound buffer and
manipulate its properties. It is similar to the 3DAudio sample but does not
use an audiopath.
Path
====
Source: DXSDK\Samples\Multimedia\DSound\Play3DSound
Executable: DXSDK\Samples\Multimedia\DSound\Bin
User's Guide
============
Click Segment File and load a wave, MIDI, or DirectMusic Producer segment
file. Play the segment. The position of the sound source is shown as a
red dot on the graph, where the x-axis is from left to right and the z-axis
is from bottom to top. Change the range of movement on the two axes by using
the sliders.
The listener is located at the center of the graph, and has its default
orientation, looking along the positive z-axis; that is, toward the top of
the screen. The sound source moves to the listener's left and right and to
the listener's front and rear, but does not move above and below the listener.
The sliders in the center of the window control the properties of the
listener; that is, the global sound properties. If you click Defer
Settings, changes are not applied until you click Apply Settings.
Programming Notes
=================
For a simpler example of how to setup a DirectSound buffer without a
3D positioning, see the PlaySound sample.
* To create a IDirectSound3DListener interface
1. Fill out a DSBUFFERDESC struct with
DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER
2. Call IDirectSound::CreateSoundBuffer passing in the DSBUFFERDESC
This will create a primary buffer with 3D control.
3. Call IDirectSoundBuffer::QueryInterface to query for the
IDirectSound3DListener
* To create a IDirectSound3DBuffer interface
1. Fill out a DSBUFFERDESC struct with
DSBCAPS_CTRL3D and the 3D virtualization guid
2. Call IDirectSound::CreateSoundBuffer passing in the DSBUFFERDESC
This will create a secondary buffer with 3D control.
3. Call IDirectSoundBuffer::QueryInterface to query for the
IDirectSound3DBuffer
* Set the position of the listener
1. Call IDirectSound3DListener::SetAllParameters passing in
a DS3DLISTENER struct. If the DS3D_DEFERRED flag is used,
then call IDirectSound3DListener::CommitDeferredSettings
when ready.
* Set the postion of the 3D buffer
1. Call IDirectSound3DBuffer::SetAllParameters passing in a
DS3DBUFFER struct. If the DS3D_DEFERRED flag is used,
then call IDirectSound3DListener::CommitDeferredSettings
when ready.

View File

@@ -0,0 +1,41 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Play3DSound.rc
//
#define IDR_MAINFRAME 128
#define IDD_MAIN 130
#define IDB_GRID_BITMAP 130
#define IDD_3D_ALGORITHM 131
#define IDR_ACCELERATOR1 132
#define IDC_PLAY 1000
#define IDC_STOP 1001
#define IDC_DOPPLER_SLIDER 1003
#define IDC_ROLLOFF_SLIDER 1004
#define IDC_MINDISTANCE_SLIDER 1005
#define IDC_MAXDISTANCE_SLIDER 1006
#define IDC_APPLY 1007
#define IDC_SOUNDFILE 1011
#define IDC_DOPPLERFACTOR 1012
#define IDC_ROLLOFFFACTOR 1013
#define IDC_MINDISTANCE 1014
#define IDC_FILENAME 1015
#define IDC_STATUS 1016
#define IDC_RENDER_WINDOW 1018
#define IDC_VERTICAL_SLIDER 1019
#define IDC_HORIZONTAL_SLIDER 1020
#define IDC_DEFER 1024
#define IDC_MAXDISTANCE 1025
#define IDC_NO_VIRT_RADIO 1025
#define IDC_HIGH_VIRT_RADIO 1026
#define IDC_LIGHT_VIRT_RADIO 1027
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 32772
#define _APS_NEXT_CONTROL_VALUE 1028
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif