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

View File

@@ -0,0 +1,173 @@
//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, 315, 257
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "AdjustSound"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "Sound &file...",IDC_SOUNDFILE,7,7,46,13
LTEXT "Static",IDC_FILENAME,57,7,251,13,SS_CENTERIMAGE,
WS_EX_CLIENTEDGE
LTEXT "Status",IDC_STATIC,7,24,42,13,SS_CENTERIMAGE
LTEXT "Static",IDC_STATUS,57,24,251,13,SS_CENTERIMAGE,
WS_EX_CLIENTEDGE
LTEXT "Frequency",IDC_STATIC,7,41,42,13,SS_CENTERIMAGE
CTEXT "0",IDC_FREQUENCY,57,41,35,13,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CTEXT "100 Hz",IDC_STATIC,96,41,25,13,SS_CENTERIMAGE
CONTROL "Slider1",IDC_FREQUENCY_SLIDER,"msctls_trackbar32",
TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,120,40,157,15
CTEXT "100 kHz",IDC_STATIC,278,41,30,13,SS_CENTERIMAGE
LTEXT "Pan",IDC_STATIC,7,59,42,13,SS_CENTERIMAGE
CTEXT "0",IDC_PAN,57,59,35,13,SS_CENTERIMAGE,WS_EX_STATICEDGE
CTEXT "Left",IDC_STATIC,106,59,15,13,SS_CENTERIMAGE
CONTROL "Slider2",IDC_PAN_SLIDER,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,120,58,157,15
CTEXT "Right",IDC_STATIC,278,58,30,13,SS_CENTERIMAGE
LTEXT "Volume",IDC_STATIC,7,75,42,13,SS_CENTERIMAGE
CTEXT "0",IDC_VOLUME,57,75,35,13,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CTEXT "Low",IDC_STATIC,106,75,15,13,SS_CENTERIMAGE
CONTROL "Slider3",IDC_VOLUME_SLIDER,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,120,74,157,15
CTEXT "High",IDC_STATIC,278,74,30,13,SS_CENTERIMAGE
LTEXT "Focus",IDC_STATIC,12,99,20,8
CONTROL "Normal",IDC_FOCUS_NORMAL,"Button",BS_AUTORADIOBUTTON,82,
98,38,10
CONTROL "Sticky",IDC_FOCUS_STICKY,"Button",BS_AUTORADIOBUTTON,
131,98,35,10
CONTROL "Global",IDC_FOCUS_GLOBAL,"Button",BS_AUTORADIOBUTTON,
177,98,36,10
LTEXT "Buffer Mixing",IDC_STATIC,12,110,42,8
CONTROL "Default",IDC_MIX_DEFAULT,"Button",BS_AUTORADIOBUTTON,82,
109,39,10
CONTROL "Hardware",IDC_MIX_HARDWARE,"Button",BS_AUTORADIOBUTTON,
131,109,47,10
CONTROL "Software",IDC_MIX_SOFTWARE,"Button",BS_AUTORADIOBUTTON,
177,109,44,10
CONTROL "&Loop sound",IDC_LOOP_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,224,53,10
PUSHBUTTON "&Play",IDC_PLAY,7,236,50,14,WS_DISABLED
PUSHBUTTON "&Stop",IDC_STOP,62,236,50,14,WS_DISABLED
PUSHBUTTON "E&xit",IDCANCEL,258,236,50,14
GROUPBOX "Expected Behavior",IDC_STATIC,7,126,301,94
LTEXT "Static",IDC_BEHAVIOR,13,136,288,77
GROUPBOX "Buffer Settings",IDC_STATIC,7,89,301,36
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 308
TOPMARGIN, 7
BOTTOMMARGIN, 250
END
END
#endif // APSTUDIO_INVOKED
#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,603 @@
//----------------------------------------------------------------------------
// File: AdjustSound.cpp
//
// Desc: AdjustSound sample sample shows how to load and play a wave file using
// a DirectSound buffer and adjust its focus, frequency, pan, and volume.
//
// Copyright (c) 1999-2001 Microsoft Corp. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <mmsystem.h>
#include <mmreg.h>
#include <dxerr8.h>
#include <dsound.h>
#include <commctrl.h>
#include <commdlg.h>
#include <dsound.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 );
VOID OnTimer( HWND hDlg );
VOID OnOpenSoundFile( HWND hDlg );
VOID ValidateWaveFile( HWND hDlg, TCHAR* strFileName );
HRESULT OnPlaySound( HWND hDlg );
HRESULT CreateAndFillBuffer( HWND hDlg, DWORD dwCreationFlags );
VOID UpdateBehaviorText( HWND hDlg );
VOID OnSliderChanged( HWND hDlg );
VOID SetBufferOptions( LONG lFrequency, LONG lPan, LONG lVolume );
VOID EnablePlayUI( HWND hDlg, BOOL bEnable );
VOID SetSlidersPos( HWND hDlg, LONG lFreqSlider, LONG lPanSlider, LONG lVolumeSlider );
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
TCHAR m_strWaveFileName[MAX_PATH];
CSoundManager* g_pSoundManager = NULL;
CSound* g_pSound = NULL;
//-----------------------------------------------------------------------------
// 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_COMMAND:
switch( LOWORD(wParam) )
{
case IDCANCEL:
EndDialog( hDlg, IDCANCEL );
break;
case IDC_SOUNDFILE:
OnOpenSoundFile( hDlg );
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();
}
break;
case IDC_MIX_DEFAULT:
case IDC_MIX_HARDWARE:
case IDC_MIX_SOFTWARE:
case IDC_FOCUS_GLOBAL:
case IDC_FOCUS_STICKY:
case IDC_FOCUS_NORMAL:
UpdateBehaviorText( hDlg );
break;
default:
return FALSE; // Didn't handle message
}
break;
case WM_TIMER:
OnTimer( hDlg );
break;
case WM_INITDIALOG:
OnInitDialog( hDlg );
break;
case WM_NOTIFY:
OnSliderChanged( hDlg );
break;
case WM_DESTROY:
// Cleanup everything
KillTimer( hDlg, 1 );
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();
if( FAILED( hr = g_pSoundManager->Initialize( hDlg, DSSCL_PRIORITY, 2, 22050, 16 ) ) )
{
DXTRACE_ERR( TEXT("Initialize"), hr );
MessageBox( hDlg, "Error initializing DirectSound. Sample will now exit.",
"DirectSound Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, IDABORT );
return;
}
// 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, so we can check for when the soundbuffer is stopped
SetTimer( hDlg, 0, 250, NULL );
// Get handles to dialog items
HWND hFreqSlider = GetDlgItem( hDlg, IDC_FREQUENCY_SLIDER );
HWND hPanSlider = GetDlgItem( hDlg, IDC_PAN_SLIDER );
HWND hVolumeSlider = GetDlgItem( hDlg, IDC_VOLUME_SLIDER );
// Set the focus to normal by default
CheckRadioButton( hDlg, IDC_FOCUS_NORMAL, IDC_FOCUS_NORMAL, IDC_FOCUS_NORMAL );
// Set the buffer mixing to default
CheckRadioButton( hDlg, IDC_MIX_DEFAULT, IDC_MIX_SOFTWARE, IDC_MIX_DEFAULT );
// Set the range and position of the freq slider from
// DSBFREQUENCY_MIN and DSBFREQUENCY_MAX are DirectSound constants
PostMessage( hFreqSlider, TBM_SETRANGEMAX, TRUE, DSBFREQUENCY_MAX );
PostMessage( hFreqSlider, TBM_SETRANGEMIN, TRUE, DSBFREQUENCY_MIN );
// Set the range and position of the pan slider from
PostMessage( hPanSlider, TBM_SETRANGEMAX, TRUE, ( 10000L/500L) );
PostMessage( hPanSlider, TBM_SETRANGEMIN, TRUE, (-10000L/500L) );
// Set the range and position of the volume slider
PostMessage( hVolumeSlider, TBM_SETRANGEMAX, TRUE, 0L );
PostMessage( hVolumeSlider, TBM_SETRANGEMIN, TRUE, (-5000L/100L) );
// Set the position of the sliders
SetSlidersPos( hDlg, DSBFREQUENCY_MIN, 0, 0 );
// Set the UI controls
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("No file loaded.") );
UpdateBehaviorText( hDlg );
}
//-----------------------------------------------------------------------------
// Name: OnOpenSoundFile()
// Desc: Called when the user requests to open a sound file
//-----------------------------------------------------------------------------
VOID OnOpenSoundFile( HWND hDlg )
{
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") );
}
// 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...") );
if( g_pSound )
{
g_pSound->Stop();
g_pSound->Reset();
}
// Display the OpenFileName dialog. Then, try to load the specified file
if( TRUE != GetOpenFileName( &ofn ) )
{
if( g_pSound )
{
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), TRUE );
}
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Load aborted.") );
return;
}
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
// Make sure wave file is a valid wav file
ValidateWaveFile( hDlg, strFileName );
// Remember the path for next time
strcpy( strPath, strFileName );
char* strLastSlash = strrchr( strPath, '\\' );
strLastSlash[0] = '\0';
}
//-----------------------------------------------------------------------------
// Name: ValidateWaveFile()
// Desc: Open the wave file with the helper
// class CWaveFile to make sure it is valid
//-----------------------------------------------------------------------------
VOID ValidateWaveFile( HWND hDlg, TCHAR* strFileName )
{
HRESULT hr;
CWaveFile waveFile;
// Load the wave file
if( FAILED( hr = waveFile.Open( strFileName, NULL, WAVEFILE_READ ) ) )
{
DXTRACE_ERR( TEXT("Open"), hr );
waveFile.Close();
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Bad wave file.") );
}
else // The load call succeeded
{
// Update the UI controls to show the sound as the file is loaded
waveFile.Close();
EnablePlayUI( hDlg, TRUE );
SetDlgItemText( hDlg, IDC_FILENAME, strFileName );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("File loaded.") );
strcpy( m_strWaveFileName, strFileName );
// Get the samples per sec from the wave file
DWORD dwSamplesPerSec = waveFile.m_pwfx->nSamplesPerSec;
// Set the slider positions
SetSlidersPos( hDlg, dwSamplesPerSec, 0, 0 );
}
}
//-----------------------------------------------------------------------------
// Name: OnPlaySound()
// Desc: User hit the "Play" button
//-----------------------------------------------------------------------------
HRESULT OnPlaySound( HWND hDlg )
{
HRESULT hr;
DWORD dwCreationFlags;
BOOL bLooped = ( IsDlgButtonChecked( hDlg, IDC_LOOP_CHECK ) == BST_CHECKED );
BOOL bFocusSticky = ( IsDlgButtonChecked( hDlg, IDC_FOCUS_STICKY ) == BST_CHECKED );
BOOL bFocusGlobal = ( IsDlgButtonChecked( hDlg, IDC_FOCUS_GLOBAL ) == BST_CHECKED );
BOOL bMixHardware = ( IsDlgButtonChecked( hDlg, IDC_MIX_HARDWARE ) == BST_CHECKED );
BOOL bMixSoftware = ( IsDlgButtonChecked( hDlg, IDC_MIX_SOFTWARE ) == BST_CHECKED );
// Detrimine the creation flags to use based on the radio buttons
dwCreationFlags = 0;
if( bFocusGlobal )
dwCreationFlags |= DSBCAPS_GLOBALFOCUS;
if( bFocusSticky )
dwCreationFlags |= DSBCAPS_STICKYFOCUS;
if( bMixHardware )
dwCreationFlags |= DSBCAPS_LOCHARDWARE;
if( bMixSoftware )
dwCreationFlags |= DSBCAPS_LOCSOFTWARE;
// Add extra flags needed for the UI
dwCreationFlags |= DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY;
// Free any previous sound
SAFE_DELETE( g_pSound );
// Since the user can change the focus before the sound is played,
// we need to create the sound buffer every time the play button is pressed
// Load the wave file into a DirectSound buffer
if( FAILED( hr = g_pSoundManager->Create( &g_pSound, m_strWaveFileName, dwCreationFlags, GUID_NULL ) ) )
{
// Not a critical failure, so just update the status
DXTRACE_ERR_NOMSGBOX( TEXT("Create"), hr );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Could not create sound buffer.") );
return S_FALSE;
}
// Set the buffer options to what the sliders are set to
OnSliderChanged( hDlg );
// Only if the sound buffer was created perfectly should we update the UI
// and play the sound
// Play the sound
DWORD dwLooped = bLooped ? DSBPLAY_LOOPING : 0L;
if( FAILED( hr = g_pSound->Play( 0, dwLooped ) ) )
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: OnTimer()
// Desc: When we think the sound is playing this periodically checks to see if
// the sound has stopped. If it has then updates the dialog.
//-----------------------------------------------------------------------------
VOID OnTimer( HWND hDlg )
{
if( IsWindowEnabled( GetDlgItem( hDlg, IDC_STOP ) ) )
{
// We think the sound is playing, so see if it has stopped yet.
if( !g_pSound->IsSoundPlaying() )
{
// Update the UI controls to show the sound as stopped
EnablePlayUI( hDlg, TRUE );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Sound stopped.") );
}
}
}
//-----------------------------------------------------------------------------
// 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];
// Get handles to dialog items
HWND hFreqSlider = GetDlgItem( hDlg, IDC_FREQUENCY_SLIDER );
HWND hPanSlider = GetDlgItem( hDlg, IDC_PAN_SLIDER );
HWND hVolumeSlider = GetDlgItem( hDlg, IDC_VOLUME_SLIDER );
// Get the position of the sliders
LONG lFrequency = (LONG)SendMessage( hFreqSlider, TBM_GETPOS, 0, 0 ) * 1L;
LONG lPan = (LONG)SendMessage( hPanSlider, TBM_GETPOS, 0, 0 ) * 500L;
LONG lVolume = (LONG)SendMessage( hVolumeSlider, TBM_GETPOS, 0, 0 ) * 100L;
// Set the static text boxes
wsprintf( strBuffer, TEXT("%ld"), lFrequency );
SetWindowText( GetDlgItem( hDlg, IDC_FREQUENCY ), strBuffer );
wsprintf( strBuffer, TEXT("%ld"), lPan );
SetWindowText( GetDlgItem( hDlg, IDC_PAN ), strBuffer );
wsprintf( strBuffer, TEXT("%ld"), lVolume );
SetWindowText( GetDlgItem( hDlg, IDC_VOLUME ), strBuffer );
// Set the options in the DirectSound buffer
if( g_pSound )
{
LPDIRECTSOUNDBUFFER pDSB = g_pSound->GetBuffer( 0 );
if( pDSB )
{
pDSB->SetFrequency( lFrequency );
pDSB->SetPan( lPan );
pDSB->SetVolume( lVolume );
}
}
}
//-----------------------------------------------------------------------------
// Name: UpdateBehaviorText()
// Desc: Figure out what the expected behavoir is based on the dialog,
// and display it on the dialog
//-----------------------------------------------------------------------------
VOID UpdateBehaviorText( HWND hDlg )
{
TCHAR strExcepted[1024];
BOOL bLooped = ( IsDlgButtonChecked( hDlg, IDC_LOOP_CHECK ) == BST_CHECKED );
BOOL bFocusSticky = ( IsDlgButtonChecked( hDlg, IDC_FOCUS_STICKY ) == BST_CHECKED );
BOOL bFocusGlobal = ( IsDlgButtonChecked( hDlg, IDC_FOCUS_GLOBAL ) == BST_CHECKED );
BOOL bMixHardware = ( IsDlgButtonChecked( hDlg, IDC_MIX_HARDWARE ) == BST_CHECKED );
BOOL bMixSoftware = ( IsDlgButtonChecked( hDlg, IDC_MIX_SOFTWARE ) == BST_CHECKED );
// Figure what the user should expect based on the dialog choice
if( bFocusSticky )
{
strcpy( strExcepted, "Buffers with \"sticky\" focus will continue to play "
"if the user switches to another application not using "
"DirectSound. However, if the user switches to another "
"DirectSound application, all normal-focus and sticky-focus "
"buffers in the previous application are muted." );
}
else if( bFocusGlobal )
{
strcpy( strExcepted, "Buffers with global focus will continue to play if the user "
"switches focus to another application, even if the new application "
"uses DirectSound. The one exception is if you switch focus to a "
"DirectSound application that uses the DSSCL_WRITEPRIMARY "
"cooperative level. In this case, the global-focus buffers from "
"other applications will not be audible." );
}
else
{
// Normal focus
strcpy( strExcepted, "Buffers with normal focus will mute if the user switches "
"focus to any other application" );
}
if( bMixHardware )
{
strcat( strExcepted, "\n\nWith the hardware mixing flag, the new buffer will "
"be forced to use hardware mixing. If the device does "
"not support hardware mixing or if the required "
"hardware resources are not available, the call to the "
"IDirectSound::CreateSoundBuffer method will fail." );
}
else if( bMixSoftware )
{
strcat( strExcepted, "\n\nWith the software mixing flag, the new buffer will use "
"software mixing, even if hardware resources are available." );
}
else
{
// Default mixing
strcat( strExcepted, "\n\nWith default mixing, the new buffer will use hardware "
"mixing if available, otherwise software mixing will be used." );
}
// Tell the user what to expect
SetDlgItemText( hDlg, IDC_BEHAVIOR, strExcepted );
}
//-----------------------------------------------------------------------------
// Name: EnablePlayUI()
// Desc: Enables or disables the Play UI controls
//-----------------------------------------------------------------------------
VOID EnablePlayUI( HWND hDlg, BOOL bEnable )
{
if( bEnable )
{
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_FOCUS_NORMAL ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_FOCUS_STICKY ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_FOCUS_GLOBAL ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_MIX_DEFAULT ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_MIX_HARDWARE ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_MIX_SOFTWARE ), TRUE );
SetFocus( GetDlgItem( hDlg, IDC_PLAY ) );
}
else
{
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_FOCUS_NORMAL ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_FOCUS_STICKY ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_FOCUS_GLOBAL ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_MIX_DEFAULT ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_MIX_HARDWARE ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_MIX_SOFTWARE ), FALSE );
SetFocus( GetDlgItem( hDlg, IDC_STOP ) );
}
}
//-----------------------------------------------------------------------------
// Name: SetSlidersPos()
// Desc: Sets the slider positions
//-----------------------------------------------------------------------------
VOID SetSlidersPos( HWND hDlg, LONG lFreqSlider, LONG lPanSlider, LONG lVolumeSlider )
{
HWND hFreqSlider = GetDlgItem( hDlg, IDC_FREQUENCY_SLIDER );
HWND hPanSlider = GetDlgItem( hDlg, IDC_PAN_SLIDER );
HWND hVolumeSlider = GetDlgItem( hDlg, IDC_VOLUME_SLIDER );
PostMessage( hFreqSlider, TBM_SETPOS, TRUE, lFreqSlider );
PostMessage( hPanSlider, TBM_SETPOS, TRUE, lPanSlider );
PostMessage( hVolumeSlider, TBM_SETPOS, TRUE, lVolumeSlider );
}

View File

@@ -0,0 +1,143 @@
# Microsoft Developer Studio Project File - Name="AdjustSound" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=AdjustSound - 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 "adjustsound.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 "adjustsound.mak" CFG="AdjustSound - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "AdjustSound - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "AdjustSound - 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)" == "AdjustSound - 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)" == "AdjustSound - 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 "AdjustSound - Win32 Release"
# Name "AdjustSound - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\adjustsound.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=.\AdjustSound.rc
# End Source File
# Begin Source File
SOURCE=.\directx.ico
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\winmain.ico
# 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: "AdjustSound"=.\adjustsound.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 adjustsound.dsp
!IF "$(CFG)" == ""
CFG=AdjustSound - Win32 Debug
!MESSAGE No configuration specified. Defaulting to AdjustSound - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "AdjustSound - Win32 Release" && "$(CFG)" != "AdjustSound - 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 "adjustsound.mak" CFG="AdjustSound - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "AdjustSound - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "AdjustSound - 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)" == "AdjustSound - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\adjustsound.exe"
CLEAN :
-@erase "$(INTDIR)\adjustsound.obj"
-@erase "$(INTDIR)\AdjustSound.res"
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\adjustsound.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)\adjustsound.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)\AdjustSound.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\adjustsound.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)\adjustsound.pdb" /machine:I386 /out:"$(OUTDIR)\adjustsound.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\adjustsound.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\AdjustSound.res"
"$(OUTDIR)\adjustsound.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "AdjustSound - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\adjustsound.exe"
CLEAN :
-@erase "$(INTDIR)\adjustsound.obj"
-@erase "$(INTDIR)\AdjustSound.res"
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\adjustsound.exe"
-@erase "$(OUTDIR)\adjustsound.ilk"
-@erase "$(OUTDIR)\adjustsound.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)\adjustsound.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)\AdjustSound.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\adjustsound.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)\adjustsound.pdb" /debug /machine:I386 /out:"$(OUTDIR)\adjustsound.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\adjustsound.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\AdjustSound.res"
"$(OUTDIR)\adjustsound.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("adjustsound.dep")
!INCLUDE "adjustsound.dep"
!ELSE
!MESSAGE Warning: cannot find "adjustsound.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "AdjustSound - Win32 Release" || "$(CFG)" == "AdjustSound - Win32 Debug"
SOURCE=.\adjustsound.cpp
"$(INTDIR)\adjustsound.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\AdjustSound.rc
"$(INTDIR)\AdjustSound.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,50 @@
//-----------------------------------------------------------------------------
//
// Sample Name: AdjustSound Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
Description
===========
AdjustSound sample shows how to load and play a wave file using
a DirectSound buffer and adjust its focus, frequency, pan, and volume.
Path
====
Source: DXSDK\Samples\Multimedia\DSound\AdjustSound
Executable: DXSDK\Samples\Multimedia\DSound\Bin
User's Guide
============
Load a wave file by clicking Sound File. Select Focus and Buffer Mixing
options; note that the various settings are explained under Expected Behavior
as you select them. Click Play. If you don't hear any sound, check the Status
pane. The application might fail to create the buffer in hardware if this
option has been selected.
By using the sliders you can adjust the frequency, pan, and volume dynamically
as the buffer is playing.
Programming Notes
=================
For a simpler example of how to setup a DirectSound buffer without as many
controls, see the PlaySound sample.
To set the focus of a buffer call IDirectSound::CreateSoundBuffer with
DSBCAPS_GLOBALFOCUS or DSBCAPS_STICKYFOCUS or neither of these flags.
To set the memory location of a buffer call IDirectSound::CreateSoundBuffer
with DSBCAPS_LOCHARDWARE or DSBCAPS_LOCSOFTWARE or neither of these flags.
To control various aspects of DirectSound buffer:
To adjust the frequency call IDirectSoundBuffer::SetFrequency
To adjust the pan call IDirectSoundBuffer::SetPan
To adjust the volume call IDirectSoundBuffer::SetVolume

View File

@@ -0,0 +1,40 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by AdjustSound.rc
//
#define IDR_MAINFRAME 128
#define IDD_MAIN 130
#define IDR_ACCELERATOR1 131
#define IDC_PLAY 1000
#define IDC_STOP 1001
#define IDC_FREQUENCY_SLIDER 1003
#define IDC_PAN_SLIDER 1004
#define IDC_VOLUME_SLIDER 1005
#define IDC_LOOP_CHECK 1009
#define IDC_SOUNDFILE 1011
#define IDC_FREQUENCY 1012
#define IDC_PAN 1013
#define IDC_VOLUME 1014
#define IDC_FILENAME 1015
#define IDC_STATUS 1016
#define IDC_FOCUS_NORMAL 1019
#define IDC_FOCUS_STICKY 1020
#define IDC_FOCUS_GLOBAL 1021
#define IDC_MEMORY_DEFAULT 1022
#define IDC_MIX_DEFAULT 1022
#define IDC_MEMORY_HARDWARE 1023
#define IDC_MIX_HARDWARE 1023
#define IDC_MEMORY_SOFTWARE 1024
#define IDC_MIX_SOFTWARE 1024
#define IDC_BEHAVIOR 1033
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 134
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1022
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,516 @@
//----------------------------------------------------------------------------
// File: AmplitudeModulation.cpp
//
// Desc: AmplitudeModulation sample shows how to create an effect buffer and
// adjust amplitude modulation parameters.
//
// Copyright (c) 1999-2001 Microsoft Corp. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <mmsystem.h>
#include <mmreg.h>
#include <dxerr8.h>
#include <dsound.h>
#include <cguid.h>
#include <commctrl.h>
#include <commdlg.h>
#include <dsound.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 );
VOID OnTimer( HWND hDlg );
VOID OnOpenSoundFile( HWND hDlg );
HRESULT ValidateWaveFile( HWND hDlg, TCHAR* strFileName );
HRESULT OnPlaySound( HWND hDlg );
HRESULT CreateAndFillBuffer( HWND hDlg, DWORD dwCreationFlags );
VOID OnEffectChanged( HWND hDlg );
VOID SetBufferOptions( LONG lFrequency, LONG lPan, LONG lVolume );
VOID EnablePlayUI( HWND hDlg, BOOL bEnable );
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
#define DSFX_GARGLE_RATEHZ_MAX 1000
#define DSFX_GARGLE_RATEHZ_MIN 1
TCHAR g_strWaveFileName[MAX_PATH];
CSoundManager* g_pSoundManager = NULL;
CSound* g_pSound = NULL;
LPDIRECTSOUNDFXGARGLE g_pIGargle = NULL;
HINSTANCE g_hInst = NULL;
//-----------------------------------------------------------------------------
// 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 )
{
g_hInst = hInst;
CoInitialize( NULL );
// Init the common control dll
InitCommonControls();
// Display the main dialog box.
DialogBox( hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDlgProc );
CoUninitialize();
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_COMMAND:
switch( LOWORD(wParam) )
{
case IDCANCEL:
EndDialog( hDlg, IDCANCEL );
break;
case IDC_SOUNDFILE:
OnOpenSoundFile( hDlg );
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:
SAFE_RELEASE( g_pIGargle );
if( g_pSound )
{
g_pSound->Stop();
g_pSound->Reset();
}
break;
case IDC_WAVEFORM_TRIANGLE:
case IDC_WAVEFORM_SQUARE:
OnEffectChanged( hDlg );
break;
default:
return FALSE; // Didn't handle message
}
break;
case WM_TIMER:
OnTimer( hDlg );
break;
case WM_INITDIALOG:
OnInitDialog( hDlg );
break;
case WM_NOTIFY:
OnEffectChanged( hDlg );
break;
case WM_DESTROY:
// Cleanup everything
KillTimer( hDlg, 1 );
SAFE_RELEASE( g_pIGargle );
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
HICON hIcon = LoadIcon( g_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();
if( FAILED( hr = g_pSoundManager->Initialize( hDlg, DSSCL_PRIORITY, 2, 22050, 16 ) ) )
{
DXTRACE_ERR( TEXT("Initialize"), hr );
MessageBox( hDlg, "Error initializing DirectSound. Sample will now exit.",
"DirectSound Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, IDABORT );
return;
}
// 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, so we can check for when the soundbuffer is stopped
SetTimer( hDlg, 0, 250, NULL );
// Get handles to dialog items
HWND hFreqSlider = GetDlgItem( hDlg, IDC_FREQUENCY_SLIDER );
// Set UI defaults
CheckDlgButton( hDlg, IDC_LOOP_CHECK, BST_CHECKED );
CheckRadioButton( hDlg, IDC_WAVEFORM_TRIANGLE, IDC_WAVEFORM_TRIANGLE, IDC_WAVEFORM_TRIANGLE );
// Set the range and position of the freq slider from
// DSBFREQUENCY_MIN and DSBFREQUENCY_MAX are DirectSound constants
PostMessage( hFreqSlider, TBM_SETRANGEMAX, TRUE, DSFX_GARGLE_RATEHZ_MAX );
PostMessage( hFreqSlider, TBM_SETRANGEMIN, TRUE, DSFX_GARGLE_RATEHZ_MIN );
PostMessage( hFreqSlider, TBM_SETPOS, TRUE, DSFX_GARGLE_RATEHZ_MIN );
// Load default wave file
TCHAR strFile[MAX_PATH];
GetWindowsDirectory( strFile, MAX_PATH );
lstrcat( strFile, "\\media\\ding.wav" );
if( FAILED( hr = ValidateWaveFile( hDlg, strFile ) ) )
{
// Set the UI controls
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("No file loaded.") );
}
}
//-----------------------------------------------------------------------------
// Name: OnOpenSoundFile()
// Desc: Called when the user requests to open a sound file
//-----------------------------------------------------------------------------
VOID OnOpenSoundFile( HWND hDlg )
{
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") );
}
// 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...") );
SAFE_RELEASE( g_pIGargle );
if( g_pSound )
{
g_pSound->Stop();
g_pSound->Reset();
}
// Display the OpenFileName dialog. Then, try to load the specified file
if( TRUE != GetOpenFileName( &ofn ) )
{
if( g_pSound )
{
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), TRUE );
}
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Load aborted.") );
return;
}
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
// Make sure wave file is a valid wav file
ValidateWaveFile( hDlg, strFileName );
// Remember the path for next time
strcpy( strPath, strFileName );
char* strLastSlash = strrchr( strPath, '\\' );
strLastSlash[0] = '\0';
}
//-----------------------------------------------------------------------------
// Name: ValidateWaveFile()
// Desc: Open the wave file with the helper
// class CWaveFile to make sure it is valid
//-----------------------------------------------------------------------------
HRESULT ValidateWaveFile( HWND hDlg, TCHAR* strFileName )
{
HRESULT hr;
CWaveFile waveFile;
if( -1 == GetFileAttributes(strFileName) )
return E_FAIL;
// Load the wave file
if( FAILED( hr = waveFile.Open( strFileName, NULL, WAVEFILE_READ ) ) )
{
waveFile.Close();
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Bad wave file.") );
return DXTRACE_ERR( TEXT("Open"), hr );
}
else // The load call succeeded
{
WAVEFORMATEX* pwfx = waveFile.GetFormat();
if( pwfx->wFormatTag != WAVE_FORMAT_PCM )
{
// Sound must be PCM when using DSBCAPS_CTRLFX
SAFE_RELEASE( g_pIGargle );
SAFE_DELETE( g_pSound );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Wave file must be PCM for effects control.") );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
return S_FALSE;
}
// Update the UI controls to show the sound as the file is loaded
waveFile.Close();
EnablePlayUI( hDlg, TRUE );
SetDlgItemText( hDlg, IDC_FILENAME, strFileName );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("File loaded.") );
strcpy( g_strWaveFileName, strFileName );
// Get the samples per sec from the wave file
DWORD dwSamplesPerSec = waveFile.m_pwfx->nSamplesPerSec;
return S_OK;
}
}
//-----------------------------------------------------------------------------
// Name: OnPlaySound()
// Desc: User hit the "Play" button
//-----------------------------------------------------------------------------
HRESULT OnPlaySound( HWND hDlg )
{
HRESULT hr;
DWORD dwCreationFlags;
DWORD dwResults;
LPDIRECTSOUNDBUFFER pDSB = NULL;
LPDIRECTSOUNDBUFFER8 pDSB8 = NULL;
BOOL bLooped = ( IsDlgButtonChecked( hDlg, IDC_LOOP_CHECK ) == BST_CHECKED );
// We would only use CTRLFX control on dsound buffer
dwCreationFlags = DSBCAPS_CTRLFX;
// Free any previous sound and FXs
SAFE_RELEASE( g_pIGargle );
SAFE_DELETE( g_pSound );
// Since the user can change the focus before the sound is played,
// we need to create the sound buffer every time the play button is pressed
// Load the wave file into a DirectSound buffer
if( FAILED( hr = g_pSoundManager->Create( &g_pSound, g_strWaveFileName, dwCreationFlags, GUID_NULL ) ) )
{
// Not a critical failure, so just update the status
DXTRACE_ERR_NOMSGBOX( TEXT("Create"), hr );
if( hr == DSERR_BUFFERTOOSMALL )
{
// DSERR_BUFFERTOOSMALL will be returned if the buffer is
// less than DSBSIZE_FX_MIN (100ms) and the buffer is created
// with DSBCAPS_CTRLFX.
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Wave file is too short (less than 100ms) for effect processing.") );
}
else
{
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Could not create sound buffer.") );
}
return S_FALSE;
}
// Query IDirectSoundBuffer8 interface
pDSB = g_pSound->GetBuffer( 0 );
if( FAILED( hr = pDSB->QueryInterface( IID_IDirectSoundBuffer8, (LPVOID*) &pDSB8 ) ) )
return DXTRACE_ERR( TEXT("QueryInterface"), hr );
// Set gargle effect on the IDirectSoundBuffer8
DSEFFECTDESC dsed;
ZeroMemory( &dsed, sizeof(DSEFFECTDESC) );
dsed.dwSize = sizeof(DSEFFECTDESC);
dsed.dwFlags = 0;
dsed.guidDSFXClass = GUID_DSFX_STANDARD_GARGLE;
if( FAILED( hr = pDSB8->SetFX( 1, &dsed, &dwResults ) ) )
{
// Not a critical failure, so just update the status
DXTRACE_ERR( TEXT("SetFX"), hr );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Could not set gargle effect.") );
return S_FALSE;
}
// Get gargle effect friendly interface
if( FAILED( hr = pDSB8->GetObjectInPath( GUID_DSFX_STANDARD_GARGLE, 0,
IID_IDirectSoundFXGargle,
(LPVOID*) &g_pIGargle ) ) )
return DXTRACE_ERR( TEXT("GetObjectInPath"), hr );
// Cleanup
SAFE_RELEASE( pDSB8 );
// Set the buffer options to what the sliders are set to
OnEffectChanged( hDlg );
// Play the sound
DWORD dwLooped = bLooped ? DSBPLAY_LOOPING : 0L;
if( FAILED( hr = g_pSound->Play( 0, dwLooped ) ) )
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: OnTimer()
// Desc: When we think the sound is playing this periodically checks to see if
// the sound has stopped. If it has then updates the dialog.
//-----------------------------------------------------------------------------
VOID OnTimer( HWND hDlg )
{
if( IsWindowEnabled( GetDlgItem( hDlg, IDC_STOP ) ) )
{
// We think the sound is playing, so see if it has stopped yet.
if( !g_pSound->IsSoundPlaying() )
{
// Update the UI controls to show the sound as stopped
EnablePlayUI( hDlg, TRUE );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Sound stopped.") );
}
}
}
//-----------------------------------------------------------------------------
// Name: OnEffectChanged()
// Desc: Called when the UI prompted an effect change
//-----------------------------------------------------------------------------
VOID OnEffectChanged( HWND hDlg )
{
DSFXGargle dsfxGargle;
// Get handles to dialog items
HWND hFreqSlider = GetDlgItem( hDlg, IDC_FREQUENCY_SLIDER );
// Get the position of the sliders
dsfxGargle.dwRateHz = (DWORD)SendMessage( hFreqSlider, TBM_GETPOS, 0, 0 );
// Update UI
TCHAR strBuffer[10];
wsprintf( strBuffer, TEXT("%ld"), dsfxGargle.dwRateHz );
SetDlgItemText( hDlg, IDC_FREQUENCY, strBuffer );
// Get wave form
if( IsDlgButtonChecked( hDlg, IDC_WAVEFORM_SQUARE ) == BST_CHECKED )
dsfxGargle.dwWaveShape = DSFXGARGLE_WAVE_SQUARE;
else
dsfxGargle.dwWaveShape = DSFXGARGLE_WAVE_TRIANGLE;
// Set the options in the DirectSound buffer
if( g_pSound && g_pIGargle )
{
g_pIGargle->SetAllParameters( &dsfxGargle );
}
}
//-----------------------------------------------------------------------------
// Name: EnablePlayUI()
// Desc: Enables or disables the Play UI controls
//-----------------------------------------------------------------------------
VOID EnablePlayUI( HWND hDlg, BOOL bEnable )
{
if( bEnable )
{
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), FALSE );
SetFocus( GetDlgItem( hDlg, IDC_PLAY ) );
}
else
{
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), TRUE );
SetFocus( GetDlgItem( hDlg, IDC_STOP ) );
}
}

View File

@@ -0,0 +1,143 @@
# Microsoft Developer Studio Project File - Name="AmplitudeModulation" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=AmplitudeModulation - 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 "amplitudemodulation.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 "amplitudemodulation.mak" CFG="AmplitudeModulation - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "AmplitudeModulation - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "AmplitudeModulation - 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)" == "AmplitudeModulation - 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)" == "AmplitudeModulation - 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 "AmplitudeModulation - Win32 Release"
# Name "AmplitudeModulation - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\AmplitudeModulation.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=.\AmplitudeModulation.rc
# End Source File
# Begin Source File
SOURCE=.\directx.ico
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\winmain.ico
# 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: "AmplitudeModulation"=.\amplitudemodulation.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 amplitudemodulation.dsp
!IF "$(CFG)" == ""
CFG=AmplitudeModulation - Win32 Debug
!MESSAGE No configuration specified. Defaulting to AmplitudeModulation - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "AmplitudeModulation - Win32 Release" && "$(CFG)" != "AmplitudeModulation - 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 "amplitudemodulation.mak" CFG="AmplitudeModulation - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "AmplitudeModulation - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "AmplitudeModulation - 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)" == "AmplitudeModulation - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\amplitudemodulation.exe"
CLEAN :
-@erase "$(INTDIR)\AmplitudeModulation.obj"
-@erase "$(INTDIR)\AmplitudeModulation.res"
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\amplitudemodulation.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)\amplitudemodulation.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)\AmplitudeModulation.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\amplitudemodulation.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)\amplitudemodulation.pdb" /machine:I386 /out:"$(OUTDIR)\amplitudemodulation.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\AmplitudeModulation.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\AmplitudeModulation.res"
"$(OUTDIR)\amplitudemodulation.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "AmplitudeModulation - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\amplitudemodulation.exe"
CLEAN :
-@erase "$(INTDIR)\AmplitudeModulation.obj"
-@erase "$(INTDIR)\AmplitudeModulation.res"
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\amplitudemodulation.exe"
-@erase "$(OUTDIR)\amplitudemodulation.ilk"
-@erase "$(OUTDIR)\amplitudemodulation.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)\amplitudemodulation.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)\AmplitudeModulation.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\amplitudemodulation.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)\amplitudemodulation.pdb" /debug /machine:I386 /out:"$(OUTDIR)\amplitudemodulation.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\AmplitudeModulation.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\AmplitudeModulation.res"
"$(OUTDIR)\amplitudemodulation.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("amplitudemodulation.dep")
!INCLUDE "amplitudemodulation.dep"
!ELSE
!MESSAGE Warning: cannot find "amplitudemodulation.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "AmplitudeModulation - Win32 Release" || "$(CFG)" == "AmplitudeModulation - Win32 Debug"
SOURCE=.\AmplitudeModulation.cpp
"$(INTDIR)\AmplitudeModulation.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\AmplitudeModulation.rc
"$(INTDIR)\AmplitudeModulation.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,149 @@
//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, 315, 119
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "AmplitudeModulation"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "Sound &file...",IDC_SOUNDFILE,7,7,46,13
LTEXT "Static",IDC_FILENAME,57,7,251,13,SS_CENTERIMAGE,
WS_EX_CLIENTEDGE
LTEXT "Status",IDC_STATIC,7,24,42,13,SS_CENTERIMAGE
LTEXT "Static",IDC_STATUS,57,24,251,13,SS_CENTERIMAGE,
WS_EX_CLIENTEDGE
LTEXT "Frequency",IDC_STATIC,12,49,42,13,SS_CENTERIMAGE
CTEXT "0",IDC_FREQUENCY,57,49,35,13,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CTEXT "1 Hz",IDC_STATIC,97,49,25,13,SS_CENTERIMAGE
CONTROL "Slider1",IDC_FREQUENCY_SLIDER,"msctls_trackbar32",
TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,125,48,144,15
CTEXT "1000 Hz",IDC_STATIC,268,49,30,13,SS_CENTERIMAGE
CONTROL "&Loop sound",IDC_LOOP_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,85,53,10
PUSHBUTTON "&Play",IDC_PLAY,7,97,50,14,WS_DISABLED
PUSHBUTTON "&Stop",IDC_STOP,62,97,50,14,WS_DISABLED
PUSHBUTTON "E&xit",IDCANCEL,258,97,50,14
LTEXT "Wave Form",IDC_STATIC,12,64,42,13,SS_CENTERIMAGE
CONTROL "Triangle",IDC_WAVEFORM_TRIANGLE,"Button",
BS_AUTORADIOBUTTON,82,65,44,10
CONTROL "Square",IDC_WAVEFORM_SQUARE,"Button",BS_AUTORADIOBUTTON,
125,65,49,10
GROUPBOX "Effect Runtime Settings",IDC_STATIC,7,38,301,43
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 308
TOPMARGIN, 7
BOTTOMMARGIN, 112
END
END
#endif // APSTUDIO_INVOKED
#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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,46 @@
//-----------------------------------------------------------------------------
//
// Sample Name: AmplitudeModulation Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
Description
===========
The AmplitudeModulation sample shows how to apply an effect to a
DirectSound secondary buffer and modify the parameters of the effect.
Path
====
Source: DXSDK\Samples\Multimedia\DSound\AmplitudeModulation
Executable: DXSDK\Samples\Multimedia\DSound\Bin
User's Guide
============
Play the default sound or load another wave file by clicking Sound File.
Change the parameters of the effect by selecting one of the Wave Form
options and moving the slider to change the modulation rate.
Programming Notes
=================
For a simpler example of how to setup a DirectSound buffer without a
DirectSound effect, see the PlaySound sample.
* To set an effect on a buffer
1. Make sure the buffer is created with the DSBCAPS_CTRLFX flag.
2. Fill out a DSEFFECTDESC struct setting the guidDSFXClass
to the GUID of the effect desired.
3. Call IDirectSoundBuffer8::SetFX passing in the DSEFFECTDESC struct.
4. Call IDirectSoundBuffer8::GetObjectInPath to get a interface
pointer to the effect in the buffer, such as IDirectSoundFXGargle.
* To control various parameters of the gargle effect:
1. Fill out a DSFXGargle struct with desired params
2. Call IDirectSoundFXGargle::SetAllParameters

View File

@@ -0,0 +1,28 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by AmplitudeModulation.rc
//
#define IDR_MAINFRAME 128
#define IDD_MAIN 130
#define IDC_PLAY 1000
#define IDC_STOP 1001
#define IDC_FREQUENCY_SLIDER 1003
#define IDC_LOOP_CHECK 1009
#define IDC_SOUNDFILE 1011
#define IDC_FREQUENCY 1012
#define IDC_FILENAME 1015
#define IDC_STATUS 1016
#define IDC_WAVEFORM_TRIANGLE 1026
#define IDC_WAVEFORM_SQUARE 1028
#define IDC_BEHAVIOR 1033
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 134
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1026
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,139 @@
# Microsoft Developer Studio Project File - Name="CaptureSound" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=CaptureSound - 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 "capturesound.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 "capturesound.mak" CFG="CaptureSound - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "CaptureSound - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "CaptureSound - 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)" == "CaptureSound - 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 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)" == "CaptureSound - 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 "CaptureSound - Win32 Release"
# Name "CaptureSound - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\capturesound.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=.\capturesound.rc
# End Source File
# Begin Source File
SOURCE=.\directx.ico
# 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: "CaptureSound"=.\capturesound.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 capturesound.dsp
!IF "$(CFG)" == ""
CFG=CaptureSound - Win32 Debug
!MESSAGE No configuration specified. Defaulting to CaptureSound - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "CaptureSound - Win32 Release" && "$(CFG)" != "CaptureSound - 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 "capturesound.mak" CFG="CaptureSound - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "CaptureSound - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "CaptureSound - 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)" == "CaptureSound - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\capturesound.exe"
CLEAN :
-@erase "$(INTDIR)\capturesound.obj"
-@erase "$(INTDIR)\capturesound.res"
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\capturesound.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)\capturesound.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)\capturesound.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\capturesound.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=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)\capturesound.pdb" /machine:I386 /out:"$(OUTDIR)\capturesound.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\capturesound.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\capturesound.res"
"$(OUTDIR)\capturesound.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "CaptureSound - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\capturesound.exe"
CLEAN :
-@erase "$(INTDIR)\capturesound.obj"
-@erase "$(INTDIR)\capturesound.res"
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\capturesound.exe"
-@erase "$(OUTDIR)\capturesound.ilk"
-@erase "$(OUTDIR)\capturesound.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)\capturesound.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)\capturesound.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\capturesound.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)\capturesound.pdb" /debug /machine:I386 /out:"$(OUTDIR)\capturesound.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\capturesound.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\capturesound.res"
"$(OUTDIR)\capturesound.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("capturesound.dep")
!INCLUDE "capturesound.dep"
!ELSE
!MESSAGE Warning: cannot find "capturesound.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "CaptureSound - Win32 Release" || "$(CFG)" == "CaptureSound - Win32 Debug"
SOURCE=.\capturesound.cpp
"$(INTDIR)\capturesound.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\capturesound.rc
"$(INTDIR)\capturesound.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,185 @@
//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_FORMATS DIALOG DISCARDABLE 0, 0, 122, 101
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select Capture Format"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "OK",IDOK,7,80,50,14,WS_DISABLED
PUSHBUTTON "Cancel",IDCANCEL,65,80,50,14
LISTBOX IDC_FORMATS_INPUT_LISTBOX,7,15,108,59,
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LTEXT "Input Format:",IDC_STATIC,7,7,50,8
END
IDD_MAIN DIALOGEX 0, 0, 259, 47
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "CaptureSound"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Input Format:",IDC_STATIC,7,27,50,8
LTEXT "",IDC_MAIN_INPUTFORMAT_TEXT,60,27,127,8
CONTROL "&Record",IDC_RECORD,"Button",BS_AUTOCHECKBOX |
BS_PUSHLIKE | WS_TABSTOP,202,24,50,14
DEFPUSHBUTTON "Sound &file...",IDC_SOUNDFILE,7,7,52,13
LTEXT "Static",IDC_FILENAME,62,7,190,13,SS_CENTERIMAGE,
WS_EX_CLIENTEDGE
END
IDD_DEVICES DIALOG DISCARDABLE 0, 0, 211, 47
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select Capture Device"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "OK",IDOK,7,26,50,14
PUSHBUTTON "Cancel",IDCANCEL,154,26,50,14
LTEXT "Capture Device:",IDC_STATIC,7,9,52,8
COMBOBOX IDC_CAPTURE_DEVICE_COMBO,62,7,142,49,CBS_DROPDOWNLIST |
CBS_SORT | WS_VSCROLL | WS_TABSTOP
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_FORMATS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 115
TOPMARGIN, 7
BOTTOMMARGIN, 94
END
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 252
TOPMARGIN, 7
BOTTOMMARGIN, 40
END
IDD_DEVICES, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 204
TOPMARGIN, 7
BOTTOMMARGIN, 40
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
BEGIN
"F", IDC_SOUNDFILE, VIRTKEY, ALT, NOINVERT
"R", IDC_RECORD, 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,29 @@
//-----------------------------------------------------------------------------
//
// Sample Name: CaptureSound Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
Description
===========
The CaptureSound application shows how to capture wave sounds to a file.
Path
====
Source: DXSDK\Samples\Multimedia\DSound\CaptureSound
Executable: DXSDK\Samples\Multimedia\DSound\Bin
User's Guide
============
Select a device and a format. Create a file, or replace an existing one,
by clicking Sound File. Click Record to start and stop recording.
Programming Notes
=================
This sample was intended to be very simple, showing the basics of capturing a
sound using the DirectSound API.

View File

@@ -0,0 +1,30 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by CaptureSound.rc
//
#define IDD_FORMATS 107
#define IDR_MAINFRAME 128
#define IDD_MAIN 130
#define IDR_ACCELERATOR1 133
#define IDD_DEVICES 134
#define IDC_FORMATS_OUTPUT_LISTBOX 1010
#define IDC_FORMATS_INPUT_LISTBOX 1011
#define IDC_SOUNDFILE 1011
#define IDC_CAPTURE_DEVICE_COMBO 1011
#define IDC_MAIN_INPUTFORMAT_TEXT 1013
#define IDC_MAIN_PRIMARYFORMAT_TEXT 1015
#define IDC_FILENAME 1015
#define IDC_MAIN_ENABLEFILTER_CHECK 1017
#define IDC_MAIN_SECONDARYFORMAT_TEXT 1018
#define IDC_RECORD 1019
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 135
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1021
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,275 @@
//----------------------------------------------------------------------------
// File: EnumDevices.cpp
//
// Desc: This sample shows how to enumerate DirectSound sound and capture
// devices.
//
// Copyright (c) 1999-2001 Microsoft Corp. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <commdlg.h>
#include <mmreg.h>
#include <dxerr8.h>
#include <dsound.h>
#include "resource.h"
//-----------------------------------------------------------------------------
// Function-prototypes
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
INT_PTR CALLBACK DSoundEnumCallback( GUID* pGUID, LPSTR strDesc, LPSTR strDrvName,
VOID* pContext );
HRESULT OnInitDialog( HWND hDlg );
HRESULT InitDirectSound( HWND hDlg );
HRESULT FreeDirectSound();
//-----------------------------------------------------------------------------
// Global data
//-----------------------------------------------------------------------------
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
LPDIRECTSOUND g_pDS = NULL;
LPDIRECTSOUNDCAPTURE g_pDSCapture = NULL;
//-----------------------------------------------------------------------------
// 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 )
{
// Initialize COM
CoInitialize( NULL );
// Display the main dialog box.
DialogBox( hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDlgProc );
// Release COM
CoUninitialize();
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_COMMAND:
switch( LOWORD(wParam) )
{
case IDC_CREATE:
// Init DirectSound
if( SUCCEEDED( hr = InitDirectSound( hDlg ) ) )
{
MessageBox( hDlg, TEXT("DirectSound interface created successfully"),
TEXT("EnumDevices"), MB_OK );
}
else
{
DXTRACE_ERR( TEXT("InitDirectSound"), hr );
MessageBox( hDlg, TEXT("DirectSound interface creatation failed"),
TEXT("EnumDevices"), MB_OK | MB_ICONERROR );
}
break;
case IDCANCEL:
EndDialog( hDlg, IDCANCEL );
break;
default:
return FALSE; // Didn't handle message
}
break;
case WM_INITDIALOG:
if( FAILED( hr = OnInitDialog( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnInitDialog"), hr );
MessageBox( hDlg, "Error enumerating DirectSound devices. "
"Sample will now exit.", "DirectSound Sample",
MB_OK | MB_ICONERROR );
EndDialog( hDlg, IDABORT );
}
break;
case WM_DESTROY:
// Cleanup everything
FreeDirectSound();
break;
default:
return FALSE; // Didn't handle message
}
return TRUE; // Handled message
}
//-----------------------------------------------------------------------------
// Name: OnInitDialog()
// Desc: Initializes the dialogs (sets up UI controls, etc.)
//-----------------------------------------------------------------------------
HRESULT 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 ) );
// 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
// Enumerate the sound devices and place them in the combo box
HWND hSoundDeviceCombo = GetDlgItem( hDlg, IDC_SOUND_DEVICE_COMBO );
if( FAILED( hr = DirectSoundEnumerate( (LPDSENUMCALLBACK)DSoundEnumCallback,
(VOID*)hSoundDeviceCombo ) ) )
return DXTRACE_ERR( TEXT("DirectSoundEnumerate"), hr );
// Enumerate the capture devices and place them in the combo box
HWND hCaptureDeviceCombo = GetDlgItem( hDlg, IDC_CAPTURE_DEVICE_COMBO );
if( FAILED( hr = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK)DSoundEnumCallback,
(VOID*)hCaptureDeviceCombo ) ) )
return DXTRACE_ERR( TEXT("DirectSoundCaptureEnumerate"), hr );
// Select the first device in the combo box
SendMessage( hSoundDeviceCombo, CB_SETCURSEL, 0, 0 );
SendMessage( hCaptureDeviceCombo, CB_SETCURSEL, 0, 0 );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DSoundEnumCallback()
// Desc: Enumeration callback called by DirectSoundEnumerate
//-----------------------------------------------------------------------------
INT_PTR CALLBACK DSoundEnumCallback( GUID* pGUID, LPSTR strDesc, LPSTR strDrvName,
VOID* pContext )
{
// Set aside static storage space for 20 audio drivers
static GUID AudioDriverGUIDs[20];
static DWORD dwAudioDriverIndex = 0;
GUID* pTemp = NULL;
if( pGUID )
{
if( dwAudioDriverIndex >= 20 )
return TRUE;
pTemp = &AudioDriverGUIDs[dwAudioDriverIndex++];
memcpy( pTemp, pGUID, sizeof(GUID) );
}
HWND hSoundDeviceCombo = (HWND)pContext;
// Add the string to the combo box
SendMessage( hSoundDeviceCombo, CB_ADDSTRING,
0, (LPARAM) (LPCTSTR) strDesc );
// Get the index of the string in the combo box
INT nIndex = (INT)SendMessage( hSoundDeviceCombo, CB_FINDSTRING,
0, (LPARAM) (LPCTSTR) strDesc );
// Set the item data to a pointer to the static guid stored in AudioDriverGUIDs
SendMessage( hSoundDeviceCombo, CB_SETITEMDATA,
nIndex, (LPARAM) pTemp );
return TRUE;
}
//-----------------------------------------------------------------------------
// Name: InitDirectSound()
// Desc: Initilizes DirectSound
//-----------------------------------------------------------------------------
HRESULT InitDirectSound( HWND hDlg )
{
HRESULT hr;
// Free any previous DirectSound objects
FreeDirectSound();
// Get the HWNDs the combo boxes
HWND hSoundDeviceCombo = GetDlgItem( hDlg, IDC_SOUND_DEVICE_COMBO );
HWND hCaptureDeviceCombo = GetDlgItem( hDlg, IDC_CAPTURE_DEVICE_COMBO );
// Get the index of the currently selected devices
INT nSoundIndex = (INT)SendMessage( hSoundDeviceCombo, CB_GETCURSEL, 0, 0 );
INT nCaptureIndex = (INT)SendMessage( hCaptureDeviceCombo, CB_GETCURSEL, 0, 0 );
// Get the GUID attached to the combo box item
GUID* pSoundGUID = (GUID*) SendMessage( hSoundDeviceCombo, CB_GETITEMDATA,
nSoundIndex, 0 );
GUID* pCaptureGUID = (GUID*) SendMessage( hCaptureDeviceCombo, CB_GETITEMDATA,
nCaptureIndex, 0 );
// Create IDirectSound using the select sound device
if( FAILED( hr = DirectSoundCreate( pSoundGUID, &g_pDS, NULL ) ) )
return DXTRACE_ERR( TEXT("DirectSoundCreate"), hr );
// Release the IDirectSound object immediately since we don't want
// to limit this sample to only computers that support full duplex audio
SAFE_RELEASE( g_pDS );
// Create IDirectSoundCapture using the select capture device
if( FAILED( hr = DirectSoundCaptureCreate( pCaptureGUID, &g_pDSCapture, NULL ) ) )
return DXTRACE_ERR( TEXT("DirectSoundCaptureCreate"), hr );
// Release g_pDSCapture, since we don't need it really
SAFE_RELEASE( g_pDSCapture );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: FreeDirectSound()
// Desc: Releases DirectSound
//-----------------------------------------------------------------------------
HRESULT FreeDirectSound()
{
// Release DirectSound interfaces
SAFE_RELEASE( g_pDSCapture );
SAFE_RELEASE( g_pDS );
return S_OK;
}

View File

@@ -0,0 +1,139 @@
# Microsoft Developer Studio Project File - Name="EnumDevices" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=EnumDevices - 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 "enumdevices.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 "enumdevices.mak" CFG="EnumDevices - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "EnumDevices - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "EnumDevices - 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)" == "EnumDevices - 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 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)" == "EnumDevices - 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 "EnumDevices - Win32 Release"
# Name "EnumDevices - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\enumdevices.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=.\directx.ico
# End Source File
# Begin Source File
SOURCE=.\enumdevices.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: "EnumDevices"=.\enumdevices.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 enumdevices.dsp
!IF "$(CFG)" == ""
CFG=EnumDevices - Win32 Debug
!MESSAGE No configuration specified. Defaulting to EnumDevices - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "EnumDevices - Win32 Release" && "$(CFG)" != "EnumDevices - 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 "enumdevices.mak" CFG="EnumDevices - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "EnumDevices - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "EnumDevices - 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)" == "EnumDevices - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\enumdevices.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\enumdevices.obj"
-@erase "$(INTDIR)\enumdevices.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\enumdevices.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)\enumdevices.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)\enumdevices.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\enumdevices.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=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)\enumdevices.pdb" /machine:I386 /out:"$(OUTDIR)\enumdevices.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\enumdevices.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\enumdevices.res"
"$(OUTDIR)\enumdevices.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "EnumDevices - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\enumdevices.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\enumdevices.obj"
-@erase "$(INTDIR)\enumdevices.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\enumdevices.exe"
-@erase "$(OUTDIR)\enumdevices.ilk"
-@erase "$(OUTDIR)\enumdevices.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)\enumdevices.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)\enumdevices.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\enumdevices.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)\enumdevices.pdb" /debug /machine:I386 /out:"$(OUTDIR)\enumdevices.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\enumdevices.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\enumdevices.res"
"$(OUTDIR)\enumdevices.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("enumdevices.dep")
!INCLUDE "enumdevices.dep"
!ELSE
!MESSAGE Warning: cannot find "enumdevices.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "EnumDevices - Win32 Release" || "$(CFG)" == "EnumDevices - Win32 Debug"
SOURCE=.\enumdevices.cpp
"$(INTDIR)\enumdevices.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\enumdevices.rc
"$(INTDIR)\enumdevices.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,146 @@
//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 DIALOG DISCARDABLE 0, 0, 211, 79
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "DirectSound EnumDevices"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "This sample simply demonstrates how to enumerate devices.",
IDC_STATIC,7,7,190,8
LTEXT "Sound Device:",IDC_STATIC,7,21,48,8
COMBOBOX IDC_SOUND_DEVICE_COMBO,62,19,142,49,CBS_DROPDOWNLIST |
CBS_SORT | WS_VSCROLL | WS_TABSTOP
LTEXT "Capture Device:",IDC_STATIC,7,40,52,8
COMBOBOX IDC_CAPTURE_DEVICE_COMBO,62,38,142,49,CBS_DROPDOWNLIST |
CBS_SORT | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "&Create",IDC_CREATE,7,58,54,14
PUSHBUTTON "E&xit",IDCANCEL,154,58,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 204
TOPMARGIN, 7
BOTTOMMARGIN, 72
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
BEGIN
"C", IDC_CREATE, 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,33 @@
//-----------------------------------------------------------------------------
//
// Sample Name: EnumDevices Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
Description
===========
The EnumDevices sample shows how to enumerate and create playback
and capture devices.
Path
====
Source: DXSDK\Samples\Multimedia\DSound\EnumDevices
Executable: DXSDK\Samples\Multimedia\DSound\Bin
User's Guide
============
Select a playback and capture device from the dropdown lists. Click Create.
Programming Notes
=================
This sample was intended to be very simple, showing the basics how to
enumerate the DirectSound and DirectSoundCapture devices.
To enumerate DirectSound devices call DirectSoundEnumerate.
To enumerate DirectSoundCapture devices call DirectSoundCaptureEnumerate.

View File

@@ -0,0 +1,21 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by EnumDevices.rc
//
#define IDR_MAINFRAME 128
#define IDD_MAIN 130
#define IDR_ACCELERATOR1 131
#define IDC_CREATE 1000
#define IDC_SOUND_DEVICE_COMBO 1010
#define IDC_CAPTURE_DEVICE_COMBO 1011
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 132
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1019
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,139 @@
# Microsoft Developer Studio Project File - Name="FullDuplexFilter" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=FullDuplexFilter - 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 "fullduplexfilter.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 "fullduplexfilter.mak" CFG="FullDuplexFilter - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "FullDuplexFilter - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "FullDuplexFilter - 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)" == "FullDuplexFilter - 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 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)" == "FullDuplexFilter - 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 "FullDuplexFilter - Win32 Release"
# Name "FullDuplexFilter - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\fullduplexfilter.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=.\directx.ico
# End Source File
# Begin Source File
SOURCE=.\fullduplexfilter.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: "FullDuplexFilter"=.\fullduplexfilter.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 fullduplexfilter.dsp
!IF "$(CFG)" == ""
CFG=FullDuplexFilter - Win32 Debug
!MESSAGE No configuration specified. Defaulting to FullDuplexFilter - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "FullDuplexFilter - Win32 Release" && "$(CFG)" != "FullDuplexFilter - 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 "fullduplexfilter.mak" CFG="FullDuplexFilter - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "FullDuplexFilter - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "FullDuplexFilter - 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)" == "FullDuplexFilter - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\fullduplexfilter.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\fullduplexfilter.obj"
-@erase "$(INTDIR)\fullduplexfilter.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\fullduplexfilter.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)\fullduplexfilter.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)\fullduplexfilter.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\fullduplexfilter.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=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)\fullduplexfilter.pdb" /machine:I386 /out:"$(OUTDIR)\fullduplexfilter.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\fullduplexfilter.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\fullduplexfilter.res"
"$(OUTDIR)\fullduplexfilter.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "FullDuplexFilter - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\fullduplexfilter.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\fullduplexfilter.obj"
-@erase "$(INTDIR)\fullduplexfilter.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\fullduplexfilter.exe"
-@erase "$(OUTDIR)\fullduplexfilter.ilk"
-@erase "$(OUTDIR)\fullduplexfilter.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)\fullduplexfilter.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)\fullduplexfilter.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\fullduplexfilter.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)\fullduplexfilter.pdb" /debug /machine:I386 /out:"$(OUTDIR)\fullduplexfilter.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\fullduplexfilter.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\fullduplexfilter.res"
"$(OUTDIR)\fullduplexfilter.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("fullduplexfilter.dep")
!INCLUDE "fullduplexfilter.dep"
!ELSE
!MESSAGE Warning: cannot find "fullduplexfilter.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "FullDuplexFilter - Win32 Release" || "$(CFG)" == "FullDuplexFilter - Win32 Debug"
SOURCE=.\fullduplexfilter.cpp
"$(INTDIR)\fullduplexfilter.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\fullduplexfilter.rc
"$(INTDIR)\fullduplexfilter.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,172 @@
//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_FORMATS DIALOG DISCARDABLE 0, 0, 258, 177
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select Formats"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "OK",IDOK,75,156,50,14,WS_DISABLED
PUSHBUTTON "Cancel",IDCANCEL,133,156,50,14
LISTBOX IDC_FORMATS_OUTPUT_LISTBOX,6,15,90,134,
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LISTBOX IDC_FORMATS_INPUT_LISTBOX,161,15,90,134,
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LTEXT "Output Format:",IDC_STATIC,6,6,50,8
LTEXT "Input Format:",IDC_STATIC,161,6,50,8
CTEXT "Choose an output format, and then select from the available input formats. Click OK to accept the combination.",
IDC_STATIC,100,15,56,59
END
IDD_MAIN DIALOG DISCARDABLE 0, 0, 200, 87
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Full-Duplex Filter Sample"
FONT 8, "MS Shell Dlg"
BEGIN
GROUPBOX "Input",IDC_STATIC,7,7,186,22
LTEXT "Format:",IDC_STATIC,10,16,26,8
LTEXT "",IDC_MAIN_INPUTFORMAT_TEXT,38,16,152,8
GROUPBOX "Output",IDC_STATIC,7,29,186,32
LTEXT "Primary Format:",IDC_STATIC,10,38,50,8
LTEXT "",IDC_MAIN_PRIMARYFORMAT_TEXT,62,38,128,8
LTEXT "Secondary Format:",IDC_STATIC,10,48,60,8
LTEXT "",IDC_MAIN_SECONDARYFORMAT_TEXT,72,48,118,8
CONTROL "&Record",IDC_RECORD,"Button",BS_AUTOCHECKBOX |
BS_PUSHLIKE | WS_TABSTOP,143,66,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_FORMATS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 251
TOPMARGIN, 7
BOTTOMMARGIN, 170
END
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 193
TOPMARGIN, 7
BOTTOMMARGIN, 80
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
BEGIN
"R", IDC_RECORD, 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,37 @@
//-----------------------------------------------------------------------------
//
// Sample Name: FullDuplexFilter Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
Description
===========
The FullDuplexFilter application shows how to capture and play back sounds
at the same time.
Path
====
Source: \DXSDK\Samples\Multimedia\DSound\FullDuplexFilter
Executable: \DXSDK\Samples\Multimedia\DSound\Bin
User's Guide
============
Be sure your sound card is configured for full-duplex operation and that
you have a microphone attached. Choose a format from the Output Format
list. A list of formats appears in the Input Format list. Select one.
Click OK. If full duplex is successfully created, another dialog box is
displayed with a Record button. Click this button. Speak into the
microphone and your voice is heard over the speakers.
Programming Notes
=================
FullDuplexFilter is designed to be a simple example of how one might go about
implementing full-duplex audio. It is designed primarily to show application
developers the proper sequence of steps for dealing with the sound devices
installed on the system for using full-duplex audio with waveIn as an input
source and DirectSound as the output device.

View File

@@ -0,0 +1,26 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by FullDuplexFilter.rc
//
#define IDD_FORMATS 107
#define IDR_MAINFRAME 128
#define IDD_MAIN 130
#define IDR_ACCELERATOR1 132
#define IDC_FORMATS_OUTPUT_LISTBOX 1010
#define IDC_FORMATS_INPUT_LISTBOX 1011
#define IDC_MAIN_INPUTFORMAT_TEXT 1013
#define IDC_MAIN_PRIMARYFORMAT_TEXT 1015
#define IDC_ENABLE_FILTER 1017
#define IDC_MAIN_SECONDARYFORMAT_TEXT 1018
#define IDC_RECORD 1019
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1021
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,360 @@
//----------------------------------------------------------------------------
// File: PlaySound.cpp
//
// Desc: The PlaySound sample shows how to load and play a wave file using
// a DirectSound buffer.
//
// Copyright (c) 1999-2001 Microsoft Corp. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <commdlg.h>
#include <mmreg.h>
#include <dxerr8.h>
#include <dsound.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 );
VOID OnOpenSoundFile( HWND hDlg );
HRESULT OnPlaySound( HWND hDlg );
HRESULT PlayBuffer( BOOL bLooped );
VOID OnTimer( HWND hDlg );
VOID EnablePlayUI( HWND hDlg, BOOL bEnable );
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
CSoundManager* g_pSoundManager = NULL;
CSound* g_pSound = NULL;
BOOL g_bBufferPaused;
//-----------------------------------------------------------------------------
// 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 )
{
// 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:
// The 'play'/'pause' button was pressed
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();
}
EnablePlayUI( hDlg, TRUE );
break;
default:
return FALSE; // Didn't handle message
}
break;
case WM_TIMER:
OnTimer( hDlg );
break;
case WM_DESTROY:
// Cleanup everything
KillTimer( hDlg, 1 );
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 ) );
// Set the icon for this dialog.
SendMessage( hDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon ); // Set big icon
SendMessage( hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon ); // Set small icon
// 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();
if( FAILED( hr = g_pSoundManager->Initialize( hDlg, DSSCL_PRIORITY, 2, 22050, 16 ) ) )
{
DXTRACE_ERR( TEXT("Initialize"), hr );
MessageBox( hDlg, "Error initializing DirectSound. Sample will now exit.",
"DirectSound Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, IDABORT );
return;
}
g_bBufferPaused = FALSE;
// Create a timer, so we can check for when the soundbuffer is stopped
SetTimer( hDlg, 0, 250, NULL );
// Set the UI controls
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("No file loaded.") );
}
//-----------------------------------------------------------------------------
// Name: OnOpenSoundFile()
// Desc: Called when the user requests to open a sound file
//-----------------------------------------------------------------------------
VOID OnOpenSoundFile( HWND hDlg )
{
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_FILENAME, TEXT("Loading file...") );
// Display the OpenFileName dialog. Then, try to load the specified file
if( TRUE != GetOpenFileName( &ofn ) )
{
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Load aborted.") );
return;
}
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
// Free any previous sound, and make a new one
SAFE_DELETE( g_pSound );
// Load the wave file into a DirectSound buffer
if( FAILED( hr = g_pSoundManager->Create( &g_pSound, strFileName, 0, GUID_NULL ) ) )
{
// Not a critical failure, so just update the status
DXTRACE_ERR_NOMSGBOX( TEXT("Create"), hr );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Could not create sound buffer.") );
return;
}
// Update the UI controls to show the sound as the file is loaded
SetDlgItemText( hDlg, IDC_FILENAME, strFileName );
EnablePlayUI( hDlg, TRUE );
// Remember the path for next time
strcpy( strPath, strFileName );
char* strLastSlash = strrchr( strPath, '\\' );
strLastSlash[0] = '\0';
}
//-----------------------------------------------------------------------------
// Name: OnPlaySound()
// Desc: User hit the "Play" button
//-----------------------------------------------------------------------------
HRESULT OnPlaySound( HWND hDlg )
{
HRESULT hr;
HWND hLoopButton = GetDlgItem( hDlg, IDC_LOOP_CHECK );
BOOL bLooped = ( SendMessage( hLoopButton, BM_GETSTATE, 0, 0 ) == BST_CHECKED );
if( g_bBufferPaused )
{
// Play the buffer since it is currently paused
DWORD dwFlags = bLooped ? DSBPLAY_LOOPING : 0L;
if( FAILED( hr = g_pSound->Play( 0, dwFlags ) ) )
return DXTRACE_ERR( TEXT("Play"), hr );
// Update the UI controls to show the sound as playing
g_bBufferPaused = FALSE;
EnablePlayUI( hDlg, FALSE );
}
else
{
if( g_pSound->IsSoundPlaying() )
{
// To pause, just stop the buffer, but don't reset the position
if( g_pSound )
g_pSound->Stop();
g_bBufferPaused = TRUE;
SetDlgItemText( hDlg, IDC_PLAY, "Play" );
}
else
{
// The buffer is not playing, so play it again
DWORD dwFlags = bLooped ? DSBPLAY_LOOPING : 0L;
if( FAILED( hr = g_pSound->Play( 0, dwFlags ) ) )
return DXTRACE_ERR( TEXT("Play"), hr );
// Update the UI controls to show the sound as playing
g_bBufferPaused = FALSE;
EnablePlayUI( hDlg, FALSE );
}
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnTimer()
// Desc: When we think the sound is playing this periodically checks to see if
// the sound has stopped. If it has then updates the dialog.
//-----------------------------------------------------------------------------
VOID OnTimer( HWND hDlg )
{
if( IsWindowEnabled( GetDlgItem( hDlg, IDC_STOP ) ) )
{
// We think the sound is playing, so see if it has stopped yet.
if( !g_pSound->IsSoundPlaying() )
{
// Update the UI controls to show the sound as stopped
EnablePlayUI( hDlg, TRUE );
}
}
}
//-----------------------------------------------------------------------------
// Name: EnablePlayUI( hDlg,)
// Desc: Enables or disables the Play UI controls
//-----------------------------------------------------------------------------
VOID EnablePlayUI( HWND hDlg, BOOL bEnable )
{
if( bEnable )
{
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), TRUE );
SetFocus( GetDlgItem( hDlg, IDC_PLAY ) );
SetDlgItemText( hDlg, IDC_PLAY, "&Play" );
}
else
{
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), TRUE );
SetFocus( GetDlgItem( hDlg, IDC_STOP ) );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), TRUE );
SetDlgItemText( hDlg, IDC_PLAY, "&Pause" );
}
}

View File

@@ -0,0 +1,143 @@
# Microsoft Developer Studio Project File - Name="PlaySound" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=PlaySound - 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 "playsound.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 "playsound.mak" CFG="PlaySound - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "PlaySound - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "PlaySound - 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)" == "PlaySound - 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 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)" == "PlaySound - 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 "PlaySound - Win32 Release"
# Name "PlaySound - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\playsound.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=.\directx.ico
# End Source File
# Begin Source File
SOURCE=.\direcx.ico
# End Source File
# Begin Source File
SOURCE=.\playsound.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: "PlaySound"=.\playsound.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 playsound.dsp
!IF "$(CFG)" == ""
CFG=PlaySound - Win32 Debug
!MESSAGE No configuration specified. Defaulting to PlaySound - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "PlaySound - Win32 Release" && "$(CFG)" != "PlaySound - 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 "playsound.mak" CFG="PlaySound - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "PlaySound - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "PlaySound - 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)" == "PlaySound - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\playsound.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\playsound.obj"
-@erase "$(INTDIR)\playsound.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\playsound.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)\playsound.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)\playsound.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\playsound.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=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)\playsound.pdb" /machine:I386 /out:"$(OUTDIR)\playsound.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\playsound.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\playsound.res"
"$(OUTDIR)\playsound.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "PlaySound - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\playsound.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\playsound.obj"
-@erase "$(INTDIR)\playsound.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\playsound.exe"
-@erase "$(OUTDIR)\playsound.ilk"
-@erase "$(OUTDIR)\playsound.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)\playsound.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)\playsound.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\playsound.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)\playsound.pdb" /debug /machine:I386 /out:"$(OUTDIR)\playsound.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\playsound.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\playsound.res"
"$(OUTDIR)\playsound.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("playsound.dep")
!INCLUDE "playsound.dep"
!ELSE
!MESSAGE Warning: cannot find "playsound.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "PlaySound - Win32 Release" || "$(CFG)" == "PlaySound - Win32 Debug"
SOURCE=.\playsound.cpp
"$(INTDIR)\playsound.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\playsound.rc
"$(INTDIR)\playsound.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,148 @@
//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, 260, 47
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "PlaySound"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "Sound &file...",IDC_SOUNDFILE,7,7,46,13
LTEXT "Static",IDC_FILENAME,68,7,185,13,SS_CENTERIMAGE,
WS_EX_CLIENTEDGE
CONTROL "&Loop sound",IDC_LOOP_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,6,28,53,10
PUSHBUTTON "&Play",IDC_PLAY,68,26,50,14,WS_DISABLED
PUSHBUTTON "&Stop",IDC_STOP,118,26,50,14,WS_DISABLED
PUSHBUTTON "E&xit",IDCANCEL,203,26,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 253
TOPMARGIN, 7
BOTTOMMARGIN, 40
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
BEGIN
"F", IDC_SOUNDFILE, VIRTKEY, ALT, NOINVERT
"L", IDC_LOOP_CHECK, 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,66 @@
//-----------------------------------------------------------------------------
//
// Sample Name: PlaySound Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
Description
===========
The PlaySound sample shows how to play a wave file in a DirectSound
secondary buffer.
Path
====
Source: DXSDK\Samples\Multimedia\DSound\PlaySound
Executable: DXSDK\Samples\Multimedia\DSound\Bin
User's Guide
============
Load a wave file by clicking Sound File. Select Loop Sound if you want
it to play repeatedly. Click Play.
Programming Notes
=================
The basic tasks write an application that supports DirectSound are as follows:
* Set up DirectSound:
1. Call DirectSoundCreate to create a IDirectSound object
2. Call IDirectSound::SetCooperativeLevel to set the cooperative level.
3. Set the primary buffer format. This sample calls
DSUtil_SetPrimaryBufferFormat() to do just this.
* Load a wav file into a DirectSound buffer:
1. Read the wav file to get the wav file size, and the wav format
in the format a WAVEFORMATEX structure.
2. If the wav file of reasonable size, then create a DirectSound buffer
big enough to hold the entire wav file, and set it's format to
that of the wav file. If the wav file large, then see the
StreamData sample for information on how to stream data into a
DirectSound buffer.
3. Next, fill the DirectSound buffer with wav data. A pointer into the
buffer can be obtained by calling IDirectSoundBuffer::Lock. After the
memory has been copied, call IDirectSoundBuffer::Unlock.
* Play or stop the DirectSound buffer:
1. First, check to see if the buffer was not lost. If it was, then it will
need to be restored.
2. To play the buffer call IDirectSoundBuffer::Play.
3. To stop the buffer call IDirectSoundBuffer::Stop.
* To check to see if the sound stopped:
It may be useful to tell if a DirectSound buffer stopped playing. An easy
way to do this would be to set a timer to trigger every so often. When the
timer message is sent, call IDirectSoundBuffer::GetStatus to see if the
DSBSTATUS_PLAYING is set. If it is not, then the sound has stopped.
* Handle restoring a DirectSound buffer:
First call IDirectSoundBuffer::Restore. Next, fill the buffer with sound again
since the sound data was lost from when the buffer was lost.
* Free DirectSound:
Simply call Release() on all the DirectSound objects that were created.

View File

@@ -0,0 +1,23 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by PlaySound.rc
//
#define IDR_MAINFRAME 128
#define IDD_MAIN 130
#define IDR_ACCELERATOR1 131
#define IDC_PLAY 1000
#define IDC_STOP 1001
#define IDC_LOOP_CHECK 1009
#define IDC_SOUNDFILE 1011
#define IDC_FILENAME 1015
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 132
#define _APS_NEXT_COMMAND_VALUE 32772
#define _APS_NEXT_CONTROL_VALUE 1019
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,39 @@
//-----------------------------------------------------------------------------
//
// Sample Name: SoundFx Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
Description
===========
The SoundFx sample shows how to use standard effects with DirectSound and
how to manipulate FX parameters. It is similar to the AudioFX sample
but does not use an audiopath.
Path
====
Source: DXSDK\Samples\Multimedia\DirectSound\SoundFx
Executable: DXSDK\Samples\Multimedia\DirectSound\Bin
User's Guide
============
Load a sound file. Enable one or more FXs by checking the checkboxes on the
left, under the column "Enable". Click Play to hear the effects applied.
Adjust parameters for any FX by using the frame on the right.
Choose which effect to adjust by choosing an option under the "Adjust"
column on the left. If you are adjusting parametesr for an active
FX while sound is playing, you will hearing the difference immediately.
Programming Notes
=================
For a simpler example of how to setup a DirectSound buffer with a
single fixed DirectSound effect, see the AmplitudeModulate sample.

View File

@@ -0,0 +1,80 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by soundfx.rc
//
#define IDD_MAIN 101
#define IDI_ICON 103
#define IDC_PARAM_NAME1 1000
#define IDC_PARAM_VALUE1 1001
#define IDC_SLIDER1 1002
#define IDC_PARAM_MIN1 1003
#define IDC_PARAM_MAX1 1004
#define IDC_PARAM_NAME2 1005
#define IDC_PARAM_VALUE2 1006
#define IDC_SLIDER2 1007
#define IDC_PARAM_MIN2 1008
#define IDC_PARAM_MAX2 1009
#define IDC_PARAM_NAME3 1010
#define IDC_PARAM_VALUE3 1011
#define IDC_SLIDER3 1012
#define IDC_PARAM_MIN3 1013
#define IDC_PARAM_MAX3 1014
#define IDC_PARAM_NAME4 1015
#define IDC_PARAM_VALUE4 1016
#define IDC_SLIDER4 1017
#define IDC_PARAM_MIN4 1018
#define IDC_PARAM_MAX4 1019
#define IDC_PARAM_NAME5 1020
#define IDC_PARAM_VALUE5 1021
#define IDC_SLIDER5 1022
#define IDC_PARAM_MIN5 1023
#define IDC_PARAM_MAX5 1024
#define IDC_PARAM_NAME6 1025
#define IDC_PARAM_VALUE6 1026
#define IDC_SLIDER6 1027
#define IDC_PARAM_MIN6 1028
#define IDC_PARAM_MAX6 1029
#define IDC_RADIO_TRIANGLE 1101
#define IDC_RADIO_SQUARE 1102
#define IDC_RADIO_SINE 1103
#define IDC_RADIO_CHORUS 1201
#define IDC_RADIO_COMPRESSOR 1202
#define IDC_RADIO_DISTORTION 1203
#define IDC_RADIO_ECHO 1204
#define IDC_RADIO_FLANGER 1205
#define IDC_RADIO_GARGLE 1206
#define IDC_RADIO_PARAMEQ 1207
#define IDC_RADIO_REVERB 1208
#define IDC_CHECK_CHORUS 1211
#define IDC_CHECK_COMPRESSOR 1212
#define IDC_CHECK_DISTORTION 1213
#define IDC_CHECK_ECHO 1214
#define IDC_CHECK_FLANGER 1215
#define IDC_CHECK_GARGLE 1216
#define IDC_CHECK_PARAMEQ 1217
#define IDC_CHECK_REVERB 1218
#define IDC_BUTTON_OPEN 1301
#define IDC_TEXT_STATUS 1302
#define IDC_TEXT_FILENAME 1303
#define IDC_CHECK_LOOP 1304
#define IDC_BUTTON_PLAY 1305
#define IDC_BUTTON_STOP 1306
#define IDC_FRAME 1307
#define IDC_FRAME_WAVEFORM 1309
#define IDC_RADIO_NEG_180 1310
#define IDC_RADIO_NEG_90 1311
#define IDC_RADIO_ZERO 1312
#define IDC_RADIO_90 1313
#define IDC_RADIO_180 1314
#define IDC_FRAME_PHASE 1315
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1316
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,139 @@
# Microsoft Developer Studio Project File - Name="soundfx" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=soundfx - 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 "soundfx.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 "soundfx.mak" CFG="soundfx - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "soundfx - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "soundfx - 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)" == "soundfx - 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 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib dxguid.lib winmm.lib dxerr8.lib comctl32.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
!ELSEIF "$(CFG)" == "soundfx - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "soundfx___Win32_Debug"
# PROP BASE Intermediate_Dir "soundfx___Win32_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 dsound.lib dxguid.lib winmm.lib dxerr8.lib comctl32.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 "soundfx - Win32 Release"
# Name "soundfx - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\soundfx.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=.\directx.ico
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\soundfx.rc
# 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: "soundfx"=.\soundfx.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 soundfx.dsp
!IF "$(CFG)" == ""
CFG=soundfx - Win32 Debug
!MESSAGE No configuration specified. Defaulting to soundfx - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "soundfx - Win32 Release" && "$(CFG)" != "soundfx - 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 "soundfx.mak" CFG="soundfx - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "soundfx - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "soundfx - 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)" == "soundfx - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\soundfx.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\soundfx.obj"
-@erase "$(INTDIR)\soundfx.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\soundfx.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)\soundfx.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)\soundfx.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\soundfx.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib dxguid.lib winmm.lib dxerr8.lib comctl32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\soundfx.pdb" /machine:I386 /out:"$(OUTDIR)\soundfx.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\soundfx.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\soundfx.res"
"$(OUTDIR)\soundfx.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "soundfx - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\soundfx.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\soundfx.obj"
-@erase "$(INTDIR)\soundfx.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\soundfx.exe"
-@erase "$(OUTDIR)\soundfx.ilk"
-@erase "$(OUTDIR)\soundfx.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)\soundfx.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)\soundfx.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\soundfx.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=dsound.lib dxguid.lib winmm.lib dxerr8.lib comctl32.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)\soundfx.pdb" /debug /machine:I386 /out:"$(OUTDIR)\soundfx.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\soundfx.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\soundfx.res"
"$(OUTDIR)\soundfx.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("soundfx.dep")
!INCLUDE "soundfx.dep"
!ELSE
!MESSAGE Warning: cannot find "soundfx.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "soundfx - Win32 Release" || "$(CFG)" == "soundfx - Win32 Debug"
SOURCE=.\soundfx.cpp
"$(INTDIR)\soundfx.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\soundfx.rc
"$(INTDIR)\soundfx.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,218 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define IDC_STATIC -1
#include <windows.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
"#define IDC_STATIC -1\r\n"
"#include <windows.h>\r\n"
"\r\n"
"\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAIN DIALOGEX 100, 100, 467, 266
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "SoundFX - Sound effects applied to IDirectSoundBuffer8"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "E&xit",IDOK,30,245,45,14
GROUPBOX "Parameters",IDC_FRAME,110,48,350,212
RTEXT "Param 1 name",IDC_PARAM_NAME1,113,83,78,8
CTEXT "Value",IDC_PARAM_VALUE1,196,82,45,10,0,WS_EX_STATICEDGE
CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,284,79,130,15
CTEXT "min",IDC_PARAM_MIN1,244,82,40,10
CTEXT "max",IDC_PARAM_MAX1,418,82,35,8
RTEXT "Param 1 name",IDC_PARAM_NAME2,113,105,78,8
CTEXT "Value",IDC_PARAM_VALUE2,196,105,45,10,0,
WS_EX_STATICEDGE
CONTROL "Slider1",IDC_SLIDER2,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,284,102,130,15
CTEXT "min",IDC_PARAM_MIN2,244,105,40,10
CTEXT "max",IDC_PARAM_MAX2,418,105,35,8
RTEXT "Param 1 name",IDC_PARAM_NAME3,113,127,78,8
CTEXT "Value",IDC_PARAM_VALUE3,196,126,45,10,0,
WS_EX_STATICEDGE
CONTROL "Slider1",IDC_SLIDER3,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,284,123,130,15
CTEXT "min",IDC_PARAM_MIN3,244,126,40,10
CTEXT "max",IDC_PARAM_MAX3,418,126,35,8
RTEXT "Param 1 name",IDC_PARAM_NAME4,113,148,78,8
CTEXT "Value",IDC_PARAM_VALUE4,196,148,45,10,0,
WS_EX_STATICEDGE
CONTROL "Slider1",IDC_SLIDER4,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,284,145,130,15
CTEXT "min",IDC_PARAM_MIN4,244,148,40,10
CTEXT "max",IDC_PARAM_MAX4,418,148,35,8
RTEXT "Param 1 name",IDC_PARAM_NAME5,113,170,78,8
CTEXT "Value",IDC_PARAM_VALUE5,196,169,45,10,0,
WS_EX_STATICEDGE
CONTROL "Slider1",IDC_SLIDER5,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,284,166,130,15
CTEXT "min",IDC_PARAM_MIN5,244,169,40,10
CTEXT "max",IDC_PARAM_MAX5,418,169,35,8
RTEXT "Param 1 name",IDC_PARAM_NAME6,113,192,78,8
CTEXT "Value",IDC_PARAM_VALUE6,196,192,45,10,0,
WS_EX_STATICEDGE
CONTROL "Slider1",IDC_SLIDER6,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,284,189,130,15
CTEXT "min",IDC_PARAM_MIN6,244,192,40,10
CTEXT "max",IDC_PARAM_MAX6,418,192,35,8
CONTROL "Triangle",IDC_RADIO_TRIANGLE,"Button",
BS_AUTORADIOBUTTON,130,231,41,10
CONTROL "Square",IDC_RADIO_SQUARE,"Button",BS_AUTORADIOBUTTON,
180,231,39,10
CONTROL "Sine",IDC_RADIO_SINE,"Button",BS_AUTORADIOBUTTON,230,
231,30,10
GROUPBOX "Waveform",IDC_FRAME_WAVEFORM,120,220,150,25
GROUPBOX "FX",IDC_STATIC,8,48,95,155
CONTROL "",IDC_CHECK_CHORUS,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,28,80,16,8
CONTROL "",IDC_CHECK_COMPRESSOR,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,28,94,16,8
CONTROL "",IDC_CHECK_DISTORTION,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,28,109,16,8
CONTROL "",IDC_CHECK_ECHO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
28,124,16,8
CONTROL "",IDC_CHECK_FLANGER,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,28,139,16,8
CONTROL "",IDC_CHECK_GARGLE,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,28,154,16,8
CONTROL "",IDC_CHECK_PARAMEQ,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,28,168,16,8
CONTROL "",IDC_CHECK_REVERB,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,28,183,16,8
CTEXT "Enable",IDC_STATIC,18,63,25,10,0,WS_EX_STATICEDGE
CTEXT "Adjust",IDC_STATIC,48,63,25,10,0,WS_EX_STATICEDGE
PUSHBUTTON "&Open File",IDC_BUTTON_OPEN,8,8,50,14
LTEXT "Filename",IDC_TEXT_FILENAME,63,9,397,12,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CTEXT "Status",IDC_STATIC,13,28,45,10,SS_CENTERIMAGE
LTEXT "Status",IDC_TEXT_STATUS,63,28,397,12,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CONTROL "&Loop Sound",IDC_CHECK_LOOP,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,28,210,55,10
PUSHBUTTON "&Play",IDC_BUTTON_PLAY,5,225,45,14
PUSHBUTTON "&Stop",IDC_BUTTON_STOP,55,225,45,14
CONTROL "&Chorus",IDC_RADIO_CHORUS,"Button",BS_AUTORADIOBUTTON,
48,80,38,10
CONTROL "Co&mpressor",IDC_RADIO_COMPRESSOR,"Button",
BS_AUTORADIOBUTTON,48,94,53,10
CONTROL "&Distortion",IDC_RADIO_DISTORTION,"Button",
BS_AUTORADIOBUTTON,48,109,45,10
CONTROL "&Echo",IDC_RADIO_ECHO,"Button",BS_AUTORADIOBUTTON,48,
124,33,10
CONTROL "&Flanger",IDC_RADIO_FLANGER,"Button",BS_AUTORADIOBUTTON,
48,139,39,10
CONTROL "&Gargle",IDC_RADIO_GARGLE,"Button",BS_AUTORADIOBUTTON,
48,154,37,10
CONTROL "P&aramEq",IDC_RADIO_PARAMEQ,"Button",BS_AUTORADIOBUTTON,
48,168,45,10
CONTROL "&Reverb",IDC_RADIO_REVERB,"Button",BS_AUTORADIOBUTTON,
48,183,39,10
CTEXT "Min",IDC_STATIC,248,63,35,10,0,WS_EX_STATICEDGE
GROUPBOX "Phase (Degrees)",IDC_FRAME_PHASE,280,220,165,25
CTEXT "Max",IDC_STATIC,418,63,35,10,0,WS_EX_STATICEDGE
CONTROL "-180",IDC_RADIO_NEG_180,"Button",BS_AUTORADIOBUTTON,286,
231,30,10
CONTROL "-90",IDC_RADIO_NEG_90,"Button",BS_AUTORADIOBUTTON,322,
231,26,10
CONTROL "0",IDC_RADIO_ZERO,"Button",BS_AUTORADIOBUTTON,352,231,
20,10
CONTROL "90",IDC_RADIO_90,"Button",BS_AUTORADIOBUTTON,382,231,24,
10
CONTROL "180",IDC_RADIO_180,"Button",BS_AUTORADIOBUTTON,412,231,
28,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 460
TOPMARGIN, 7
BOTTOMMARGIN, 259
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON ICON DISCARDABLE "directx.ico"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,89 @@
//-----------------------------------------------------------------------------
//
// Sample Name: StreamData Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
Description
===========
The StreamData sample shows how to stream a wave file through a DirectSound
secondary buffer. It is similar to the PlaySound sample, but adds support
for streaming.
Path
====
Source: DXSDK\Samples\Multimedia\DSound\StreamData
Executable: DXSDK\Samples\Multimedia\DSound\Bin
User's Guide
============
Load a wave file by clicking Sound File. Select Loop Sound if you want it
to play repeatedly. Click Play.
Programming Notes
=================
For details on how to setup a non-streaming DirectSound buffer, see the
PlaySound sample.
The basic tasks to stream data from a wav file to a DirectSound buffer are
as follows:
* Set up DirectSound:
1. Call DirectSoundCreate to create a IDirectSound object
2. Call IDirectSound::SetCooperativeLevel to set the cooperative level.
3. Set the primary buffer format. This sample calls
DSUtil_SetPrimaryBufferFormat() to do just this.
* Create a DirectSound buffer and set up the notifications:
1. Read the wav file to get the wav file size, and the wav format
in the format a WAVEFORMATEX structure.
2. Choose a DirectSound buffer size. This is the amount of data that
DirectSound stores at once. You re-fill this buffer as sound plays
from this buffer. This is best for large sounds files that are not
possible to load all at once. For this sample, the buffer size is
~3 seconds of data.
3. Create a DirectSound buffer using the buffer size, and the wav file's
format. Also pass in DSBCAPS_CTRLPOSITIONNOTIFY flag. This allows the
buffer to send notification events to tell us whenever sound has finished
playing. However, using this flags limits the buffer to software only,
since hardware can not signal position notifications.
4. Set up the notifications on the buffer by calling
IDirectSoundBuffer::SetNotificationPositions. See InitDSoundNotification()
for an example of how this is done. When DirectSound plays past a
notification position it signals an Win32 event. When this event is signaled,
it is safe to fill that segment of data in the buffer with a new piece of
sound.
* Play the DirectSound buffer:
1. Call IDirectSoundBuffer::Restore on the buffer if the buffer was lost.
2. Next, fill the DirectSound buffer will the maximum amount of sound data.
Since all the sound can not fit into this buffer will be filled with new
sound data as this sound plays.
3. Call IDirectSoundBuffer::Play with the DSBPLAY_LOOPING flag set to
start the buffer playing. The looping flag needs to be set since the
buffer will need to continue playing after the end of the buffer is
reached since typically more sound needs to be played.
* Check to see if a notification is signaled:
1. Typically in the message pump check to see if the event was signaled.
The event tells us that a segment of data has been played so this
piece need to be filled. MsgWaitForMultipleObjects() works well as
the message pump for this purpose.
2. If the event has been signaled, then lock the section of the buffer
than has just been played and fill it with the next segment of wav
data. See HandleNotification() for how this works.
* When the entire sound has played:
When handling the event notification, keep track of how much data has
been put in the buffer. When the entire wav file has been put into the
buffer, and after DirectSound has played it all it is necessary to manually
stop the buffer since the buffer will continuously loop otherwise.
* Free DirectSound:
Simply call Release() on all the DirectSound objects that were created.

View File

@@ -0,0 +1,23 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by StreamData.rc
//
#define IDR_MAINFRAME 128
#define IDD_MAIN 130
#define IDR_ACCELERATOR1 132
#define IDC_PLAY 1000
#define IDC_STOP 1001
#define IDC_LOOP_CHECK 1009
#define IDC_SOUNDFILE 1011
#define IDC_FILENAME 1015
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1019
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,469 @@
//----------------------------------------------------------------------------
// File: StreamData.cpp
//
// Desc: The StreamData sample shows how to streaming wave data into
// a DirectSound buffer.
//
// Copyright (c) 1999-2001 Microsoft Corp. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <commdlg.h>
#include <mmreg.h>
#include <dxerr8.h>
#include <dsound.h>
#include "resource.h"
#include "DSUtil.h"
//-----------------------------------------------------------------------------
// Function-prototypes
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
DWORD WINAPI NotificationProc( LPVOID lpParameter );
VOID OnInitDialog( HWND hDlg );
HRESULT InitDirectSound( HWND hDlg );
HRESULT FreeDirectSound();
VOID OnOpenSoundFile( HWND hDlg );
VOID LoadWaveAndCreateBuffer( HWND hDlg, TCHAR* strFileName );
HRESULT InitDSoundNotification();
HRESULT PlayBuffer( BOOL bLooped );
HRESULT HandleNotification( BOOL bLooped );
VOID OnTimer( HWND hDlg );
VOID EnablePlayUI( HWND hDlg, BOOL bEnable );
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
#define NUM_PLAY_NOTIFICATIONS 16
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
CSoundManager* g_pSoundManager = NULL;
CStreamingSound* g_pStreamingSound = NULL;
HANDLE g_hNotificationEvent = NULL;
DWORD g_dwNotifyThreadID = 0;
HANDLE g_hNotifyThread = NULL;
HINSTANCE g_hInst = NULL;
//-----------------------------------------------------------------------------
// 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 )
{
g_hInst = hInst;
g_hNotificationEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
// Display the main dialog box.
DialogBox( hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDlgProc );
CloseHandle( g_hNotificationEvent );
return TRUE;
}
//-----------------------------------------------------------------------------
// Name: NotificationProc()
// Desc: Handles dsound notifcation events
//-----------------------------------------------------------------------------
DWORD WINAPI NotificationProc( LPVOID lpParameter )
{
HRESULT hr;
HWND hDlg = (HWND) lpParameter;
MSG msg;
DWORD dwResult;
BOOL bDone = FALSE;
BOOL bLooped;
while( !bDone )
{
dwResult = MsgWaitForMultipleObjects( 1, &g_hNotificationEvent,
FALSE, INFINITE, QS_ALLEVENTS );
switch( dwResult )
{
case WAIT_OBJECT_0 + 0:
// g_hNotificationEvent is signaled
// This means that DirectSound just finished playing
// a piece of the buffer, so we need to fill the circular
// buffer with new sound from the wav file
bLooped = ( IsDlgButtonChecked( hDlg, IDC_LOOP_CHECK ) == BST_CHECKED );
if( FAILED( hr = g_pStreamingSound->HandleWaveStreamNotification( bLooped ) ) )
{
DXTRACE_ERR( TEXT("HandleWaveStreamNotification"), hr );
MessageBox( hDlg, "Error handling DirectSound notifications."
"Sample will now exit.", "DirectSound Sample",
MB_OK | MB_ICONERROR );
bDone = TRUE;
}
break;
case WAIT_OBJECT_0 + 1:
// Messages are available
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if( msg.message == WM_QUIT )
bDone = TRUE;
}
break;
}
}
return 0;
}
//-----------------------------------------------------------------------------
// 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:
PostQuitMessage( 0 );
EndDialog( hDlg, IDCANCEL );
break;
case IDC_PLAY:
{
BOOL bLooped = ( IsDlgButtonChecked( hDlg, IDC_LOOP_CHECK ) == BST_CHECKED );
if( FAILED( hr = PlayBuffer( bLooped ) ) )
{
DXTRACE_ERR( TEXT("PlayBuffer"), hr );
MessageBox( hDlg, "Error playing DirectSound buffer."
"Sample will now exit.", "DirectSound Sample",
MB_OK | MB_ICONERROR );
EndDialog( hDlg, IDABORT );
}
// Update the UI controls to show the sound as playing
EnablePlayUI( hDlg, FALSE );
}
break;
case IDC_STOP:
if( g_pStreamingSound )
{
g_pStreamingSound->Stop();
g_pStreamingSound->Reset();
}
EnablePlayUI( hDlg, TRUE );
break;
default:
return FALSE; // Didn't handle message
}
break;
case WM_TIMER:
OnTimer( hDlg );
break;
case WM_DESTROY:
// Cleanup everything
KillTimer( hDlg, 1 );
SAFE_DELETE( g_pStreamingSound );
SAFE_DELETE( g_pSoundManager );
// Close down notification thread
PostThreadMessage( g_dwNotifyThreadID, WM_QUIT, 0, 0 );
WaitForSingleObject( g_hNotifyThread, INFINITE );
CloseHandle( g_hNotifyThread );
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
HICON hIcon = LoadIcon( g_hInst, MAKEINTRESOURCE( IDR_MAINFRAME ) );
// Set the icon for this dialog.
SendMessage( hDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon ); // Set big icon
SendMessage( hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon ); // Set small icon
// 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();
if( FAILED( hr = g_pSoundManager->Initialize( hDlg, DSSCL_PRIORITY, 2, 22050, 16 ) ) )
{
DXTRACE_ERR( TEXT("Initialize"), hr );
MessageBox( hDlg, "Error initializing DirectSound. Sample will now exit.",
"DirectSound Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, IDABORT );
return;
}
// Create a thread to handle DSound notifications
g_hNotifyThread = CreateThread( NULL, 0, NotificationProc,
hDlg, 0, &g_dwNotifyThreadID );
// Create a timer, so we can check for when the soundbuffer is stopped
SetTimer( hDlg, 0, 250, NULL );
// Set the UI controls
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("No file loaded.") );
}
//-----------------------------------------------------------------------------
// Name: OnOpenSoundFile()
// Desc: Called when the user requests to open a sound file
//-----------------------------------------------------------------------------
VOID OnOpenSoundFile( HWND hDlg )
{
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_pStreamingSound )
{
g_pStreamingSound->Stop();
g_pStreamingSound->Reset();
}
// Update the UI controls to show the sound as loading a file
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), FALSE );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Loading file...") );
// Display the OpenFileName dialog. Then, try to load the specified file
if( TRUE != GetOpenFileName( &ofn ) )
{
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Load aborted.") );
return;
}
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
// Load the wave file and create a DirectSound buffer
LoadWaveAndCreateBuffer( hDlg, strFileName );
// Remember the path for next time
strcpy( strPath, strFileName );
char* strLastSlash = strrchr( strPath, '\\' );
strLastSlash[0] = '\0';
}
//-----------------------------------------------------------------------------
// Name: LoadWaveAndCreateBuffer()
// Desc: Loads the wave file, and create a DirectSound buffer. Since we are
// streaming data into the buffer, the buffer will be filled with data
// when the sound is played, and as notification events are signaled
//-----------------------------------------------------------------------------
VOID LoadWaveAndCreateBuffer( HWND hDlg, TCHAR* strFileName )
{
HRESULT hr;
CWaveFile waveFile;
DWORD dwNotifySize;
// Load the wave file
if( FAILED( hr = waveFile.Open( strFileName, NULL, WAVEFILE_READ ) ) )
{
DXTRACE_ERR( TEXT("Open"), hr );
waveFile.Close();
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Bad wave file.") );
return;
}
if( waveFile.GetSize() == 0 )
{
waveFile.Close();
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Wave file blank.") );
return;
}
// The wave file is valid, and waveFile.m_pwfx is the wave's format
// so we are done with the reader.
waveFile.Close();
// This samples works by dividing a 3 second streaming buffer into
// NUM_PLAY_NOTIFICATIONS (16) pieces. It creates a notification for each
// piece and when a notification arrives then it fills the circular streaming
// buffer with new wav data over the sound data which was just played
// Determine the g_dwNotifySize. It should be an integer multiple of nBlockAlign
DWORD nBlockAlign = (DWORD)waveFile.m_pwfx->nBlockAlign;
INT nSamplesPerSec = waveFile.m_pwfx->nSamplesPerSec;
dwNotifySize = nSamplesPerSec * 3 * nBlockAlign / NUM_PLAY_NOTIFICATIONS;
dwNotifySize -= dwNotifySize % nBlockAlign;
// Create a new sound
SAFE_DELETE( g_pStreamingSound );
// Set up the direct sound buffer. Request the NOTIFY flag, so
// that we are notified as the sound buffer plays. Note, that using this flag
// may limit the amount of hardware acceleration that can occur.
if( FAILED( hr = g_pSoundManager->CreateStreaming( &g_pStreamingSound, strFileName,
DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GETCURRENTPOSITION2,
GUID_NULL, NUM_PLAY_NOTIFICATIONS,
dwNotifySize, g_hNotificationEvent ) ) )
{
if( hr != DSERR_BADFORMAT && hr != E_INVALIDARG )
DXTRACE_ERR( TEXT("CreateStreaming"), hr );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Could not create sound buffer.") );
return;
}
// Update the UI controls to show the sound as the file is loaded
EnablePlayUI( hDlg, TRUE );
SetDlgItemText( hDlg, IDC_FILENAME, strFileName );
}
//-----------------------------------------------------------------------------
// Name: PlayBuffer()
// Desc: Reset the buffer, fill it with sound, and starting it playing
//-----------------------------------------------------------------------------
HRESULT PlayBuffer( BOOL bLooped )
{
HRESULT hr;
if( NULL == g_pStreamingSound )
return E_FAIL; // Sanity check
if( FAILED( hr = g_pStreamingSound->Reset() ) )
return DXTRACE_ERR( TEXT("Reset"), hr );
// Fill the entire buffer with wave data, and if the wav file is small then
// repeat the wav file if the user wants to loop the file, otherwise fill in
// silence
LPDIRECTSOUNDBUFFER pDSB = g_pStreamingSound->GetBuffer( 0 );
if( FAILED( hr = g_pStreamingSound->FillBufferWithSound( pDSB, bLooped ) ) )
return DXTRACE_ERR( TEXT("FillBufferWithSound"), hr );
// Always play with the LOOPING flag since the streaming buffer
// wraps around before the entire WAV is played
if( FAILED( hr = g_pStreamingSound->Play( 0, DSBPLAY_LOOPING ) ) )
return DXTRACE_ERR( TEXT("Play"), hr );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnTimer()
// Desc: When we think the sound is playing this periodically checks to see if
// the sound has stopped. If it has then updates the dialog.
//-----------------------------------------------------------------------------
VOID OnTimer( HWND hDlg )
{
if( IsWindowEnabled( GetDlgItem( hDlg, IDC_STOP ) ) )
{
// We think the sound is playing, so see if it has stopped yet.
if( !g_pStreamingSound->IsSoundPlaying() )
{
// Update the UI controls to show the sound as stopped
EnablePlayUI( hDlg, TRUE );
}
}
}
//-----------------------------------------------------------------------------
// Name: EnablePlayUI( hDlg,)
// Desc: Enables or disables the Play UI controls
//-----------------------------------------------------------------------------
VOID EnablePlayUI( HWND hDlg, BOOL bEnable )
{
if( bEnable )
{
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), TRUE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), FALSE );
SetFocus( GetDlgItem( hDlg, IDC_PLAY ) );
}
else
{
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), TRUE );
SetFocus( GetDlgItem( hDlg, IDC_STOP ) );
}
}

View File

@@ -0,0 +1,135 @@
# Microsoft Developer Studio Project File - Name="StreamData" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=StreamData - 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 "streamdata.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 "streamdata.mak" CFG="StreamData - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "StreamData - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "StreamData - 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)" == "StreamData - 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 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)" == "StreamData - 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 "StreamData - Win32 Release"
# Name "StreamData - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\streamdata.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=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\streamdata.rc
# 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: "StreamData"=.\streamdata.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 streamdata.dsp
!IF "$(CFG)" == ""
CFG=StreamData - Win32 Debug
!MESSAGE No configuration specified. Defaulting to StreamData - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "StreamData - Win32 Release" && "$(CFG)" != "StreamData - 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 "streamdata.mak" CFG="StreamData - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "StreamData - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "StreamData - 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)" == "StreamData - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\streamdata.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\streamdata.obj"
-@erase "$(INTDIR)\streamdata.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\streamdata.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)\streamdata.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)\streamdata.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\streamdata.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=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)\streamdata.pdb" /machine:I386 /out:"$(OUTDIR)\streamdata.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\streamdata.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\streamdata.res"
"$(OUTDIR)\streamdata.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "StreamData - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\streamdata.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\streamdata.obj"
-@erase "$(INTDIR)\streamdata.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\streamdata.exe"
-@erase "$(OUTDIR)\streamdata.ilk"
-@erase "$(OUTDIR)\streamdata.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)\streamdata.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)\streamdata.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\streamdata.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)\streamdata.pdb" /debug /machine:I386 /out:"$(OUTDIR)\streamdata.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\streamdata.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\streamdata.res"
"$(OUTDIR)\streamdata.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("streamdata.dep")
!INCLUDE "streamdata.dep"
!ELSE
!MESSAGE Warning: cannot find "streamdata.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "StreamData - Win32 Release" || "$(CFG)" == "StreamData - Win32 Debug"
SOURCE=.\streamdata.cpp
"$(INTDIR)\streamdata.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\streamdata.rc
"$(INTDIR)\streamdata.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,148 @@
//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, 260, 47
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "StreamData"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "Sound &file...",IDC_SOUNDFILE,7,7,52,13
LTEXT "Static",IDC_FILENAME,68,7,185,13,SS_CENTERIMAGE,
WS_EX_CLIENTEDGE
CONTROL "&Loop sound",IDC_LOOP_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,6,28,53,10
PUSHBUTTON "&Play",IDC_PLAY,68,26,50,14,WS_DISABLED
PUSHBUTTON "&Stop",IDC_STOP,118,26,50,14,WS_DISABLED
PUSHBUTTON "E&xit",IDCANCEL,203,26,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 253
TOPMARGIN, 7
BOTTOMMARGIN, 40
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
BEGIN
"F", IDC_SOUNDFILE, VIRTKEY, ALT, NOINVERT
"L", IDC_LOOP_CHECK, 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,40 @@
//-----------------------------------------------------------------------------
//
// Sample Name: VoiceManagement Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
Description
===========
The VoiceManagement sample shows how to implement dynamic voice management
when creating DirectSound secondary buffers.
Path
====
Source: DXSDK\Samples\Multimedia\DSound\VoiceManagement
Executable: DXSDK\Samples\Multimedia\DSound\Bin
User's Guide
============
Load a wave file by clicking Sound File. Select Voice Allocation Flags,
Buffer Priority, and Voice Management Flags options. Note that the effect
of the selected options is described under Expected Behavior. Create the
buffer and play the sound by clicking Play.
Programming Notes
=================
For a simpler example of how to setup a DirectSound buffer without
voice management flags, see the PlaySound sample.
To use voice management flags, the buffer must be created using
DSBCAPS_LOCDEFER otherwise DirectSound will not be able to dynamically
place the buffer in either hardware or software at runtime.
When playing the buffer just call IDirectSoundBuffer::Play with a
valid combination of voice management flags. Run the sample to observe
the expected result of any combination of flags.

View File

@@ -0,0 +1,33 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by VoiceManagement.rc
//
#define IDR_MAINFRAME 128
#define IDD_MAIN 130
#define IDR_ACCELERATOR1 131
#define IDC_PLAY 1000
#define IDC_STOP 1001
#define IDC_LOOP_CHECK 1009
#define IDC_SOUNDFILE 1011
#define IDC_SOUNDFILE2 1012
#define IDC_FILENAME 1015
#define IDC_ALLOC_EITHER 1019
#define IDC_ALLOC_HARDWARE 1020
#define IDC_ALLOC_SOFTWARE 1021
#define IDC_BYPRIORTY 1024
#define IDC_BYDISTANCE 1025
#define IDC_BYTIME 1026
#define IDC_EDIT_PRIORITY 1031
#define IDC_SPIN_PRIORITY 1032
#define IDC_BEHAVIOR 1033
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 132
#define _APS_NEXT_COMMAND_VALUE 32772
#define _APS_NEXT_CONTROL_VALUE 1034
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,680 @@
//----------------------------------------------------------------------------
// File: VoiceManagement.cpp
//
// Desc: Main application file for the VoiceManagement sample.
//
// Copyright (c) 1999-2001 Microsoft Corp. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <commdlg.h>
#include <commctrl.h>
#include <mmreg.h>
#include <dxerr8.h>
#include <dsound.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 );
VOID OnOpenSoundFile( HWND hDlg );
HRESULT OnPlaySound( HWND hDlg );
VOID OnTimer( HWND hDlg );
VOID EnablePlayUI( HWND hDlg, BOOL bShowPlayControl );
VOID EnableManagementFlags( HWND hDlg, BOOL bShowFlags );
VOID UpdateBehaviorText( HWND hDlg );
VOID SetFileUI( HWND hDlg, TCHAR* strFileName );
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
CSoundManager* g_pSoundManager = NULL;
CSound* g_pSound = NULL;
//-----------------------------------------------------------------------------
// 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 )
{
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:
// The 'play' button was pressed
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();
}
EnablePlayUI( hDlg, TRUE );
break;
case IDC_ALLOC_HARDWARE:
case IDC_ALLOC_EITHER:
EnableManagementFlags( hDlg, TRUE );
UpdateBehaviorText( hDlg );
break;
case IDC_ALLOC_SOFTWARE:
EnableManagementFlags( hDlg, FALSE );
UpdateBehaviorText( hDlg );
break;
case IDC_BYTIME:
if( IsDlgButtonChecked( hDlg, IDC_BYTIME ) == BST_CHECKED )
CheckDlgButton( hDlg, IDC_BYDISTANCE, BST_UNCHECKED );
UpdateBehaviorText( hDlg );
break;
case IDC_BYDISTANCE:
if( IsDlgButtonChecked( hDlg, IDC_BYDISTANCE ) == BST_CHECKED )
CheckDlgButton( hDlg, IDC_BYTIME, BST_UNCHECKED );
UpdateBehaviorText( hDlg );
break;
case IDC_BYPRIORTY:
UpdateBehaviorText( hDlg );
break;
default:
return FALSE; // Didn't handle message
}
break;
case WM_TIMER:
OnTimer( hDlg );
break;
case WM_DESTROY:
// Cleanup everything
KillTimer( hDlg, 1 );
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();
if( FAILED( hr = g_pSoundManager->Initialize( hDlg, DSSCL_PRIORITY, 2, 22050, 16 ) ) )
{
DXTRACE_ERR( TEXT("Initialize"), hr );
MessageBox( hDlg, "Error initializing DirectSound. Sample will now exit.",
"DirectSound Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, IDABORT );
return;
}
// Check the 'hardware' voice allocation button by default.
CheckRadioButton( hDlg, IDC_ALLOC_EITHER, IDC_ALLOC_SOFTWARE, IDC_ALLOC_EITHER );
HWND hEditPri = GetDlgItem( hDlg, IDC_EDIT_PRIORITY );
HWND hSpinPri = GetDlgItem( hDlg, IDC_SPIN_PRIORITY );
SendMessage( hSpinPri, UDM_SETBUDDY, (WPARAM) hEditPri, 0 );
SendMessage( hSpinPri, UDM_SETRANGE, 0, MAKELONG (0x7FFF, 0) );
SendMessage( hSpinPri, UDM_SETPOS, 0, 0 );
SendMessage( hEditPri, EM_LIMITTEXT, 5, 0 );
// 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, so we can check for when the soundbuffer is stopped
SetTimer( hDlg, 0, 250, NULL );
// Set the UI controls
UpdateBehaviorText( hDlg );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("No file loaded.") );
}
//-----------------------------------------------------------------------------
// Name: OnOpenSoundFile()
// Desc: Called when the user requests to open a sound file
//-----------------------------------------------------------------------------
VOID OnOpenSoundFile( HWND hDlg )
{
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_FILENAME, TEXT("Loading file...") );
// Display the OpenFileName dialog. Then, try to load the specified file
if( TRUE != GetOpenFileName( &ofn ) )
{
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Load aborted.") );
return;
}
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
// Free any previous sound, and make a new one
SAFE_DELETE( g_pSound );
// Load the wave file into a DirectSound buffer
if( FAILED( hr = g_pSoundManager->Create( &g_pSound, strFileName,
DSBCAPS_LOCDEFER, GUID_NULL ) ) )
{
// Not a critical failure, so just update the status
DXTRACE_ERR_NOMSGBOX( TEXT("Create"), hr );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Could not create sound buffer.") );
return;
}
// Update the UI controls to show the sound as the file is loaded
SetDlgItemText( hDlg, IDC_FILENAME, strFileName );
EnablePlayUI( hDlg, TRUE );
// Remember the path for next time
strcpy( strPath, strFileName );
char* strLastSlash = strrchr( strPath, '\\' );
strLastSlash[0] = '\0';
}
//-----------------------------------------------------------------------------
// Name: OnPlaySound()
// Desc: User hit the "Play" button
//-----------------------------------------------------------------------------
HRESULT OnPlaySound( HWND hDlg )
{
HRESULT hr;
LONG lPriority;
DWORD dwPlayFlags;
BOOL bLooped;
BOOL bAllocHW;
BOOL bAllocSW;
BOOL bAllocEither;
BOOL bByTime;
BOOL bByDistance;
BOOL bByPriority;
bLooped = ( IsDlgButtonChecked( hDlg, IDC_LOOP_CHECK ) == BST_CHECKED );
// Determine where the buffer would like to be allocated
bAllocHW = ( IsDlgButtonChecked( hDlg, IDC_ALLOC_HARDWARE ) == BST_CHECKED );
bAllocSW = ( IsDlgButtonChecked( hDlg, IDC_ALLOC_SOFTWARE ) == BST_CHECKED );
bAllocEither = ( IsDlgButtonChecked( hDlg, IDC_ALLOC_EITHER ) == BST_CHECKED );
if( bAllocHW || bAllocEither )
{
// Determine how the buffer should steal hardware resources (if they are not available)
bByTime = ( IsDlgButtonChecked( hDlg, IDC_BYTIME ) == BST_CHECKED );
bByDistance = ( IsDlgButtonChecked( hDlg, IDC_BYDISTANCE ) == BST_CHECKED );
bByPriority = ( IsDlgButtonChecked( hDlg, IDC_BYPRIORTY ) == BST_CHECKED );
}
else
{
// Buffers running in software are not allowed to have
// voice management flags since they have no need to
// steal hardware resources.
bByTime = FALSE;
bByDistance = FALSE;
bByPriority = FALSE;
}
// Get the buffer priority
TCHAR strText[MAX_PATH];
GetDlgItemText( hDlg, IDC_EDIT_PRIORITY, strText, MAX_PATH );
lPriority = atol( strText );
if( lPriority < 0 || lPriority > 32767 )
{
MessageBox( hDlg, "Please enter a buffer priority between 0 and 32767",
"DirectSound Sample", MB_OK );
return S_OK;
}
// Figure out the voice allocation flag from the dialog,
// and what the user should expect based on the dialog choice
if( bAllocSW )
dwPlayFlags = DSBPLAY_LOCSOFTWARE;
if( bAllocHW )
dwPlayFlags = DSBPLAY_LOCHARDWARE;
if( bAllocEither )
dwPlayFlags = 0;
// Figure out what voice management flags should be based on the dlg
if( bByTime )
{
if( bByPriority )
{
dwPlayFlags |= DSBPLAY_TERMINATEBY_TIME |
DSBPLAY_TERMINATEBY_PRIORITY;
}
else
{
dwPlayFlags |= DSBPLAY_TERMINATEBY_TIME;
}
}
else if( bByDistance )
{
if( bByPriority )
{
dwPlayFlags |= DSBPLAY_TERMINATEBY_DISTANCE |
DSBPLAY_TERMINATEBY_PRIORITY;
}
else
{
dwPlayFlags |= DSBPLAY_TERMINATEBY_DISTANCE;
}
}
else
{
if( bByPriority )
{
dwPlayFlags |= DSBPLAY_TERMINATEBY_PRIORITY;
}
else
{
dwPlayFlags |= 0;
}
}
if( bLooped )
dwPlayFlags |= DSBPLAY_LOOPING;
// Play the sound
if( FAILED( hr = g_pSound->Play( lPriority, dwPlayFlags ) ) )
{
if( hr == DSERR_CONTROLUNAVAIL ||
hr == DSERR_INVALIDCALL ||
hr == E_FAIL ||
hr == E_NOTIMPL)
{
DXTRACE_ERR_NOMSGBOX( TEXT("Play"), hr );
if( hr == DSERR_INVALIDCALL )
{
MessageBox( hDlg, "Unsupported wave file format.",
"DirectPlay Sample", MB_OK | MB_ICONERROR );
}
else
{
MessageBox( hDlg, "The buffer could not be played.",
"DirectPlay Sample", MB_OK | MB_ICONERROR );
}
return S_OK;
}
return DXTRACE_ERR( TEXT("Play"), hr );
}
// Update the UI controls to show the sound as playing
EnablePlayUI( hDlg, FALSE );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnTimer()
// Desc: When we think the sound is playing this periodically checks to see if
// the sound has stopped. If it has then updates the dialog.
//-----------------------------------------------------------------------------
VOID OnTimer( HWND hDlg )
{
if( IsWindowEnabled( GetDlgItem( hDlg, IDC_STOP ) ) )
{
// We think the sound is playing, so see if it has stopped yet.
if( !g_pSound->IsSoundPlaying() )
{
// Update the UI controls to show the sound as stopped
EnablePlayUI( hDlg, TRUE );
}
}
}
//-----------------------------------------------------------------------------
// Name: UpdateBehaviorText()
// Desc: Figure out what the expected behavoir is based on the dialog,
// and display it on the dialog
//-----------------------------------------------------------------------------
VOID UpdateBehaviorText( HWND hDlg )
{
TCHAR strExcepted[1024];
BOOL bAllocHW;
BOOL bAllocSW;
BOOL bAllocEither;
BOOL bByTime;
BOOL bByDistance;
BOOL bByPriority;
// Determine where the buffer would like to be allocated
bAllocHW = ( IsDlgButtonChecked( hDlg, IDC_ALLOC_HARDWARE ) == BST_CHECKED );
bAllocSW = ( IsDlgButtonChecked( hDlg, IDC_ALLOC_SOFTWARE ) == BST_CHECKED );
bAllocEither = ( IsDlgButtonChecked( hDlg, IDC_ALLOC_EITHER ) == BST_CHECKED );
if( bAllocHW || bAllocEither )
{
// Determine how the buffer should steal hardware resources (if they are not available)
bByTime = ( IsDlgButtonChecked( hDlg, IDC_BYTIME ) == BST_CHECKED );
bByDistance = ( IsDlgButtonChecked( hDlg, IDC_BYDISTANCE ) == BST_CHECKED );
bByPriority = ( IsDlgButtonChecked( hDlg, IDC_BYPRIORTY ) == BST_CHECKED );
}
else
{
// Buffers running in software are not allowed to have
// voice management flags since they have no need to
// steal hardware resources.
bByTime = FALSE;
bByDistance = FALSE;
bByPriority = FALSE;
}
// Figure what the user should expect based on the dialog choice
if( bAllocSW )
{
strcpy( strExcepted, "The new sound will be played in software" );
}
if( bAllocHW )
{
strcpy( strExcepted, "The new sound will be played in hardware" );
}
if( bAllocEither )
{
strcpy( strExcepted, "The new sound will be played in hardware "
"if available" );
}
if( bByTime )
{
if( bByPriority )
{
if( bAllocEither )
{
strcpy( strExcepted, "The new sound will be played in hardware, "
"if the the hardware has no available "
"voices, and new sound has a higher priority "
"than sounds currently playing in hardware "
"then sound with the lowest priority will be "
"terminated and the new sound will play in "
"hardware. Otherwise, the new sound will play "
"in software. In event of a priority tie, "
"then the buffer with the least time left to "
"play will be prematurely terminated." );
}
else
{
strcat( strExcepted, ", and if the hardware has no available "
"voices, the voice management buffer with "
"the lowest priority as set by the "
"IDirectSoundBuffer::Play priority argument "
"will be prematurely terminated. In event "
"of a priority tie, then the buffer with "
"the least time left to play will be "
"prematurely terminated." );
}
}
else
{
strcat( strExcepted, ", and if the hardware has no available "
"voices, the voice management buffer with "
"the least time left to play will be "
"prematurely terminated." );
}
}
else if( bByDistance )
{
if( bByPriority )
{
if( bAllocEither )
{
strcpy( strExcepted, "The new sound will be played in hardware, "
"if the the hardware has no available "
"voices, and new sound has a higher priority "
"than sounds currently playing in hardware "
"then sound with the lowest priority will be "
"terminated and the new sound will play in "
"hardware. Otherwise, the new sound will play "
"in software. In event of a priority tie, "
"then the buffer which is the furthest "
"distance from the listener at the time "
"of the Play will be prematurely terminated." );
}
else
{
strcat( strExcepted, ", and if the hardware has no available "
"voices, the voice management buffer with "
"the lowest priority as set by the "
"IDirectSoundBuffer::Play priority argument "
"will be prematurely terminated. In event "
"of a priority tie, then the buffer which "
"is the furthest distance from the "
"listener at the time of the Play will "
"be prematurely terminated." );
}
}
else
{
strcat( strExcepted, ", and if the hardware has no available "
"voices, the voice management buffer which "
"is the furthest distance from the "
"listener at the time of the Play will "
"be prematurely terminated." );
}
}
else
{
if( bByPriority )
{
if( bAllocEither )
{
strcpy( strExcepted, "The new sound will be played in hardware, "
"if the the hardware has no available "
"voices, and new sound has a higher priority "
"than sounds currently playing in hardware "
"then sound with the lowest priority will be "
"terminated and the new sound will play in "
"hardware. Otherwise, the new sound will play "
"in software." );
}
else
{
strcat( strExcepted, ", and if the hardware has no available "
"voices, the voice management buffer with "
"the lowest priority as set by the "
"IDirectSoundBuffer::Play priority argument "
"will be prematurely terminated. " );
}
}
else
{
strcat( strExcepted, ", and the buffer will not steal any "
"hardware resources." );
}
}
// Tell the user what to expect
SetDlgItemText( hDlg, IDC_BEHAVIOR, strExcepted );
}
//-----------------------------------------------------------------------------
// Name: EnablePlayUI()
// Desc: Enables or disables the Play UI controls
//-----------------------------------------------------------------------------
VOID EnablePlayUI( HWND hDlg, BOOL bShowPlayControl )
{
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), bShowPlayControl );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), !bShowPlayControl );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), bShowPlayControl );
// Don't allow the voice allocation or voicemanagement flags
// to be changed when a sound is playing
EnableWindow( GetDlgItem( hDlg, IDC_BYTIME ), bShowPlayControl );
EnableWindow( GetDlgItem( hDlg, IDC_BYDISTANCE ), bShowPlayControl );
EnableWindow( GetDlgItem( hDlg, IDC_BYPRIORTY ), bShowPlayControl );
EnableWindow( GetDlgItem( hDlg, IDC_EDIT_PRIORITY ), bShowPlayControl );
EnableWindow( GetDlgItem( hDlg, IDC_ALLOC_HARDWARE ), bShowPlayControl );
EnableWindow( GetDlgItem( hDlg, IDC_ALLOC_SOFTWARE ), bShowPlayControl );
EnableWindow( GetDlgItem( hDlg, IDC_ALLOC_EITHER ), bShowPlayControl );
if( bShowPlayControl )
{
// If the software alloc flag is checked, then don't enable
// the voice management flags
if( IsDlgButtonChecked( hDlg, IDC_ALLOC_SOFTWARE ) == BST_CHECKED )
EnableManagementFlags( hDlg, FALSE );
}
if( bShowPlayControl )
SetFocus( GetDlgItem( hDlg, IDC_PLAY ) );
else
SetFocus( GetDlgItem( hDlg, IDC_STOP ) );
}
//-----------------------------------------------------------------------------
// Name: EnableManagementFlags()
// Desc: Enable or disable the voice management flags
//-----------------------------------------------------------------------------
VOID EnableManagementFlags( HWND hDlg, BOOL bShowFlags )
{
EnableWindow( GetDlgItem( hDlg, IDC_BYTIME ), bShowFlags );
EnableWindow( GetDlgItem( hDlg, IDC_BYDISTANCE ), bShowFlags );
EnableWindow( GetDlgItem( hDlg, IDC_BYPRIORTY ), bShowFlags );
EnableWindow( GetDlgItem( hDlg, IDC_EDIT_PRIORITY ), bShowFlags );
}

View File

@@ -0,0 +1,139 @@
# Microsoft Developer Studio Project File - Name="VoiceManagement" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=VoiceManagement - 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 "voicemanagement.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 "voicemanagement.mak" CFG="VoiceManagement - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "VoiceManagement - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "VoiceManagement - 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)" == "VoiceManagement - 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)" == "VoiceManagement - 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 "VoiceManagement - Win32 Release"
# Name "VoiceManagement - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\voicemanagement.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=.\directx.ico
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\voicemanagement.rc
# 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: "VoiceManagement"=.\voicemanagement.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 voicemanagement.dsp
!IF "$(CFG)" == ""
CFG=VoiceManagement - Win32 Debug
!MESSAGE No configuration specified. Defaulting to VoiceManagement - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "VoiceManagement - Win32 Release" && "$(CFG)" != "VoiceManagement - 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 "voicemanagement.mak" CFG="VoiceManagement - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "VoiceManagement - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "VoiceManagement - 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)" == "VoiceManagement - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\voicemanagement.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\voicemanagement.obj"
-@erase "$(INTDIR)\voicemanagement.res"
-@erase "$(OUTDIR)\voicemanagement.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)\voicemanagement.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)\voicemanagement.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\voicemanagement.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)\voicemanagement.pdb" /machine:I386 /out:"$(OUTDIR)\voicemanagement.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\voicemanagement.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\voicemanagement.res"
"$(OUTDIR)\voicemanagement.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "VoiceManagement - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\voicemanagement.exe"
CLEAN :
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(INTDIR)\voicemanagement.obj"
-@erase "$(INTDIR)\voicemanagement.res"
-@erase "$(OUTDIR)\voicemanagement.exe"
-@erase "$(OUTDIR)\voicemanagement.ilk"
-@erase "$(OUTDIR)\voicemanagement.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)\voicemanagement.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)\voicemanagement.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\voicemanagement.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)\voicemanagement.pdb" /debug /machine:I386 /out:"$(OUTDIR)\voicemanagement.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\voicemanagement.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\voicemanagement.res"
"$(OUTDIR)\voicemanagement.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("voicemanagement.dep")
!INCLUDE "voicemanagement.dep"
!ELSE
!MESSAGE Warning: cannot find "voicemanagement.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "VoiceManagement - Win32 Release" || "$(CFG)" == "VoiceManagement - Win32 Debug"
SOURCE=.\voicemanagement.cpp
"$(INTDIR)\voicemanagement.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\voicemanagement.rc
"$(INTDIR)\voicemanagement.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,169 @@
//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, 299, 188
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Voice Management Sample"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "Sound &file...",IDC_SOUNDFILE,7,7,46,13
LTEXT "Static",IDC_FILENAME,57,7,235,13,SS_CENTERIMAGE,
WS_EX_CLIENTEDGE
GROUPBOX "Voice Allocation Flags",IDC_STATIC,7,24,93,50
CONTROL "Hardware",IDC_ALLOC_HARDWARE,"Button",
BS_AUTORADIOBUTTON,19,35,48,10
CONTROL "Software",IDC_ALLOC_SOFTWARE,"Button",
BS_AUTORADIOBUTTON,19,46,48,10
CONTROL "Either",IDC_ALLOC_EITHER,"Button",BS_AUTORADIOBUTTON,19,
58,48,10
GROUPBOX "Buffer Priority",IDC_STATIC,108,24,64,50
EDITTEXT IDC_EDIT_PRIORITY,119,44,39,14,ES_AUTOHSCROLL
CONTROL "Spin1",IDC_SPIN_PRIORITY,"msctls_updown32",
UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS |
UDS_NOTHOUSANDS,153,41,11,14
GROUPBOX "Voice Management Flags",IDC_STATIC,179,24,113,50
CONTROL "Terminate By Time",IDC_BYTIME,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,190,35,75,10
CONTROL "Terminate By Distance",IDC_BYDISTANCE,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,190,46,87,10
CONTROL "Terminate By Priority",IDC_BYPRIORTY,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,190,57,80,10
GROUPBOX "Expected Behavior",IDC_STATIC,7,76,285,74
LTEXT "Static",IDC_BEHAVIOR,15,86,269,58
CONTROL "&Loop sound",IDC_LOOP_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,154,53,10
PUSHBUTTON "&Play",IDC_PLAY,7,167,50,14,WS_DISABLED
PUSHBUTTON "&Stop",IDC_STOP,58,167,50,14,WS_DISABLED
PUSHBUTTON "E&xit",IDCANCEL,242,167,50,14
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 292
TOPMARGIN, 7
BOTTOMMARGIN, 181
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
BEGIN
"F", IDC_SOUNDFILE, VIRTKEY, ALT, NOINVERT
"L", IDC_LOOP_CHECK, 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,137 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "AdjustSound"=.\adjustsound\adjustsound.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "AmplitudeModulation"=.\amplitudemodulation\amplitudemodulation.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "CaptureSound"=.\capturesound\capturesound.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "EnumDevices"=.\enumdevices\enumdevices.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "FullDuplexFilter"=.\fullduplexfilter\fullduplexfilter.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "Play3DSound"=.\play3dsound\play3dsound.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "PlaySound"=.\playsound\playsound.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "StreamData"=.\streamdata\streamdata.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "VoiceManagement"=.\voicemanagement\voicemanagement.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "soundfx"=.\soundfx\soundfx.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################