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,765 @@
//-----------------------------------------------------------------------------
// File: 3DAudio.cpp
//
// Desc: Plays a primary segment using DirectMusic
//
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <commdlg.h>
#include <commctrl.h>
#include <dmusicc.h>
#include <dmusici.h>
#include <dxerr8.h>
#include <cguid.h>
#include <math.h>
#include <stdio.h>
#include "resource.h"
#include "DMUtil.h"
#include "DXUtil.h"
//-----------------------------------------------------------------------------
// Function-prototypes
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
VOID OnInitDialog( HWND hDlg );
HRESULT InitAudio( HWND hDlg );
VOID SetSlidersPos( HWND hDlg, FLOAT fDopplerValue, FLOAT fRolloffValue, FLOAT fMinDistValue, FLOAT fMaxDistValue );
VOID OnOpenAudioFile( HWND hDlg );
HRESULT LoadSegmentFile( HWND hDlg, TCHAR* strFileName );
HRESULT OnPlayAudio( HWND hDlg );
VOID EnablePlayUI( HWND hDlg, BOOL bEnable );
VOID OnMovementTimer( HWND hDlg );
VOID Set3DParameters( FLOAT fDopplerFactor, FLOAT fRolloffFactor, FLOAT fMinDistance, FLOAT fMaxDistance );
VOID EnablePlayUI( HWND hDlg, BOOL bEnable );
VOID SetObjectProperties( D3DVECTOR* pvPosition, D3DVECTOR* pvVelocity );
VOID UpdateGrid( HWND hDlg, FLOAT x, FLOAT y );
VOID OnSliderChanged( HWND hDlg );
VOID SetObjectProperties( D3DVECTOR* pvPosition, D3DVECTOR* pvVelocity );
FLOAT ConvertLinearSliderPosToLogScale( LONG lSliderPos );
LONG ConvertLogScaleToLinearSliderPosTo( FLOAT fValue );
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
#define ORBIT_MAX_RADIUS 5.0f
#define IDT_MOVEMENT_TIMER 1
CMusicManager* g_pMusicManager = NULL;
CMusicSegment* g_pMusicSegment = NULL;
IDirectMusicAudioPath* g_p3DAudioPath = NULL;
IDirectSound3DBuffer* g_pDS3DBuffer = NULL; // 3D sound buffer
IDirectSound3DListener* g_pDSListener = NULL; // 3D listener object
DS3DBUFFER g_dsBufferParams; // 3D buffer properties
DS3DLISTENER g_dsListenerParams; // Listener properties
HINSTANCE g_hInst = NULL;
BOOL g_bAllowMovementTimer = TRUE;
BOOL g_bDeferSettings = FALSE;
//-----------------------------------------------------------------------------
// 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;
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:
OnOpenAudioFile( hDlg );
break;
case IDCANCEL:
EndDialog( hDlg, 0 );
break;
case IDC_PLAY:
if( FAILED( hr = OnPlayAudio( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnPlayAudio"), hr );
MessageBox( hDlg, "Error playing DirectMusic segment. "
"Sample will now exit.", "DirectMusic Sample",
MB_OK | MB_ICONERROR );
EndDialog( hDlg, 0 );
}
break;
case IDC_STOP:
if( g_pMusicSegment )
{
g_pMusicSegment->Stop( DMUS_SEGF_BEAT );
EnablePlayUI( hDlg, TRUE );
}
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
if( g_pMusicSegment )
{
g_pMusicSegment->Unload( g_p3DAudioPath );
SAFE_DELETE( g_pMusicSegment );
}
KillTimer( hDlg, 1 );
SAFE_RELEASE( g_pDSListener );
SAFE_RELEASE( g_pDS3DBuffer );
SAFE_RELEASE( g_p3DAudioPath );
SAFE_DELETE( g_pMusicManager );
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
if( FAILED( hr = InitAudio( hDlg ) ) )
{
DXTRACE_ERR( TEXT("InitAudio"), hr );
MessageBox( hDlg, "Error initializing DirectMusic. Sample will now exit.",
"DirectMusic Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, 0 );
return;
}
// Set the default media path (something like C:\MSSDK\SAMPLES\MULTIMEDIA\MEDIA)
// to be used as the search directory for finding DirectMusic content.
g_pMusicManager->SetSearchDirectory( DXUtil_GetDXSDKMediaPath() );
// Load a default music segment
TCHAR strFileName[MAX_PATH];
strcpy( strFileName, DXUtil_GetDXSDKMediaPath() );
strcat( strFileName, "sample.sgt" );
if( S_FALSE == LoadSegmentFile( hDlg, strFileName ) )
{
// Set the UI controls
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("No file loaded.") );
}
// Create a timer to periodically move the 3D object around
SetTimer( hDlg, IDT_MOVEMENT_TIMER, 5, NULL );
// 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, 10L );
PostMessage( hHorzSlider, TBM_SETRANGEMAX, TRUE, 100L );
PostMessage( hHorzSlider, TBM_SETRANGEMIN, TRUE, -100L );
PostMessage( hHorzSlider, TBM_SETPOS, TRUE, 50L );
// Set the position of the sliders
SetSlidersPos( hDlg, 0.0f, 0.0f, ORBIT_MAX_RADIUS, ORBIT_MAX_RADIUS*2.0f );
}
//-----------------------------------------------------------------------------
// Name: InitAudio()
// Desc: Init both DirectMusic and DirectSound
//-----------------------------------------------------------------------------
HRESULT InitAudio( HWND hDlg )
{
HRESULT hr;
// Initialize the performance. This initializes both DirectMusic and DirectSound
// and optionally sets up the synthesizer and default audio path.
// However, since this app never uses the default audio path, we don't bother
// to do that here.
g_pMusicManager = new CMusicManager();
if( FAILED( hr = g_pMusicManager->Initialize( hDlg ) ) )
return DXTRACE_ERR( TEXT("Initialize"), hr );
IDirectMusicPerformance8* pPerformance = g_pMusicManager->GetPerformance();
// Create a 3D audiopath with a 3d buffer.
// We can then play all segments into this buffer and directly control its
// 3D parameters.
if( FAILED( hr = pPerformance->CreateStandardAudioPath( DMUS_APATH_DYNAMIC_3D,
64, TRUE, &g_p3DAudioPath ) ) )
return DXTRACE_ERR( TEXT("CreateStandardAudioPath"), hr );
// Get the 3D buffer in the audio path.
if( FAILED( hr = g_p3DAudioPath->GetObjectInPath( 0, DMUS_PATH_BUFFER, 0,
GUID_NULL, 0, IID_IDirectSound3DBuffer,
(LPVOID*) &g_pDS3DBuffer ) ) )
return DXTRACE_ERR( TEXT("GetObjectInPath"), hr );
// 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 );
// Get the listener from the in the audio path.
if( FAILED( hr = g_p3DAudioPath->GetObjectInPath( 0, DMUS_PATH_PRIMARY_BUFFER, 0,
GUID_NULL, 0, IID_IDirectSound3DListener,
(LPVOID*) &g_pDSListener ) ) )
return DXTRACE_ERR( TEXT("GetObjectInPath"), hr );
// Get listener parameters
g_dsListenerParams.dwSize = sizeof(DS3DLISTENER);
g_pDSListener->GetAllParameters( &g_dsListenerParams );
return S_OK;
}
//-----------------------------------------------------------------------------
// 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 );
SendMessage( hDopplerSlider, TBM_SETPOS, TRUE, lDopplerSlider );
SendMessage( hRolloffSlider, TBM_SETPOS, TRUE, lRolloffSlider );
SendMessage( hMinDistSlider, TBM_SETPOS, TRUE, lMinDistSlider );
SendMessage( hMaxDistSlider, TBM_SETPOS, TRUE, lMaxDistSlider );
}
//-----------------------------------------------------------------------------
// Name: OnOpenAudioFile()
// Desc: Called when the user requests to open a sound file
//-----------------------------------------------------------------------------
VOID OnOpenAudioFile( HWND hDlg )
{
static TCHAR strFileName[MAX_PATH] = TEXT("");
static TCHAR strPath[MAX_PATH] = TEXT("");
// Get the default media path (something like C:\MSSDK\SAMPLES\DMUSIC\MEDIA)
if( '\0' == strPath[0] )
{
const TCHAR* szDir = DXUtil_GetDXSDKMediaPath();
strcpy( strPath, szDir );
}
// Setup the OPENFILENAME structure
OPENFILENAME ofn = { sizeof(OPENFILENAME), hDlg, NULL,
TEXT("DirectMusic Content Files\0*.sgt;*.mid;*.rmi\0Wave Files\0*.wav\0All Files\0*.*\0\0"), NULL,
0, 1, strFileName, MAX_PATH, NULL, 0, strPath,
TEXT("Open Content File"),
OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, 0, 0,
TEXT(".sgt"), 0, NULL, NULL };
if( g_pMusicSegment )
g_pMusicSegment->Stop( 0 );
// 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...") );
// 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_FILENAME, TEXT("Load aborted.") );
g_bAllowMovementTimer = TRUE;
return;
}
if( S_FALSE == LoadSegmentFile( hDlg, strFileName ) )
{
// Not a critical failure, so just update the status
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Could not create segment from file.") );
}
g_bAllowMovementTimer = TRUE;
// Remember the path for next time
strcpy( strPath, strFileName );
char* strLastSlash = strrchr( strPath, '\\' );
strLastSlash[0] = '\0';
}
//-----------------------------------------------------------------------------
// Name: LoadSegmentFile()
// Desc:
//-----------------------------------------------------------------------------
HRESULT LoadSegmentFile( HWND hDlg, TCHAR* strFileName )
{
HRESULT hr;
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
// Free any previous segment, and make a new one
SAFE_DELETE( g_pMusicSegment );
// Have the loader collect any garbage now that the old
// segment has been released
g_pMusicManager->CollectGarbage();
// For DirectMusic must know if the file is a standard MIDI file or not
// in order to load the correct instruments.
BOOL bMidiFile = FALSE;
if( strstr( strFileName, ".mid" ) != NULL ||
strstr( strFileName, ".rmi" ) != NULL )
{
bMidiFile = TRUE;
}
// Load the file into a DirectMusic segment, but don't download
// it to the default audio path -- use the 3D audio path instead
if( FAILED( g_pMusicManager->CreateSegmentFromFile( &g_pMusicSegment, strFileName,
FALSE, bMidiFile ) ) )
{
// Not a critical failure, so just update the status
return S_FALSE;
}
// Download the segment on the 3D audio path
if( FAILED( hr = g_pMusicSegment->Download( g_p3DAudioPath ) ) )
return DXTRACE_ERR( TEXT("Download"), hr );
// Update the UI controls to show the segment is loaded
SetDlgItemText( hDlg, IDC_FILENAME, strFileName );
EnablePlayUI( hDlg, TRUE );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnPlayAudio()
// Desc:
//-----------------------------------------------------------------------------
HRESULT OnPlayAudio( HWND hDlg )
{
HRESULT hr;
if( g_pMusicSegment == NULL )
return S_FALSE;
// Set the segment to repeat many times
if( FAILED( hr = g_pMusicSegment->SetRepeats( DMUS_SEG_REPEAT_INFINITE ) ) )
return DXTRACE_ERR( TEXT("SetRepeats"), hr );
// Play the segment and wait. The DMUS_SEGF_BEAT indicates to play on the
// next beat if there is a segment currently playing.
if( FAILED( hr = g_pMusicSegment->Play( DMUS_SEGF_BEAT, g_p3DAudioPath ) ) )
return DXTRACE_ERR( TEXT("Play"), hr );
EnablePlayUI( hDlg, FALSE );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: EnablePlayUI( hDlg,)
// Desc: Enables or disables the Play UI controls
//-----------------------------------------------------------------------------
VOID EnablePlayUI( HWND hDlg, BOOL bEnable )
{
if( bEnable )
{
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), TRUE );
SetFocus( GetDlgItem( hDlg, IDC_PLAY ) );
}
else
{
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), TRUE );
SetFocus( GetDlgItem( hDlg, IDC_STOP ) );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), FALSE );
}
}
//-----------------------------------------------------------------------------
// 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: 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] = { 0,0,0,0,0 };
static LONG s_lX = 0;
static LONG s_lY = 0;
HWND hWndGrid = GetDlgItem( hDlg, IDC_RENDER_WINDOW );
HDC hDC = GetDC( hWndGrid );
RECT rc;
// 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->SetPosition( g_dsBufferParams.vPosition.x,
g_dsBufferParams.vPosition.y,
g_dsBufferParams.vPosition.z, DS3D_IMMEDIATE );
g_pDS3DBuffer->SetVelocity( g_dsBufferParams.vVelocity.x,
g_dsBufferParams.vVelocity.y,
g_dsBufferParams.vVelocity.z, 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="3DAudio" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=3DAudio - 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 "3DAudio.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 "3DAudio.mak" CFG="3DAudio - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "3DAudio - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "3DAudio - 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)" == "3DAudio - 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" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /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 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)" == "3DAudio - 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" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /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 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 "3DAudio - Win32 Release"
# Name "3DAudio - Win32 Debug"
# Begin Group "Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\3DAudio.cpp
# End Source File
# End Group
# Begin Group "Resource"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\3DAudio.rc
# End Source File
# Begin Source File
SOURCE=.\bitmap1.bmp
# 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\dmutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\dmutil.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: "3DAudio"=.\3DAudio.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 3DAudio.dsp
!IF "$(CFG)" == ""
CFG=3DAudio - Win32 Debug
!MESSAGE No configuration specified. Defaulting to 3DAudio - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "3DAudio - Win32 Release" && "$(CFG)" != "3DAudio - 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 "3DAudio.mak" CFG="3DAudio - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "3DAudio - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "3DAudio - 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)" == "3DAudio - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\3DAudio.exe"
CLEAN :
-@erase "$(INTDIR)\3DAudio.obj"
-@erase "$(INTDIR)\3DAudio.res"
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\3DAudio.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" /Fp"$(INTDIR)\3DAudio.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\3DAudio.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\3DAudio.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=comctl32.lib dxerr8.lib winmm.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)\3DAudio.pdb" /machine:I386 /out:"$(OUTDIR)\3DAudio.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\3DAudio.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\3DAudio.res"
"$(OUTDIR)\3DAudio.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "3DAudio - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\3DAudio.exe"
CLEAN :
-@erase "$(INTDIR)\3DAudio.obj"
-@erase "$(INTDIR)\3DAudio.res"
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\3DAudio.exe"
-@erase "$(OUTDIR)\3DAudio.ilk"
-@erase "$(OUTDIR)\3DAudio.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" /Fp"$(INTDIR)\3DAudio.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\3DAudio.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\3DAudio.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=comctl32.lib dxerr8.lib winmm.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)\3DAudio.pdb" /debug /machine:I386 /out:"$(OUTDIR)\3DAudio.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\3DAudio.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\3DAudio.res"
"$(OUTDIR)\3DAudio.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("3DAudio.dep")
!INCLUDE "3DAudio.dep"
!ELSE
!MESSAGE Warning: cannot find "3DAudio.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "3DAudio - Win32 Release" || "$(CFG)" == "3DAudio - Win32 Debug"
SOURCE=.\3DAudio.cpp
"$(INTDIR)\3DAudio.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\3DAudio.rc
"$(INTDIR)\3DAudio.res" : $(SOURCE) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
SOURCE=..\..\common\src\dmutil.cpp
"$(INTDIR)\dmutil.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,151 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define IDC_STATIC -1
/////////////////////////////////////////////////////////////////////////////
#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
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAIN DIALOGEX 0, 0, 294, 146
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "DirectX 3D Audio Sample"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "Open &file...",IDC_SOUNDFILE,7,7,54,13
PUSHBUTTON "&Play",IDC_PLAY,7,123,50,14,WS_DISABLED
PUSHBUTTON "&Stop",IDC_STOP,57,123,50,14,WS_DISABLED
PUSHBUTTON "E&xit",IDCANCEL,237,123,50,14
EDITTEXT IDC_FILENAME,66,7,221,14,ES_AUTOHSCROLL | ES_READONLY
GROUPBOX "Sound properties",IDC_STATIC,7,25,200,94
RTEXT "Doppler factor (%)",IDC_STATIC,13,41,58,13,
SS_CENTERIMAGE
CTEXT "0",IDC_DOPPLERFACTOR,75,41,32,13,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CONTROL "Slider1",IDC_DOPPLER_SLIDER,"msctls_trackbar32",
TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,112,42,90,10
RTEXT "Rolloff factor (%)",IDC_STATIC,13,55,58,13,
SS_CENTERIMAGE
CTEXT "0",IDC_ROLLOFFFACTOR,75,55,32,13,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CONTROL "Slider2",IDC_ROLLOFF_SLIDER,"msctls_trackbar32",
TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,112,56,90,10
RTEXT "Min distance (m)",IDC_STATIC,13,70,58,13,SS_CENTERIMAGE
CTEXT "0",IDC_MINDISTANCE,75,70,32,13,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CONTROL "Slider3",IDC_MINDISTANCE_SLIDER,"msctls_trackbar32",
TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,112,71,90,10
RTEXT "Max distance (m)",IDC_STATIC,13,86,58,13,SS_CENTERIMAGE
CTEXT "0",IDC_MAXDISTANCE,75,86,32,13,SS_CENTERIMAGE,
WS_EX_STATICEDGE
CONTROL "Slider3",IDC_MAXDISTANCE_SLIDER,"msctls_trackbar32",
TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,112,87,90,10
CONTROL "Defer Settings",IDC_DEFER,"Button",BS_AUTOCHECKBOX |
BS_PUSHLIKE | WS_TABSTOP,49,102,53,11
GROUPBOX "Sound movement",IDC_STATIC,212,25,75,94,BS_LEFT
CONTROL 130,IDC_RENDER_WINDOW,"Static",SS_BITMAP,222,46,46,42,
WS_EX_CLIENTEDGE
CONTROL "Slider1",IDC_VERTICAL_SLIDER,"msctls_trackbar32",
TBS_VERT | TBS_TOP | TBS_NOTICKS | WS_TABSTOP,272,41,10,
50
CONTROL "Slider1",IDC_HORIZONTAL_SLIDER,"msctls_trackbar32",
TBS_TOP | TBS_NOTICKS | WS_TABSTOP,217,90,55,10
PUSHBUTTON "Apply Settings",IDC_APPLY,121,102,53,11
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 287
TOPMARGIN, 7
BOTTOMMARGIN, 137
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include <windows.h>\r\n"
"#define IDC_STATIC -1\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\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"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_GRID_BITMAP BITMAP DISCARDABLE "bitmap1.bmp"
#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: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,53 @@
//-----------------------------------------------------------------------------
//
// Sample Name: 3DAudio Sample
//
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
//
// GM/GS<47> Sound Set Copyright <20>1996, Roland Corporation U.S.
//
//-----------------------------------------------------------------------------
Description
===========
The 3DAudio sample application shows how to create a 3-D audiopath in
a DirectMusic performance, how to obtain an interface to a 3-D buffer
and listener in that path, and how to modify the parameters of the buffer
and listener.
Path
====
Source: DXSDK\Samples\Multimedia\DirectMusic\3DAudio
Executable: DXSDK\Samples\Multimedia\DirectMusic\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
=================
The 3DAudio sample is very similar in form to the PlayAudio sample. For
detailed programming notes on the basics this sample, refer to Programming
Notes section of the PlayAudio sample.

View File

@@ -0,0 +1,35 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by 3DAudio.rc
//
#define IDD_MAIN 101
#define IDR_MAINFRAME 102
#define IDB_GRID_BITMAP 130
#define IDC_PLAY 1002
#define IDC_STOP 1003
#define IDC_FILENAME 1004
#define IDC_MINDISTANCE_SLIDER 1005
#define IDC_MAXDISTANCE_SLIDER 1006
#define IDC_APPLY 1007
#define IDC_DOPPLER_SLIDER 1010
#define IDC_SOUNDFILE 1011
#define IDC_DOPPLERFACTOR 1012
#define IDC_ROLLOFFFACTOR 1013
#define IDC_ROLLOFF_SLIDER 1014
#define IDC_MINDISTANCE 1015
#define IDC_RENDER_WINDOW 1018
#define IDC_VERTICAL_SLIDER 1019
#define IDC_HORIZONTAL_SLIDER 1020
#define IDC_DEFER 1024
#define IDC_MAXDISTANCE 1025
// 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 1008
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,147 @@
# Microsoft Developer Studio Project File - Name="audiofx" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=audiofx - 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 "audiofx.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 "audiofx.mak" CFG="audiofx - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "audiofx - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "audiofx - 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)" == "audiofx - 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 dxguid.lib dxerr8.lib comctl32.lib winmm.lib dsound.lib /nologo /subsystem:windows /machine:I386 /stack:0x200000,0x200000
!ELSEIF "$(CFG)" == "audiofx - 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 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dxguid.lib dxerr8.lib comctl32.lib winmm.lib dsound.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x200000,0x200000
!ENDIF
# Begin Target
# Name "audiofx - Win32 Release"
# Name "audiofx - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\audiofx.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=.\audiofx.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\dmutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\dmutil.h
# End Source File
# 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: "audiofx"=.\audiofx.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,231 @@
# Microsoft Developer Studio Generated NMAKE File, Based on audiofx.dsp
!IF "$(CFG)" == ""
CFG=audiofx - Win32 Debug
!MESSAGE No configuration specified. Defaulting to audiofx - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "audiofx - Win32 Release" && "$(CFG)" != "audiofx - 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 "audiofx.mak" CFG="audiofx - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "audiofx - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "audiofx - 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)" == "audiofx - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\audiofx.exe"
CLEAN :
-@erase "$(INTDIR)\audiofx.obj"
-@erase "$(INTDIR)\audiofx.res"
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\audiofx.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)\audiofx.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)\audiofx.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\audiofx.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 dxguid.lib dxerr8.lib comctl32.lib winmm.lib dsound.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\audiofx.pdb" /machine:I386 /out:"$(OUTDIR)\audiofx.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\audiofx.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\audiofx.res"
"$(OUTDIR)\audiofx.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "audiofx - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\audiofx.exe"
CLEAN :
-@erase "$(INTDIR)\audiofx.obj"
-@erase "$(INTDIR)\audiofx.res"
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dsutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\audiofx.exe"
-@erase "$(OUTDIR)\audiofx.ilk"
-@erase "$(OUTDIR)\audiofx.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)\audiofx.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)\audiofx.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\audiofx.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 dxguid.lib dxerr8.lib comctl32.lib winmm.lib dsound.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\audiofx.pdb" /debug /machine:I386 /out:"$(OUTDIR)\audiofx.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\audiofx.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dsutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\audiofx.res"
"$(OUTDIR)\audiofx.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("audiofx.dep")
!INCLUDE "audiofx.dep"
!ELSE
!MESSAGE Warning: cannot find "audiofx.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "audiofx - Win32 Release" || "$(CFG)" == "audiofx - Win32 Debug"
SOURCE=.\audiofx.cpp
"$(INTDIR)\audiofx.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\audiofx.rc
"$(INTDIR)\audiofx.res" : $(SOURCE) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
SOURCE=..\..\common\src\dmutil.cpp
"$(INTDIR)\dmutil.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_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 "AudioFX - Sound effects applied to IDirectMusicSegment8"
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,55 @@
//-----------------------------------------------------------------------------
//
// Sample Name: AudioFx Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
// GM/GS<47> Sound Set Copyright <20>1996, Roland Corporation U.S.
//
//-----------------------------------------------------------------------------
Description
===========
The sample demonstrates:
(1) how to use standard effects (FX) with DirectMusic
(2) how to manipulate FX parameters - and what the results sounds like
Path
====
Source: DXSDK\Samples\Multimedia\DirectMusic\AudioFx
Executable: DXSDK\Samples\Multimedia\DirectMusic\Bin
User's Guide
============
- make sure a sound file is loaded (can be WAV, MID, or RMI), a default
sound file should be loaded for you.
- by default, no FX are enabled. try playing the sound to see what it
orginally sounds like.
- enable one or more FXs by checking the checkboxes on the left, under
the column "Enable".
- Hit play to hear the FX applied.
- you can adjust parameters for any FX by using the frame on the right.
(choose which FX 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
=================
To Enable a stand effect, ultimately, you need to obtain a LPDIRECTSOUNDBUFFER8
interface pointer. Fill one or more DSEFFECTDESC structs, and pass them into
IDirectSoundBuffer8::SetFX( ). This functionality is encapsulated by the sample
in the CSoundFXManager.
Much of the code is for manipulating the UI, and is loosely coupled with
the FX code.

View File

@@ -0,0 +1,80 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by audiofx.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

View File

@@ -0,0 +1,317 @@
//-----------------------------------------------------------------------------
// File: Audiopath.cpp
//
// Desc: Uses a 3D Audiopath, and shows off various methods of PlaySegmentEx
//
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <commdlg.h>
#include <commctrl.h>
#include <dmusicc.h>
#include <dmusici.h>
#include <cguid.h>
#include <dxerr8.h>
#include <tchar.h>
#include "resource.h"
#include "DMUtil.h"
#include "DXUtil.h"
//-----------------------------------------------------------------------------
// Function-prototypes
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
HRESULT OnInitDialog( HWND hDlg );
HRESULT PlaySegment( DWORD dwIndex );
HRESULT SetPosition( float fXPos, float fYPos, float fZPos );
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
CMusicManager* g_pMusicManager = NULL;
CMusicSegment* g_pMusicSegments[4] = { NULL,NULL,NULL,NULL };
IDirectMusicAudioPath* g_p3DAudiopath = 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;
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:
if( FAILED( hr = OnInitDialog( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnInitDialog"), hr );
MessageBox( hDlg, "Error initializing DirectMusic. Sample will now exit.",
"DirectMusic Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, 0 );
return TRUE;
}
break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDCANCEL:
EndDialog( hDlg, 0 );
break;
case IDC_PLAY1:
case IDC_PLAY2:
case IDC_PLAY3:
case IDC_PLAY4:
{
DWORD dwIndex = LOWORD(wParam) - IDC_PLAY1;
if( FAILED( hr = PlaySegment( dwIndex ) ) )
{
DXTRACE_ERR( TEXT("PlaySegment"), hr );
MessageBox( hDlg, "Error playing DirectMusic segment. Sample will now exit.",
"DirectMusic Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, 0 );
return TRUE;
}
break;
}
default:
return FALSE; // Didn't handle message
}
break;
case WM_HSCROLL:
{
// Set the 3D position
int nXPos = (int)SendDlgItemMessage( hDlg, IDC_XPOS, TBM_GETPOS, 0, 0 );
int nYPos = (int)SendDlgItemMessage( hDlg, IDC_YPOS, TBM_GETPOS, 0, 0 );
int nZPos = (int)SendDlgItemMessage( hDlg, IDC_ZPOS, TBM_GETPOS, 0, 0 );
SetDlgItemInt( hDlg, IDC_XDISPLAY, nXPos, TRUE );
SetDlgItemInt( hDlg, IDC_YDISPLAY, nYPos, TRUE );
SetDlgItemInt( hDlg, IDC_ZDISPLAY, nZPos, TRUE );
SetPosition( (float) nXPos, (float) nYPos, (float) nZPos );
break;
}
case WM_DESTROY:
{
// Cleanup everything
SAFE_RELEASE( g_p3DAudiopath );
for( int i=0; i<4; i++ )
SAFE_DELETE( g_pMusicSegments[i] );
SAFE_DELETE( g_pMusicManager );
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
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
g_pMusicManager = new CMusicManager();
if( FAILED( hr = g_pMusicManager->Initialize( hDlg ) ) )
return DXTRACE_ERR( TEXT("Initialize"), hr );
// Create a 3D Audiopath. This creates a synth port that feeds a 3d buffer.
// We can then play all segments into this buffer and directly control its
// 3D parameters.
IDirectMusicPerformance8* pPerformance = g_pMusicManager->GetPerformance();
if( FAILED( hr = pPerformance->CreateStandardAudioPath( DMUS_APATH_DYNAMIC_3D, 128,
TRUE, &g_p3DAudiopath ) ) )
return DXTRACE_ERR( TEXT("CreateStandardAudioPath"), hr );
// Set the default media path (something like C:\MSSDK\SAMPLES\MULTIMEDIA\MEDIA)
// to be used as the search directory for finding DirectMusic content.
if( FAILED( hr = g_pMusicManager->SetSearchDirectory( DXUtil_GetDXSDKMediaPath() ) ) )
return DXTRACE_ERR( TEXT("SetSearchDirectory"), hr );
TCHAR strFileNames[4][MAX_PATH] = { TEXT("Audiopath1.sgt"), // Lullaby theme
TEXT("Audiopath2.sgt"), // Snoring
TEXT("Audiopath3.wav"), // Muttering in sleep
TEXT("Audiopath4.sgt") // Rude awakening
};
// Create the segments from a file
for (DWORD dwIndex = 0;dwIndex < 4; dwIndex++)
{
if( FAILED( hr = g_pMusicManager->CreateSegmentFromFile( &g_pMusicSegments[dwIndex],
strFileNames[dwIndex] ) ) )
return DXTRACE_ERR( TEXT("CreateSegmentFromFile"), hr );
}
// Get the listener from the in the Audiopath.
IDirectSound3DListener* pDSListener = NULL;
if( FAILED( hr = g_p3DAudiopath->GetObjectInPath( 0, DMUS_PATH_PRIMARY_BUFFER, 0,
GUID_NULL, 0, IID_IDirectSound3DListener,
(LPVOID*) &pDSListener ) ) )
return DXTRACE_ERR( TEXT("GetObjectInPath"), hr );
// Set a new rolloff factor (1.0f is default)
if( FAILED( hr = pDSListener->SetRolloffFactor( 0.25f, DS3D_IMMEDIATE ) ) )
return DXTRACE_ERR( TEXT("SetRolloffFactor"), hr );
// Release the listener since we are done with it.
SAFE_RELEASE( pDSListener );
// Setup the sliders
HWND hSlider;
hSlider = GetDlgItem( hDlg, IDC_XPOS );
SendMessage( hSlider, TBM_SETRANGEMAX, TRUE, 20L );
SendMessage( hSlider, TBM_SETRANGEMIN, TRUE, -20L );
SendMessage( hSlider, TBM_SETPOS, TRUE, 0L );
hSlider = GetDlgItem( hDlg, IDC_YPOS );
SendMessage( hSlider, TBM_SETRANGEMAX, TRUE, 20L );
SendMessage( hSlider, TBM_SETRANGEMIN, TRUE, -20L );
SendMessage( hSlider, TBM_SETPOS, TRUE, 0L );
hSlider = GetDlgItem( hDlg, IDC_ZPOS );
SendMessage( hSlider, TBM_SETRANGEMAX, TRUE, 20L );
SendMessage( hSlider, TBM_SETRANGEMIN, TRUE, -20L );
SendMessage( hSlider, TBM_SETPOS, TRUE, 0L );
SetDlgItemInt( hDlg, IDC_XDISPLAY, 0, TRUE );
SetDlgItemInt( hDlg, IDC_YDISPLAY, 0, TRUE );
SetDlgItemInt( hDlg, IDC_ZDISPLAY, 0, TRUE );
SetPosition( 0, 0, 0 );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: PlaySegment()
// Desc:
//-----------------------------------------------------------------------------
HRESULT PlaySegment( DWORD dwIndex )
{
HRESULT hr = S_OK;
if( g_pMusicSegments[dwIndex] )
{
switch( dwIndex )
{
case 0:
// Lullaby theme. This should play as a primary segment.
hr = g_pMusicSegments[dwIndex]->Play( DMUS_SEGF_DEFAULT, g_p3DAudiopath );
break;
case 1:
case 2:
// Sound effects. These play as secondary segments so
// they can be triggered multiple times and will layer on top.
hr = g_pMusicSegments[dwIndex]->Play( DMUS_SEGF_DEFAULT | DMUS_SEGF_SECONDARY,
g_p3DAudiopath );
break;
case 3:
// Rude awakening. Notice that this also passes the Audiopath
// in pFrom, indicating that all segments currently playing on
// the Audiopath should be stopped at the exact time
// this starts.
IDirectMusicSegment8* pSegment = g_pMusicSegments[dwIndex]->GetSegment();
IDirectMusicPerformance8* pPerformance = g_pMusicManager->GetPerformance();
hr = pPerformance->PlaySegmentEx( pSegment, 0, NULL, 0, 0, 0,
g_p3DAudiopath, g_p3DAudiopath );
}
}
if( FAILED(hr) )
return DXTRACE_ERR( TEXT("PlaySegmentEx"), hr );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: SetPosition()
// Desc:
//-----------------------------------------------------------------------------
HRESULT SetPosition( float fXPos, float fYPos, float fZPos )
{
HRESULT hr;
if( NULL == g_p3DAudiopath )
return E_INVALIDARG;
// First, get the 3D interface from the buffer by using GetObjectInPath.
IDirectSound3DBuffer *pBuffer;
if( FAILED( hr = g_p3DAudiopath->GetObjectInPath( DMUS_PCHANNEL_ALL, DMUS_PATH_BUFFER, 0,
GUID_NULL, 0, IID_IDirectSound3DBuffer,
(void **)&pBuffer ) ) )
return DXTRACE_ERR( TEXT("GetObjectInPath"), hr );
// Then, set the coordinates and release.
if( FAILED( hr = pBuffer->SetPosition( fXPos, fYPos, fZPos, DS3D_IMMEDIATE ) ) )
return DXTRACE_ERR( TEXT("SetPosition"), hr );
SAFE_RELEASE( pBuffer );
return S_OK;
}

View File

@@ -0,0 +1,139 @@
# Microsoft Developer Studio Project File - Name="AudioPath" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=AudioPath - 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 "audiopath.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 "audiopath.mak" CFG="AudioPath - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "AudioPath - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "AudioPath - 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)" == "AudioPath - 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" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /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 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)" == "AudioPath - 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" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /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 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 "AudioPath - Win32 Release"
# Name "AudioPath - Win32 Debug"
# Begin Group "Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\AudioPath.cpp
# End Source File
# End Group
# Begin Group "Resource"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\AudioPath.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\dmutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\dmutil.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: "AudioPath"=.\audiopath.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 audiopath.dsp
!IF "$(CFG)" == ""
CFG=AudioPath - Win32 Debug
!MESSAGE No configuration specified. Defaulting to AudioPath - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "AudioPath - Win32 Release" && "$(CFG)" != "AudioPath - 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 "audiopath.mak" CFG="AudioPath - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "AudioPath - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "AudioPath - 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)" == "AudioPath - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\audiopath.exe"
CLEAN :
-@erase "$(INTDIR)\AudioPath.obj"
-@erase "$(INTDIR)\AudioPath.res"
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\audiopath.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" /Fp"$(INTDIR)\audiopath.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\AudioPath.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\audiopath.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=comctl32.lib dxerr8.lib winmm.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)\audiopath.pdb" /machine:I386 /out:"$(OUTDIR)\audiopath.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\AudioPath.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\AudioPath.res"
"$(OUTDIR)\audiopath.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "AudioPath - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\audiopath.exe"
CLEAN :
-@erase "$(INTDIR)\AudioPath.obj"
-@erase "$(INTDIR)\AudioPath.res"
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\audiopath.exe"
-@erase "$(OUTDIR)\audiopath.ilk"
-@erase "$(OUTDIR)\audiopath.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" /Fp"$(INTDIR)\audiopath.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\AudioPath.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\audiopath.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=comctl32.lib dxerr8.lib winmm.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)\audiopath.pdb" /debug /machine:I386 /out:"$(OUTDIR)\audiopath.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\AudioPath.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\AudioPath.res"
"$(OUTDIR)\audiopath.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("audiopath.dep")
!INCLUDE "audiopath.dep"
!ELSE
!MESSAGE Warning: cannot find "audiopath.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "AudioPath - Win32 Release" || "$(CFG)" == "AudioPath - Win32 Debug"
SOURCE=.\AudioPath.cpp
"$(INTDIR)\AudioPath.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\AudioPath.rc
"$(INTDIR)\AudioPath.res" : $(SOURCE) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
SOURCE=..\..\common\src\dmutil.cpp
"$(INTDIR)\dmutil.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,135 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define IDC_STATIC -1
/////////////////////////////////////////////////////////////////////////////
#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
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAIN DIALOG DISCARDABLE 0, 0, 322, 180
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "DirectMusic Audiopath Sample"
FONT 8, "MS Shell Dlg"
BEGIN
GROUPBOX "DirectMusic Segments",IDC_STATIC,7,7,308,80
PUSHBUTTON "Lullaby",IDC_PLAY1,15,19,63,13
PUSHBUTTON "Snore",IDC_PLAY2,15,35,63,13
PUSHBUTTON "Mumble",IDC_PLAY3,15,51,63,13
PUSHBUTTON "Rude Awakening",IDC_PLAY4,15,67,63,13
GROUPBOX "3D Positioning of AudioPath",IDC_STATIC,7,90,145,61
LTEXT "X",IDC_STATIC,13,101,8,8
CONTROL "Slider1",IDC_XPOS,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,19,99,108,14
LTEXT "Y",IDC_STATIC,13,117,8,8
CONTROL "Slider1",IDC_YPOS,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,19,115,108,14
LTEXT "Z",IDC_STATIC,13,133,8,8
CONTROL "Slider1",IDC_ZPOS,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,19,131,108,14
DEFPUSHBUTTON "Exit",IDCANCEL,265,157,50,14
LTEXT "Segment file. Start over if pressed twice. Plays as primary segment.",
IDC_STATIC,86,21,223,8
LTEXT "Segment file. Overlaps if pressed twice. Plays as secondary segment. ",
IDC_STATIC,86,37,223,8
LTEXT "Wave file. Overlaps if pressed twice. Plays as secondary segment. ",
IDC_STATIC,86,53,223,8
LTEXT "Segment file. Stops all sound on audiopath. Plays as primary segment.",
IDC_STATIC,86,69,223,8
GROUPBOX "Description",IDC_STATIC,157,90,158,61
LTEXT "All of the sounds above will play on a 3D audiopath. Click on the buttons to hear various methods of using PlaySegmentEx(). To the left, you can adjust the 3D position of the audiopath.",
IDC_STATIC,165,101,143,43
LTEXT "Static",IDC_ZDISPLAY,129,132,18,12
LTEXT "Static",IDC_YDISPLAY,129,116,18,12
LTEXT "Static",IDC_XDISPLAY,129,100,18,12
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 315
TOPMARGIN, 7
BOTTOMMARGIN, 171
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include <windows.h>\r\n"
"#define IDC_STATIC -1\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\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"
#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,76 @@
//-----------------------------------------------------------------------------
//
// Sample Name: AudioPath Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
// GM/GS<47> Sound Set Copyright <20>1996, Roland Corporation U.S.
//
//-----------------------------------------------------------------------------
Description
===========
The AudioPath sample demonstrates how different sounds can be played
on an audiopath, and how the parameters of all sounds are affected
by changes made on the audiopath.
Path
====
Source: DXSDK\Samples\Multimedia\DirectMusic\AudioPath
Executable: DXSDK\Samples\Multimedia\DirectMusic\Bin
User's Guide
============
Click Lullaby, Snore, and Mumble to play different sounds. Adjust the
3-D position of the sounds by using the sliders. Click Rude Awakening
to play a different sound and stop all other sounds.
Programming Notes
=================
The AudioPath sample is very similar in form to the PlayAudio sample. For
detailed programming notes on the basics this sample, refer to Programming
Notes section of the PlayAudio sample.
The AudioPath differs by showing some of the various uses of an
audiopath. Here's how:
* Upon init. See OnInitDialog()
1. Calls IDirectMusicPerformance8::CreateStandardAudioPath passing
in DMUS_APATH_DYNAMIC_3D to create a 3D audiopath named g_p3DAudiopath.
2. Uses the CMusicManager framework class to create CMusicSegments from a
list a list of files.
3. Gets the IDirectSound3DListener from the 3D audiopath, and
calls SetRolloffFactor to set a new rolloff factor.
* Upon 3D positoin slider change. See SetPosition()
1. Calls IDirectMusicAudioPath::GetObjectInPath on the 3D audiopath to
get the IDirectSound3DBuffer from it.
2. Calls IDirectSound3DBuffer::SetPosition to set a new 3D position on
the buffer of the audiopath.
3. Releases the 3D buffer.
* Upon button click. See PlaySegment().
- If its the first button, "Lullaby", this plays the primary segment
on the 3D audiopath by calling PlaySegmentEx passing in
DMUS_SEGF_DEFAULT and the 3D audiopath.
- If its the second or third button, this plays a secondary segment
on the 3D audiopath by calling PlaySegmentEx passing in
DMUS_SEGF_DEFAULT | DMUS_SEGF_SECONDARY and the 3D audiopath.
- If its the forth button, "Rude Awakening", this plays a primary segment
on the 3D audiopath by calling PlaySegmentEx passing in
the 3D audiopath, and setting the pFrom to the 3D audiopath.
This causes all currently playing segments to stop when this one starts.

View File

@@ -0,0 +1,35 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by AudioPath.rc
//
#define IDD_MAIN 101
#define IDR_MAINFRAME 102
#define IDR_ACCELERATOR1 131
#define IDC_PLAY 1002
#define IDC_STOP 1003
#define IDC_FILENAME 1004
#define IDC_TEMPO_SLIDER 1005
#define IDC_VOLUME_SLIDER 1006
#define IDC_LOOP_CHECK 1009
#define IDC_XPOS 1010
#define IDC_SOUNDFILE 1011
#define IDC_YPOS 1012
#define IDC_ZPOS 1013
#define IDC_XDISPLAY 1014
#define IDC_YDISPLAY 1015
#define IDC_ZDISPLAY 1016
#define IDC_PLAY1 2000
#define IDC_PLAY2 2001
#define IDC_PLAY3 2002
#define IDC_PLAY4 2003
// 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 1007
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

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: "AudioScripts"=.\AudioScripts.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 AudioScripts.dsp
!IF "$(CFG)" == ""
CFG=AudioScripts - Win32 Debug
!MESSAGE No configuration specified. Defaulting to AudioScripts - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "AudioScripts - Win32 Release" && "$(CFG)" != "AudioScripts - 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 "AudioScripts.mak" CFG="AudioScripts - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "AudioScripts - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "AudioScripts - 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)" == "AudioScripts - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\AudioScripts.exe"
CLEAN :
-@erase "$(INTDIR)\AudioScripts.obj"
-@erase "$(INTDIR)\AudioScripts.res"
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\AudioScripts.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" /Fp"$(INTDIR)\AudioScripts.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\AudioScripts.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\AudioScripts.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=dxerr8.lib winmm.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)\AudioScripts.pdb" /machine:I386 /out:"$(OUTDIR)\AudioScripts.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\AudioScripts.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\AudioScripts.res"
"$(OUTDIR)\AudioScripts.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "AudioScripts - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\AudioScripts.exe"
CLEAN :
-@erase "$(INTDIR)\AudioScripts.obj"
-@erase "$(INTDIR)\AudioScripts.res"
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\AudioScripts.exe"
-@erase "$(OUTDIR)\AudioScripts.ilk"
-@erase "$(OUTDIR)\AudioScripts.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" /Fp"$(INTDIR)\AudioScripts.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\AudioScripts.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\AudioScripts.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=dxerr8.lib winmm.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)\AudioScripts.pdb" /debug /machine:I386 /out:"$(OUTDIR)\AudioScripts.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\AudioScripts.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\AudioScripts.res"
"$(OUTDIR)\AudioScripts.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("AudioScripts.dep")
!INCLUDE "AudioScripts.dep"
!ELSE
!MESSAGE Warning: cannot find "AudioScripts.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "AudioScripts - Win32 Release" || "$(CFG)" == "AudioScripts - Win32 Debug"
SOURCE=.\AudioScripts.cpp
"$(INTDIR)\AudioScripts.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\AudioScripts.rc
"$(INTDIR)\AudioScripts.res" : $(SOURCE) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
SOURCE=..\..\common\src\dmutil.cpp
"$(INTDIR)\dmutil.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,352 @@
//-----------------------------------------------------------------------------
// File: AudioScripts.cpp
//
// Desc: Plays a script file using DirectMusic
//
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <commdlg.h>
#include <objbase.h>
#include <stdio.h>
#include <dmusicc.h>
#include <dmusici.h>
#include <dxerr8.h>
#include "resource.h"
#include <tchar.h>
#include "DMUtil.h"
#include "DXUtil.h"
//-----------------------------------------------------------------------------
// Function-prototypes
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
HRESULT OnInitDialog( HWND hDlg );
HRESULT OnChangeScriptFile( HWND hDlg, TCHAR* strFileName );
HRESULT OnCallRoutine( HWND hDlg, TCHAR* strRoutine );
HRESULT UpdateVariables( HWND hDlg );
HRESULT SetVariable( HWND hDlg, int nIDDlgItem );
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
CMusicManager* g_pMusicManager = NULL;
CMusicScript* g_pMusicScript = 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;
// 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:
if( FAILED( hr = OnInitDialog( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnInitDialog"), hr );
MessageBox( hDlg, "Error initializing DirectMusic. Sample will now exit.",
"DirectMusic Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, 0 );
return TRUE;
}
break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDC_COMBO_SCRIPT:
if ( HIWORD(wParam) == CBN_SELCHANGE )
{
char strFile[MAX_PATH] = "";
GetDlgItemText( hDlg, IDC_COMBO_SCRIPT, strFile, MAX_PATH );
if( FAILED( hr = OnChangeScriptFile( hDlg, strFile ) ) )
{
DXTRACE_ERR( TEXT("OnChangeScriptFile"), hr );
MessageBox( hDlg, "Error loading script. Sample will now exit.",
"DirectMusic Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, 0 );
return TRUE;
}
break;
}
case IDC_BUTTON_ROUTINE1:
case IDC_BUTTON_ROUTINE2:
case IDC_BUTTON_ROUTINE3:
if ( HIWORD(wParam) == BN_CLICKED )
{
TCHAR pstrRoutine[] = TEXT("RoutineX");
pstrRoutine[_tcslen(pstrRoutine) - 1] = '1' + (LOWORD(wParam) - IDC_BUTTON_ROUTINE1);
if( FAILED( hr = OnCallRoutine(hDlg, pstrRoutine) ) )
{
DXTRACE_ERR( TEXT("OnCallRoutine"), hr );
MessageBox( hDlg, "Error calling routine. Sample will now exit.",
"DirectMusic Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, 0 );
return TRUE;
}
}
break;
case IDC_EDIT_VARIABLE1:
case IDC_EDIT_VARIABLE2:
if ( HIWORD(wParam) == EN_KILLFOCUS )
{
if( FAILED( hr = SetVariable( hDlg, LOWORD(wParam) ) ) )
{
DXTRACE_ERR( TEXT("SetVariable"), hr );
MessageBox( hDlg, "Error setting variable. Sample will now exit.",
"DirectMusic Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, 0 );
return TRUE;
}
}
break;
case IDOK:
if ( HIWORD(wParam) == BN_CLICKED )
{
// This is sent by edit boxes to click the default button
// (which we don't have) when Enter is pressed.
HWND hwndFocus = GetFocus();
int nIDDlgItem = 0;
if ( hwndFocus == GetDlgItem(hDlg, IDC_EDIT_VARIABLE1) )
nIDDlgItem = IDC_EDIT_VARIABLE1;
else if ( hwndFocus == GetDlgItem(hDlg, IDC_EDIT_VARIABLE2) )
nIDDlgItem = IDC_EDIT_VARIABLE2;
if ( nIDDlgItem != 0)
{
if( FAILED( hr = SetVariable( hDlg, nIDDlgItem ) ) )
{
DXTRACE_ERR( TEXT("SetVariable"), hr );
MessageBox( hDlg, "Error setting variable. Sample will now exit.",
"DirectMusic Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, 0 );
return TRUE;
}
// Select the value to show that Enter committed it
SendMessage(hwndFocus, EM_SETSEL, 0, -1);
}
}
break;
case IDCANCEL:
EndDialog( hDlg, 0 );
break;
default:
return FALSE; // Didn't handle message
}
break;
case WM_DESTROY:
// Cleanup everything
SAFE_DELETE( g_pMusicScript );
SAFE_DELETE( g_pMusicManager );
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
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
g_pMusicManager = new CMusicManager();
if( FAILED( hr = g_pMusicManager->Initialize( hDlg ) ) )
return hr;
// Set the default media path (something like C:\MSSDK\SAMPLES\MULTIMEDIA\MEDIA)
// to be used as the search directory for finding DirectMusic content.
g_pMusicManager->SetSearchDirectory( DXUtil_GetDXSDKMediaPath() );
// Fill the dropdown script choices
SendDlgItemMessage( hDlg, IDC_COMBO_SCRIPT, CB_ADDSTRING,
0, (LPARAM) "ScriptDemoBasic.spt" );
SendDlgItemMessage( hDlg, IDC_COMBO_SCRIPT, CB_ADDSTRING,
0, (LPARAM) "ScriptDemoBaseball.spt" );
// Load ScriptDemoBasic
OnChangeScriptFile( hDlg, "ScriptDemoBasic.spt" );
SendDlgItemMessage( hDlg, IDC_COMBO_SCRIPT, CB_SELECTSTRING,
-1, (LPARAM) "ScriptDemoBasic.spt" );
if( g_pMusicScript )
{
if( FAILED( hr = UpdateVariables( hDlg ) ) )
return hr;
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnChangeScriptFile()
// Desc: Called when the user changes script files from the dropdown.
//-----------------------------------------------------------------------------
HRESULT OnChangeScriptFile( HWND hDlg, TCHAR* strFileName )
{
HRESULT hr;
// Free any previous script, and make a new one
SAFE_DELETE( g_pMusicScript );
// Have the loader collect any garbage now that the old
// script has been released
g_pMusicManager->CollectGarbage();
// Load the script file
if( FAILED( hr = g_pMusicManager->CreateScriptFromFile( &g_pMusicScript, strFileName ) ) )
return hr;
// Get and display a string from the script describing itself.
// Here we will ignore any errors. The script doesn't have to tell
// about itself if it doesn't want to.
if( SUCCEEDED( g_pMusicScript->CallRoutine( TEXT("GetAbout") ) ) )
{
// Scripts are normally designed to return Number and Object variables.
// Retrieving a string is rarely used, and requires use of the more complicated
// VARIANT data type.
VARIANT varValue;
VariantInit(&varValue);
if( SUCCEEDED( g_pMusicScript->GetScript()->GetVariableVariant( L"About",
&varValue, NULL ) ) )
{
if (varValue.vt == VT_BSTR)
{
char strAbout[5000] = "";
wcstombs( strAbout, varValue.bstrVal, 5000 );
strAbout[4999] = '\0';
SetDlgItemText( hDlg, IDC_EDIT_ABOUT, strAbout );
}
// The returned VARIANT contains data fields that
// must be freed or memory will be leaked
VariantClear(&varValue);
}
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnCallRoutine()
// Desc:
//-----------------------------------------------------------------------------
HRESULT OnCallRoutine( HWND hDlg, TCHAR* strRoutine )
{
HRESULT hr;
if( FAILED( hr = g_pMusicScript->CallRoutine( strRoutine ) ) )
return DXTRACE_ERR( TEXT("CallRoutine"), hr );
if( FAILED( hr = UpdateVariables( hDlg ) ) )
return DXTRACE_ERR( TEXT("UpdateVariables"), hr );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: UpdateVariables()
// Desc:
//-----------------------------------------------------------------------------
HRESULT UpdateVariables( HWND hDlg )
{
LONG lVal = 0;
HRESULT hr;
if( FAILED( hr = g_pMusicScript->GetVariableNumber( TEXT("Variable1"), &lVal ) ) )
return DXTRACE_ERR( TEXT("GetVariableNumber"), hr );
SetDlgItemInt( hDlg, IDC_EDIT_VARIABLE1, lVal, TRUE );
if( FAILED( hr = g_pMusicScript->GetVariableNumber( TEXT("Variable2"), &lVal ) ) )
return DXTRACE_ERR( TEXT("GetVariableNumber"), hr );
SetDlgItemInt( hDlg, IDC_EDIT_VARIABLE2, lVal, TRUE );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: SetVariable()
// Desc:
//-----------------------------------------------------------------------------
HRESULT SetVariable( HWND hDlg, int nIDDlgItem )
{
HRESULT hr;
BOOL fIntConvertOK = FALSE;
int iVal = GetDlgItemInt( hDlg, nIDDlgItem, &fIntConvertOK, TRUE );
TCHAR* pstrVariable = (nIDDlgItem == IDC_EDIT_VARIABLE1) ? TEXT("Variable1") : TEXT("Variable2");
hr = g_pMusicScript->SetVariableNumber( pstrVariable, iVal );
if( FAILED(hr) )
return hr;
return S_OK;
}

View File

@@ -0,0 +1,139 @@
# Microsoft Developer Studio Project File - Name="AudioScripts" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=AudioScripts - 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 "AudioScripts.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 "AudioScripts.mak" CFG="AudioScripts - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "AudioScripts - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "AudioScripts - 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)" == "AudioScripts - 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" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /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 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)" == "AudioScripts - 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" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /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 dxerr8.lib winmm.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 "AudioScripts - Win32 Release"
# Name "AudioScripts - Win32 Debug"
# Begin Group "Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\AudioScripts.cpp
# End Source File
# End Group
# Begin Group "Resource"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\AudioScripts.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\dmutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\dmutil.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,120 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define IDC_STATIC -1
/////////////////////////////////////////////////////////////////////////////
#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
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAIN DIALOG DISCARDABLE 0, 0, 225, 257
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "DirectMusic Script Demo"
FONT 8, "MS Shell Dlg"
BEGIN
PUSHBUTTON "E&xit",IDCANCEL,168,7,50,14
LTEXT "Script File:",IDC_STATIC,7,10,36,8
COMBOBOX IDC_COMBO_SCRIPT,52,8,103,68,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Routine&1",IDC_BUTTON_ROUTINE1,7,25,62,14
PUSHBUTTON "Routine&2",IDC_BUTTON_ROUTINE2,81,25,62,14
PUSHBUTTON "Routine&3",IDC_BUTTON_ROUTINE3,155,25,62,14
EDITTEXT IDC_EDIT_VARIABLE1,48,46,50,14,ES_AUTOHSCROLL |
ES_NUMBER
LTEXT "Variable1:",IDC_STATIC,7,49,32,8
EDITTEXT IDC_EDIT_VARIABLE2,156,46,50,14,ES_AUTOHSCROLL
LTEXT "Variable2:",IDC_STATIC,115,49,32,8
EDITTEXT IDC_EDIT_ABOUT,7,76,211,172,ES_MULTILINE | ES_READONLY |
WS_VSCROLL
LTEXT "Script Notes:",IDC_STATIC,7,66,47,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 218
TOPMARGIN, 7
BOTTOMMARGIN, 248
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include <windows.h>\r\n"
"#define IDC_STATIC -1\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\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"
#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,41 @@
//-----------------------------------------------------------------------------
//
// Sample Name: AudioScripts Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
// GM/GS<47> Sound Set Copyright <20>1996, Roland Corporation U.S.
//
//-----------------------------------------------------------------------------
Description
===========
The AudioScripts sample demonstrates how an application and a DirectMusic
script work together. The script reads and writes to variables in the
application, and the application calls routines in the script that
play segments.
The sample also demonstrates how waves can be played as variations
in a segment.
Path
====
Source: DXSDK\Samples\Multimedia\DirectMusic\AudioScripts
Executable: DXSDK\Samples\Multimedia\DirectMusic\Bin
User's Guide
============
Select ScriptDemoBasic.spt from the Script File list box. Play a segment
by clicking Routine 1. Click Routine 2 to play an ending and stop playback.
Play the segment again and click Routine 3 several times. Note how Variable
1 reflects the number of times the button has been clicked, and how the
music changes in response to each click.
Select ScriptDemoBaseball.spt from the list box. Click Routine 1 to play
various calls from a vendor. Click Routine 2 to play various musical motifs.
Change the score by entering different values in the Variable1 and Variable2
text boxes. Click Routine 3 to hear the score. If the score for either team
exceeds 10, the crowd roars and then falls silent.

View File

@@ -0,0 +1,24 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by AudioScripts.rc
//
#define IDD_MAIN 101
#define IDR_MAINFRAME 102
#define IDC_COMBO_SCRIPT 1000
#define IDC_EDIT_ABOUT 1001
#define IDC_BUTTON_ROUTINE1 2001
#define IDC_BUTTON_ROUTINE2 2002
#define IDC_BUTTON_ROUTINE3 2003
#define IDC_EDIT_VARIABLE1 3001
#define IDC_EDIT_VARIABLE2 3002
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1020
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

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: "MusicTool"=.\MusicTool.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,230 @@
# Microsoft Developer Studio Generated NMAKE File, Based on MusicTool.dsp
!IF "$(CFG)" == ""
CFG=MusicTool - Win32 Debug
!MESSAGE No configuration specified. Defaulting to MusicTool - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "MusicTool - Win32 Release" && "$(CFG)" != "MusicTool - 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 "MusicTool.mak" CFG="MusicTool - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "MusicTool - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "MusicTool - 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)" == "MusicTool - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\MusicTool.exe"
CLEAN :
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\echotool.obj"
-@erase "$(INTDIR)\MusicTool.obj"
-@erase "$(INTDIR)\MusicTool.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\MusicTool.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" /Fp"$(INTDIR)\MusicTool.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\MusicTool.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\MusicTool.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=dxerr8.lib winmm.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)\MusicTool.pdb" /machine:I386 /out:"$(OUTDIR)\MusicTool.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\echotool.obj" \
"$(INTDIR)\MusicTool.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\MusicTool.res"
"$(OUTDIR)\MusicTool.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "MusicTool - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\MusicTool.exe"
CLEAN :
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\echotool.obj"
-@erase "$(INTDIR)\MusicTool.obj"
-@erase "$(INTDIR)\MusicTool.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\MusicTool.exe"
-@erase "$(OUTDIR)\MusicTool.ilk"
-@erase "$(OUTDIR)\MusicTool.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" /Fp"$(INTDIR)\MusicTool.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\MusicTool.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\MusicTool.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=dxerr8.lib winmm.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)\MusicTool.pdb" /debug /machine:I386 /out:"$(OUTDIR)\MusicTool.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\echotool.obj" \
"$(INTDIR)\MusicTool.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\MusicTool.res"
"$(OUTDIR)\MusicTool.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("MusicTool.dep")
!INCLUDE "MusicTool.dep"
!ELSE
!MESSAGE Warning: cannot find "MusicTool.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "MusicTool - Win32 Release" || "$(CFG)" == "MusicTool - Win32 Debug"
SOURCE=.\echotool.cpp
"$(INTDIR)\echotool.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\MusicTool.cpp
"$(INTDIR)\MusicTool.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\MusicTool.rc
"$(INTDIR)\MusicTool.res" : $(SOURCE) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
SOURCE=..\..\common\src\dmutil.cpp
"$(INTDIR)\dmutil.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,293 @@
//-----------------------------------------------------------------------------
// File: EchoTool.cpp
//
// Desc: Implements an object based on IDirectMusicTool
// that provides echoing effects.
//
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#include <dmusici.h>
#include "EchoTool.h"
//-----------------------------------------------------------------------------
// Name: CEchoTool::CEchoTool()
// Desc:
//-----------------------------------------------------------------------------
CEchoTool::CEchoTool()
{
m_cRef = 1; // Set to 1 so one call to Release() will free this
m_dwEchoNum = 3; // Default to 3 echoes per note
m_mtDelay = DMUS_PPQ / 2; // Default to 8th note echoes
InitializeCriticalSection(&m_CrSec);
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::~CEchoTool()
// Desc:
//-----------------------------------------------------------------------------
CEchoTool::~CEchoTool()
{
DeleteCriticalSection(&m_CrSec);
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::QueryInterface()
// Desc:
//-----------------------------------------------------------------------------
STDMETHODIMP CEchoTool::QueryInterface(const IID &iid, void **ppv)
{
if (iid == IID_IUnknown || iid == IID_IDirectMusicTool)
{
*ppv = static_cast<IDirectMusicTool*>(this);
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
reinterpret_cast<IUnknown*>(this)->AddRef();
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::AddRef()
// Desc:
//-----------------------------------------------------------------------------
STDMETHODIMP_(ULONG) CEchoTool::AddRef()
{
return InterlockedIncrement(&m_cRef);
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::Release()
// Desc:
//-----------------------------------------------------------------------------
STDMETHODIMP_(ULONG) CEchoTool::Release()
{
if( 0 == InterlockedDecrement(&m_cRef) )
{
delete this;
return 0;
}
return m_cRef;
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::Init()
// Desc:
//-----------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE CEchoTool::Init( IDirectMusicGraph* pGraph )
{
// This tool has no need to do any type of initialization.
return E_NOTIMPL;
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::GetMsgDeliveryType()
// Desc:
//-----------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE CEchoTool::GetMsgDeliveryType( DWORD* pdwDeliveryType )
{
// This tool wants messages immediately.
// This is the default, so returning E_NOTIMPL
// would work. The other method is to specifically
// set *pdwDeliveryType to the delivery type, DMUS_PMSGF_TOOL_IMMEDIATE,
// DMUS_PMSGF_TOOL_QUEUE, or DMUS_PMSGF_TOOL_ATTIME.
*pdwDeliveryType = DMUS_PMSGF_TOOL_IMMEDIATE;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::GetMediaTypeArraySize()
// Desc:
//-----------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE CEchoTool::GetMediaTypeArraySize( DWORD* pdwNumElements )
{
// This tool only wants note messages, patch messages, sysex, and MIDI messages, so set
// *pdwNumElements to 4.
*pdwNumElements = 4;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::GetMediaTypes()
// Desc:
//-----------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE CEchoTool::GetMediaTypes( DWORD** padwMediaTypes,
DWORD dwNumElements )
{
// Fill in the array padwMediaTypes with the type of
// messages this tool wants to process. In this case,
// dwNumElements will be 3, since that is what this
// tool returns from GetMediaTypeArraySize().
if( dwNumElements == 4 )
{
// Set the elements in the array to DMUS_PMSGT_NOTE,
// DMUS_PMSGT_MIDI, and DMUS_PMSGT_PATCH
(*padwMediaTypes)[0] = DMUS_PMSGT_NOTE;
(*padwMediaTypes)[1] = DMUS_PMSGT_MIDI;
(*padwMediaTypes)[2] = DMUS_PMSGT_PATCH;
(*padwMediaTypes)[3] = DMUS_PMSGT_SYSEX;
return S_OK;
}
else
{
// This should never happen
return E_FAIL;
}
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::ProcessPMsg()
// Desc:
//-----------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE CEchoTool::ProcessPMsg( IDirectMusicPerformance* pPerf,
DMUS_PMSG* pPMsg )
{
DWORD dwCount;
DWORD dwEchoNum;
MUSIC_TIME mtDelay;
// SetEchoNum() and SetDelay() use these member variables,
// so use a critical section to make them thread-safe.
EnterCriticalSection(&m_CrSec);
dwEchoNum = m_dwEchoNum;
mtDelay = m_mtDelay;
LeaveCriticalSection(&m_CrSec);
// Returning S_FREE frees the message. If StampPMsg()
// fails, there is no destination for this message so
// free it.
if(( NULL == pPMsg->pGraph ) ||
FAILED(pPMsg->pGraph->StampPMsg(pPMsg)))
{
return DMUS_S_FREE;
}
// The Tool is set up to only receive messages of types
// DMUS_PMSGT_NOTE, DMUS_PMSGT_MIDI, DMUS_PMSGT_SYSEX, or DMUS_PMSGT_PATCH
// We use the DX8 ClonePMsg method to make a copy of the pmsg and
// send it to a pchannel in the next pchannel group.
// If it's a note, we also doctor the velocity.
IDirectMusicPerformance8 *pPerf8;
if (SUCCEEDED(pPerf->QueryInterface(IID_IDirectMusicPerformance8,(void **)&pPerf8)))
{
for( dwCount = 1; dwCount <= dwEchoNum; dwCount++ )
{
DMUS_PMSG *pClone;
if( SUCCEEDED( pPerf8->ClonePMsg( pPMsg,&pClone)))
{
// Add to the time of the echoed note
pClone->mtTime += (dwCount * mtDelay);
if (pPMsg->dwType == DMUS_PMSGT_NOTE )
{
DMUS_NOTE_PMSG *pNote = (DMUS_NOTE_PMSG*)pPMsg;
DMUS_NOTE_PMSG *pCloneNote = (DMUS_NOTE_PMSG*)pClone;
// Reduce the volume of the echoed note
// percentage of reduction in velocity increases with each echo
pCloneNote->bVelocity = (BYTE) (pNote->bVelocity -
((pNote->bVelocity * (dwCount * 15))/100));
}
// Set the note so only MUSIC_TIME is valid.
// REFERENCE_TIME will be recomputed inside
// SendPMsg()
pClone->dwFlags = DMUS_PMSGF_MUSICTIME;
pClone->dwPChannel = pPMsg->dwPChannel +
(16*dwCount);
// Queue the echoed PMsg
pPerf->SendPMsg(pClone );
}
}
pPerf8->Release();
}
// Return DMUS_S_REQUEUE so the original message is requeued
return DMUS_S_REQUEUE;
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::Flush()
// Desc:
//-----------------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE CEchoTool::Flush( IDirectMusicPerformance* pPerf,
DMUS_PMSG* pDMUS_PMSG,
REFERENCE_TIME rt)
{
// This tool does not need to flush.
return E_NOTIMPL;
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::SetEchoNum()
// Desc:
//-----------------------------------------------------------------------------
void CEchoTool::SetEchoNum( DWORD dwEchoNum )
{
// ProcessPMsg() uses m_dwEchoNum, so use a critical
// section to make it thread-safe.
if( dwEchoNum <= MAX_ECHOES )
{
EnterCriticalSection(&m_CrSec);
m_dwEchoNum = dwEchoNum;
LeaveCriticalSection(&m_CrSec);
}
}
//-----------------------------------------------------------------------------
// Name: CEchoTool::SetDelay()
// Desc:
//-----------------------------------------------------------------------------
void CEchoTool::SetDelay( MUSIC_TIME mtDelay )
{
// ProcessPMsg() uses m_mtDelay, so use a critical
// section to make it thread-safe.
EnterCriticalSection(&m_CrSec);
m_mtDelay = mtDelay;
LeaveCriticalSection(&m_CrSec);
}

View File

@@ -0,0 +1,49 @@
//-----------------------------------------------------------------------------
// File: EchoTool.h
//
// Desc: Implements an object based on IDirectMusicTool
// that provides echoing effects.
//
// Copyright (c) 1998-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#ifndef _ECHOTOOL_H
#define _ECHOTOOL_H
#include <dmusici.h>
// Maximum echoes is 4 (the number of extra groups opened
// on the port in helper.cpp)
#define MAX_ECHOES 4
class CEchoTool : public IDirectMusicTool
{
public:
CEchoTool();
~CEchoTool();
public:
// IUnknown
virtual STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
virtual STDMETHODIMP_(ULONG) AddRef();
virtual STDMETHODIMP_(ULONG) Release();
// IDirectMusicTool
HRESULT STDMETHODCALLTYPE Init( IDirectMusicGraph* pGraph );
HRESULT STDMETHODCALLTYPE GetMsgDeliveryType( DWORD* pdwDeliveryType );
HRESULT STDMETHODCALLTYPE GetMediaTypeArraySize( DWORD* pdwNumElements );
HRESULT STDMETHODCALLTYPE GetMediaTypes( DWORD** padwMediaTypes, DWORD dwNumElements) ;
HRESULT STDMETHODCALLTYPE ProcessPMsg( IDirectMusicPerformance* pPerf, DMUS_PMSG* pDMUS_PMSG );
HRESULT STDMETHODCALLTYPE Flush( IDirectMusicPerformance* pPerf, DMUS_PMSG* pDMUS_PMSG, REFERENCE_TIME rt );
private:
long m_cRef; // Reference counter
DWORD m_dwEchoNum; // Number of echoes to generate
MUSIC_TIME m_mtDelay; // Delay time between echoes
CRITICAL_SECTION m_CrSec; // To make SetEchoNum() and SetDelay() thread-safe
public:
// Public class methods
void SetEchoNum( DWORD dwEchoNum );
void SetDelay( MUSIC_TIME mtDelay );
};
#endif // _ECHOTOOL_H

View File

@@ -0,0 +1,534 @@
//-----------------------------------------------------------------------------
// File: MusicTool.cpp
//
// Desc: Plays a primary segment using DirectMusic
//
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <commdlg.h>
#include <commctrl.h>
#include <dmusicc.h>
#include <dmusici.h>
#include <dxerr8.h>
#include <cguid.h>
#include <tchar.h>
#include "resource.h"
#include "DMUtil.h"
#include "DXUtil.h"
#include "EchoTool.h"
//-----------------------------------------------------------------------------
// Function-prototypes
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
HRESULT OnInitDialog( HWND hDlg );
HRESULT ProcessDirectMusicMessages( HWND hDlg );
VOID OnOpenSoundFile( HWND hDlg );
HRESULT LoadSegmentFile( HWND hDlg, TCHAR* strFileName );
HRESULT OnPlaySegment( HWND hDlg );
VOID EnablePlayUI( HWND hDlg, BOOL bEnable );
HRESULT OnChangeTool( HWND hDlg );
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
HINSTANCE g_hInst = NULL;
CMusicManager* g_pMusicManager = NULL;
CMusicSegment* g_pMusicSegment = NULL;
CEchoTool* g_pEchoTool = NULL;
IDirectMusicTool* g_pCurrentTool = NULL;
IDirectMusicGraph* g_pGraph = NULL;
HANDLE g_hDMusicMessageEvent = 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 )
{
HWND hDlg = NULL;
BOOL bDone = FALSE;
int nExitCode;
HRESULT hr;
DWORD dwResult;
MSG msg;
g_hInst = hInst;
// Display the main dialog box.
hDlg = CreateDialog( hInst, MAKEINTRESOURCE(IDD_MAIN),
NULL, MainDlgProc );
while( !bDone )
{
dwResult = MsgWaitForMultipleObjects( 1, &g_hDMusicMessageEvent,
FALSE, INFINITE, QS_ALLEVENTS );
switch( dwResult )
{
case WAIT_OBJECT_0 + 0:
// g_hDPMessageEvent is signaled, so there are
// DirectPlay messages available
if( FAILED( hr = ProcessDirectMusicMessages( hDlg ) ) )
{
DXTRACE_ERR( TEXT("ProcessDirectMusicMessages"), hr );
return FALSE;
}
break;
case WAIT_OBJECT_0 + 1:
// Windows messages are available
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if( !IsDialogMessage( hDlg, &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
if( msg.message == WM_QUIT )
{
nExitCode = (int)msg.wParam;
bDone = TRUE;
DestroyWindow( hDlg );
}
}
break;
}
}
return nExitCode;
}
//-----------------------------------------------------------------------------
// 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:
if( FAILED( hr = OnInitDialog( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnInitDialog"), hr );
MessageBox( hDlg, "Error initializing DirectMusic. Sample will now exit.",
"DirectMusic Sample", MB_OK | MB_ICONERROR );
PostQuitMessage( IDABORT );
return FALSE;
}
break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDC_SOUNDFILE:
OnOpenSoundFile( hDlg );
break;
case IDCANCEL:
PostQuitMessage( IDCANCEL );
break;
case IDC_PLAY:
if( FAILED( hr = OnPlaySegment( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnPlaySegment"), hr );
MessageBox( hDlg, "Error playing DirectMusic segment. "
"Sample will now exit.", "DirectMusic Sample",
MB_OK | MB_ICONERROR );
PostQuitMessage( IDABORT );
}
break;
case IDC_STOP:
g_pMusicSegment->Stop( DMUS_SEGF_BEAT );
EnablePlayUI( hDlg, TRUE );
break;
case IDC_TOOL_COMBO:
OnChangeTool( hDlg );
break;
default:
return FALSE; // Didn't handle message
}
break;
case WM_DESTROY:
// Cleanup everything
SAFE_DELETE( g_pMusicSegment );
SAFE_DELETE( g_pMusicManager );
SAFE_DELETE( g_pEchoTool );
CloseHandle( g_hDMusicMessageEvent );
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;
LONG lIndex;
// Set the icon for this dialog.
HICON hIcon = LoadIcon( g_hInst, MAKEINTRESOURCE( IDR_MAINFRAME ) );
SendMessage( hDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon ); // Set big icon
SendMessage( hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon ); // Set small icon
g_hDMusicMessageEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
g_pMusicManager = new CMusicManager();
// Init DirectMusic with a default audio path
hr = g_pMusicManager->Initialize( hDlg );
IDirectMusicPerformance8* pPerformance = g_pMusicManager->GetPerformance();
IDirectMusicAudioPath8* pDefaultAudioPath = g_pMusicManager->GetDefaultAudioPath();
// Create a DirectMusicGraph, and tell the preformance about it
hr = pDefaultAudioPath->GetObjectInPath( 0, DMUS_PATH_PERFORMANCE_GRAPH, 0,
GUID_NULL, 0, IID_IDirectMusicGraph,
(LPVOID*) &g_pGraph );
if( FAILED( hr ) )
return DXTRACE_ERR( TEXT("GetObjectInPath"), hr );
// Register segment notification
GUID guid = GUID_NOTIFICATION_SEGMENT;
if( FAILED( hr = pPerformance->AddNotificationType( guid ) ) )
return DXTRACE_ERR( TEXT("AddNotificationType"), hr );
if( FAILED( hr = pPerformance->SetNotificationHandle( g_hDMusicMessageEvent, 0 ) ) )
return DXTRACE_ERR( TEXT("SetNotificationHandle"), hr );
g_pEchoTool = new CEchoTool();
// Init the UI
HWND hToolCombo = GetDlgItem( hDlg, IDC_TOOL_COMBO );
lIndex = (LONG)SendMessage( hToolCombo, CB_ADDSTRING, 0, (LPARAM) TEXT("None") );
SendMessage( hToolCombo, CB_SETITEMDATA, lIndex, (LPARAM) NULL );
lIndex = (LONG)SendMessage( hToolCombo, CB_ADDSTRING, 0, (LPARAM) TEXT("Echo Tool") );
SendMessage( hToolCombo, CB_SETITEMDATA, lIndex, (LPARAM) (IDirectMusicTool*) g_pEchoTool );
SendMessage( hToolCombo, CB_SETCURSEL, 0, 0 );
// Load a default music segment
TCHAR strFileName[MAX_PATH];
strcpy( strFileName, DXUtil_GetDXSDKMediaPath() );
strcat( strFileName, "sample.sgt" );
if( S_FALSE == LoadSegmentFile( hDlg, strFileName ) )
{
// Set the UI controls
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("No file loaded.") );
}
return S_OK;
}
//-----------------------------------------------------------------------------
// 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("");
// Get the default media path (something like C:\MSSDK\SAMPLES\DMUSIC\MEDIA)
if( '\0' == strPath[0] )
{
const TCHAR* szDir = DXUtil_GetDXSDKMediaPath();
strcpy( strPath, szDir );
}
// Setup the OPENFILENAME structure
OPENFILENAME ofn = { sizeof(OPENFILENAME), hDlg, NULL,
TEXT("DirectMusic Content Files\0*.sgt;*.mid;*.rmi\0All Files\0*.*\0\0"), NULL,
0, 1, strFileName, MAX_PATH, NULL, 0, strPath,
TEXT("Open Content File"),
OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, 0, 0,
TEXT(".sgt"), 0, NULL, NULL };
if( g_pMusicSegment )
g_pMusicSegment->Stop( 0 );
// 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;
}
if( S_FALSE == LoadSegmentFile( hDlg, strFileName ) )
{
// Not a critical failure, so just update the status
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Could not create segment from file.") );
}
// Remember the path for next time
strcpy( strPath, strFileName );
char* strLastSlash = strrchr( strPath, '\\' );
strLastSlash[0] = '\0';
}
//-----------------------------------------------------------------------------
// Name: LoadSegmentFile()
// Desc:
//-----------------------------------------------------------------------------
HRESULT LoadSegmentFile( HWND hDlg, TCHAR* strFileName )
{
HRESULT hr;
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
// Free any previous segment, and make a new one
SAFE_DELETE( g_pMusicSegment );
// Have the loader collect any garbage now that the old
// script has been released
g_pMusicManager->CollectGarbage();
// Set the media path based on the file name (something like C:\MEDIA)
// to be used as the search directory for finding DirectMusic content
// related to this file.
TCHAR strMediaPath[MAX_PATH];
_tcscpy( strMediaPath, strFileName );
TCHAR* strLastSlash = _tcsrchr(strMediaPath, TEXT('\\'));
*strLastSlash = 0;
if( FAILED( hr = g_pMusicManager->SetSearchDirectory( strMediaPath ) ) )
return DXTRACE_ERR( TEXT("SetSearchDirectory"), hr );
// For DirectMusic must know if the file is a standard MIDI file or not
// in order to load the correct instruments.
BOOL bMidiFile = FALSE;
if( strstr( strFileName, ".mid" ) != NULL ||
strstr( strFileName, ".rmi" ) != NULL )
{
bMidiFile = TRUE;
}
// Load the file into a DirectMusic segment
if( FAILED( g_pMusicManager->CreateSegmentFromFile( &g_pMusicSegment, strFileName,
TRUE, bMidiFile ) ) )
{
// Not a critical failure, so just update the status
return S_FALSE;
}
// Update the UI controls to show the segment is loaded
SetDlgItemText( hDlg, IDC_FILENAME, strFileName );
EnablePlayUI( hDlg, TRUE );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: ProcessDirectMusicMessages()
// Desc: Handle DirectMusic notification messages
//-----------------------------------------------------------------------------
HRESULT ProcessDirectMusicMessages( HWND hDlg )
{
HRESULT hr;
IDirectMusicPerformance8* pPerf = NULL;
DMUS_NOTIFICATION_PMSG* pPMsg;
if( NULL == g_pMusicManager )
return S_OK;
pPerf = g_pMusicManager->GetPerformance();
// Get waiting notification message from the performance
while( S_OK == pPerf->GetNotificationPMsg( &pPMsg ) )
{
switch( pPMsg->dwNotificationOption )
{
case DMUS_NOTIFICATION_SEGEND:
if( pPMsg->punkUser )
{
IDirectMusicSegmentState8* pSegmentState = NULL;
IDirectMusicSegment* pNotifySegment = NULL;
IDirectMusicSegment8* pNotifySegment8 = NULL;
IDirectMusicSegment8* pPrimarySegment8 = NULL;
// The pPMsg->punkUser contains a IDirectMusicSegmentState8,
// which we can query for the segment that the SegmentState refers to.
if( FAILED( hr = pPMsg->punkUser->QueryInterface( IID_IDirectMusicSegmentState8,
(VOID**) &pSegmentState ) ) )
return DXTRACE_ERR( TEXT("QueryInterface"), hr );
if( SUCCEEDED( hr = pSegmentState->GetSegment( &pNotifySegment ) ) )
{
if( FAILED( hr = pNotifySegment->QueryInterface( IID_IDirectMusicSegment8,
(VOID**) &pNotifySegment8 ) ) )
return DXTRACE_ERR( TEXT("QueryInterface"), hr );
// Get the IDirectMusicSegment for the primary segment
pPrimarySegment8 = g_pMusicSegment->GetSegment();
// Figure out which segment this is
if( pNotifySegment8 == pPrimarySegment8 )
{
// Update the UI controls to show the sound as stopped
EnablePlayUI( hDlg, TRUE );
}
}
// Cleanup
SAFE_RELEASE( pSegmentState );
SAFE_RELEASE( pNotifySegment );
SAFE_RELEASE( pNotifySegment8 );
}
break;
}
pPerf->FreePMsg( (DMUS_PMSG*)pPMsg );
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnPlaySegment()
// Desc:
//-----------------------------------------------------------------------------
HRESULT OnPlaySegment( HWND hDlg )
{
HRESULT hr;
HWND hLoopButton = GetDlgItem( hDlg, IDC_LOOP_CHECK );
BOOL bLooped = ( SendMessage( hLoopButton, BM_GETSTATE, 0, 0 ) == BST_CHECKED );
if( bLooped )
{
// Set the segment to repeat many times
if( FAILED( hr = g_pMusicSegment->SetRepeats( DMUS_SEG_REPEAT_INFINITE ) ) )
return DXTRACE_ERR( TEXT("SetRepeats"), hr );
}
else
{
// Set the segment to not repeat
if( FAILED( hr = g_pMusicSegment->SetRepeats( 0 ) ) )
return DXTRACE_ERR( TEXT("SetRepeats"), hr );
}
// Play the segment and wait. The DMUS_SEGF_BEAT indicates to play on the
// next beat if there is a segment currently playing.
if( FAILED( hr = g_pMusicSegment->Play( DMUS_SEGF_BEAT ) ) )
return DXTRACE_ERR( TEXT("Play"), hr );
EnablePlayUI( hDlg, FALSE );
return S_OK;
}
//-----------------------------------------------------------------------------
// 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 ) );
}
else
{
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), TRUE );
SetFocus( GetDlgItem( hDlg, IDC_STOP ) );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), FALSE );
}
}
//-----------------------------------------------------------------------------
// Name: OnChangeTool()
// Desc:
//-----------------------------------------------------------------------------
HRESULT OnChangeTool( HWND hDlg )
{
HRESULT hr;
IDirectMusicTool* pSelectedTool;
LONG lCurSelection;
lCurSelection = (LONG)SendDlgItemMessage( hDlg, IDC_TOOL_COMBO, CB_GETCURSEL, 0, 0 );
pSelectedTool = (IDirectMusicTool*) SendDlgItemMessage( hDlg, IDC_TOOL_COMBO,
CB_GETITEMDATA, lCurSelection, 0 );
if( pSelectedTool != g_pCurrentTool )
{
// Remove the current tool from the graph
if( g_pCurrentTool != NULL )
{
if( FAILED( hr = g_pGraph->RemoveTool( g_pCurrentTool ) ) )
return DXTRACE_ERR( TEXT("RemoveTool"), hr );
}
// Add the tool to the graph on all PChannels
// and at the beginning of the graph.
if( pSelectedTool != NULL )
{
if( FAILED( hr = g_pGraph->InsertTool( pSelectedTool, NULL, 0, 0 ) ) )
return DXTRACE_ERR( TEXT("InsertTool"), hr );
}
g_pCurrentTool = pSelectedTool;
}
return S_OK;
}

View File

@@ -0,0 +1,147 @@
# Microsoft Developer Studio Project File - Name="MusicTool" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=MusicTool - 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 "MusicTool.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 "MusicTool.mak" CFG="MusicTool - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "MusicTool - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "MusicTool - 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)" == "MusicTool - 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" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /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 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)" == "MusicTool - 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" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /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 dxerr8.lib winmm.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 "MusicTool - Win32 Release"
# Name "MusicTool - Win32 Debug"
# Begin Group "Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\echotool.cpp
# End Source File
# Begin Source File
SOURCE=.\echotool.h
# End Source File
# Begin Source File
SOURCE=.\MusicTool.cpp
# End Source File
# End Group
# Begin Group "Resource"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\directx.ico
# End Source File
# Begin Source File
SOURCE=.\MusicTool.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\dmutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\dmutil.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,115 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define IDC_STATIC -1
/////////////////////////////////////////////////////////////////////////////
#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
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAIN DIALOG DISCARDABLE 0, 0, 262, 66
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "DirectMusic MusicTool Sample"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "Open &file...",IDC_SOUNDFILE,7,7,54,13
CONTROL "&Loop file",IDC_LOOP_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,45,61,10
PUSHBUTTON "&Play",IDC_PLAY,69,43,50,14,WS_DISABLED
PUSHBUTTON "&Stop",IDC_STOP,119,43,50,14,WS_DISABLED
PUSHBUTTON "E&xit",IDCANCEL,205,43,50,14
EDITTEXT IDC_FILENAME,69,7,186,14,ES_AUTOHSCROLL | ES_READONLY
LTEXT "DirectMusic Tool:",IDC_STATIC,7,27,56,8
COMBOBOX IDC_TOOL_COMBO,69,25,98,78,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 255
TOPMARGIN, 7
BOTTOMMARGIN, 57
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include <windows.h>\r\n"
"#define IDC_STATIC -1\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\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"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,29 @@
//-----------------------------------------------------------------------------
//
// Sample Name: MusicTool Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
// GM/GS<47> Sound Set Copyright <20>1996, Roland Corporation U.S.
//
//-----------------------------------------------------------------------------
Description
===========
The MusicTool sample demonstrates how to implement a DirectMusic tool
that intercepts messages.
Path
====
Source: DXSDK\Samples\Multimedia\DirectMusic\MusicTool
Executable: DXSDK\Samples\Multimedia\DirectMusic\Bin
User's Guide
============
Play the default segment, or choose another wave, MIDI, or
DirectMusicProducer segment file by clicking Segment File. Apply the
echo effect by selecting Echo Tool from the drop-down list.

View File

@@ -0,0 +1,23 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by MusicTool.rc
//
#define IDD_MAIN 101
#define IDR_MAINFRAME 102
#define IDC_PLAY 1002
#define IDC_STOP 1003
#define IDC_FILENAME 1004
#define IDC_TOOL_COMBO 1007
#define IDC_LOOP_CHECK 1009
#define IDC_SOUNDFILE 1011
// 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 1008
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,549 @@
//-----------------------------------------------------------------------------
// File: PlayAudio.cpp
//
// Desc: Plays a primary segment using DirectMusic
//
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <commdlg.h>
#include <commctrl.h>
#include <dmusicc.h>
#include <dmusici.h>
#include <dxerr8.h>
#include <tchar.h>
#include "resource.h"
#include "DMUtil.h"
#include "DXUtil.h"
//-----------------------------------------------------------------------------
// Function-prototypes
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
HRESULT OnInitDialog( HWND hDlg );
HRESULT ProcessDirectMusicMessages( HWND hDlg );
VOID OnOpenSoundFile( HWND hDlg );
HRESULT LoadSegmentFile( HWND hDlg, TCHAR* strFileName );
HRESULT OnPlayAudio( HWND hDlg );
VOID EnablePlayUI( HWND hDlg, BOOL bEnable );
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
#define MUSIC_VOLUME_RANGE ( 0-(DMUS_VOLUME_MIN/4) )
CMusicManager* g_pMusicManager = NULL;
CMusicSegment* g_pMusicSegment = NULL;
HINSTANCE g_hInst = NULL;
HANDLE g_hDMusicMessageEvent = 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 )
{
HWND hDlg = NULL;
BOOL bDone = FALSE;
int nExitCode;
HRESULT hr;
DWORD dwResult;
MSG msg;
g_hInst = hInst;
InitCommonControls();
// Display the main dialog box.
hDlg = CreateDialog( hInst, MAKEINTRESOURCE(IDD_MAIN),
NULL, MainDlgProc );
while( !bDone )
{
dwResult = MsgWaitForMultipleObjects( 1, &g_hDMusicMessageEvent,
FALSE, INFINITE, QS_ALLEVENTS );
switch( dwResult )
{
case WAIT_OBJECT_0 + 0:
// g_hDPMessageEvent is signaled, so there are
// DirectPlay messages available
if( FAILED( hr = ProcessDirectMusicMessages( hDlg ) ) )
{
DXTRACE_ERR( TEXT("ProcessDirectMusicMessages"), hr );
return FALSE;
}
break;
case WAIT_OBJECT_0 + 1:
// Windows messages are available
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if( !IsDialogMessage( hDlg, &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
if( msg.message == WM_QUIT )
{
nExitCode = (int)msg.wParam;
bDone = TRUE;
DestroyWindow( hDlg );
}
}
break;
}
}
return nExitCode;
}
//-----------------------------------------------------------------------------
// 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:
if( FAILED( hr = OnInitDialog( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnInitDialog"), hr );
MessageBox( hDlg, "Error initializing DirectMusic. Sample will now exit.",
"DirectMusic Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, 0 );
return TRUE;
}
break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDC_SOUNDFILE:
OnOpenSoundFile( hDlg );
break;
case IDCANCEL:
PostQuitMessage( IDCANCEL );
break;
case IDC_PLAY:
if( FAILED( hr = OnPlayAudio( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnPlayAudio"), hr );
MessageBox( hDlg, "Error playing DirectMusic segment. "
"Sample will now exit.", "DirectMusic Sample",
MB_OK | MB_ICONERROR );
PostQuitMessage( IDABORT );
}
break;
case IDC_STOP:
g_pMusicSegment->Stop( DMUS_SEGF_BEAT );
EnablePlayUI( hDlg, TRUE );
break;
default:
return FALSE; // Didn't handle message
}
break;
case WM_NOTIFY:
if( wParam == IDC_TEMPO_SLIDER )
{
static int s_nLastTempo = -1;
int nTempo = (int)SendDlgItemMessage( hDlg, IDC_TEMPO_SLIDER, TBM_GETPOS, 0, 0 );
if( nTempo != s_nLastTempo )
{
IDirectMusicPerformance* pPerf = NULL;
if( g_pMusicManager )
pPerf = g_pMusicManager->GetPerformance();
if( NULL == pPerf )
break;
s_nLastTempo = nTempo;
// Adjust the slider position to go between 1/4th and 4x tempo
FLOAT fTempo;
if( nTempo > 4 )
fTempo = (float)(nTempo-3);
else
fTempo = nTempo/4.0f;
pPerf->SetGlobalParam( GUID_PerfMasterTempo,
(void*)&fTempo, sizeof(float) );
}
}
else if( wParam == IDC_VOLUME_SLIDER )
{
static long s_nLastVolume = -1;
long nSlider = (long)SendDlgItemMessage( hDlg, IDC_VOLUME_SLIDER, TBM_GETPOS, 0, 0 );
long nVolume = nSlider - MUSIC_VOLUME_RANGE;
if( nVolume != s_nLastVolume )
{
IDirectMusicPerformance* pPerf = NULL;
if( g_pMusicManager )
pPerf = g_pMusicManager->GetPerformance();
if( NULL == pPerf )
break;
s_nLastVolume = nVolume;
// Adjust the slider position to match GUID_PerfMasterTempo range
pPerf->SetGlobalParam( GUID_PerfMasterVolume,
(void*)&nVolume, sizeof(long) );
}
}
break;
case WM_DESTROY:
// Cleanup everything
SAFE_DELETE( g_pMusicSegment );
SAFE_DELETE( g_pMusicManager );
CloseHandle( g_hDMusicMessageEvent );
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
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
g_hDMusicMessageEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
g_pMusicManager = new CMusicManager();
if( FAILED( hr = g_pMusicManager->Initialize( hDlg ) ) )
return DXTRACE_ERR( TEXT("Initialize"), hr );
// Register segment notification
IDirectMusicPerformance* pPerf = g_pMusicManager->GetPerformance();
GUID guid = GUID_NOTIFICATION_SEGMENT;
pPerf->AddNotificationType( guid );
pPerf->SetNotificationHandle( g_hDMusicMessageEvent, 0 );
SendDlgItemMessage( hDlg, IDC_TEMPO_SLIDER, TBM_SETRANGE, FALSE, MAKELONG( 1, 7 ) );
SendDlgItemMessage( hDlg, IDC_TEMPO_SLIDER, TBM_SETTIC, TRUE, 4 );
SendDlgItemMessage( hDlg, IDC_TEMPO_SLIDER, TBM_SETPOS, TRUE, 4 );
SendDlgItemMessage( hDlg, IDC_VOLUME_SLIDER, TBM_SETRANGE, FALSE, MAKELONG( 0, MUSIC_VOLUME_RANGE ) );
SendDlgItemMessage( hDlg, IDC_VOLUME_SLIDER, TBM_SETPOS, TRUE, MUSIC_VOLUME_RANGE );
// Load a default music segment
TCHAR strFileName[MAX_PATH];
strcpy( strFileName, DXUtil_GetDXSDKMediaPath() );
strcat( strFileName, "sample.sgt" );
if( S_FALSE == LoadSegmentFile( hDlg, strFileName ) )
{
// Set the UI controls
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("No file loaded.") );
}
return S_OK;
}
//-----------------------------------------------------------------------------
// 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("");
// Get the default media path (something like C:\MSSDK\SAMPLES\DMUSIC\MEDIA)
if( '\0' == strPath[0] )
{
const TCHAR* szDir = DXUtil_GetDXSDKMediaPath();
strcpy( strPath, szDir );
}
// Setup the OPENFILENAME structure
OPENFILENAME ofn = { sizeof(OPENFILENAME), hDlg, NULL,
TEXT("DirectMusic Content Files\0*.sgt;*.mid;*.rmi\0Wave Files\0*.wav\0All Files\0*.*\0\0"), NULL,
0, 1, strFileName, MAX_PATH, NULL, 0, strPath,
TEXT("Open Content File"),
OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, 0, 0,
TEXT(".sgt"), 0, NULL, NULL };
if( g_pMusicSegment )
g_pMusicSegment->Stop( 0 );
// 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;
}
if( S_FALSE == LoadSegmentFile( hDlg, strFileName ) )
{
// Not a critical failure, so just update the status
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("Could not create segment from file.") );
}
// Remember the path for next time
strcpy( strPath, strFileName );
char* strLastSlash = strrchr( strPath, '\\' );
strLastSlash[0] = '\0';
}
//-----------------------------------------------------------------------------
// Name: LoadSegmentFile()
// Desc:
//-----------------------------------------------------------------------------
HRESULT LoadSegmentFile( HWND hDlg, TCHAR* strFileName )
{
HRESULT hr;
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
// Free any previous segment, and make a new one
SAFE_DELETE( g_pMusicSegment );
// Have the loader collect any garbage now that the old
// segment has been released
g_pMusicManager->CollectGarbage();
// Set the media path based on the file name (something like C:\MEDIA)
// to be used as the search directory for finding DirectMusic content
// related to this file.
TCHAR strMediaPath[MAX_PATH];
_tcscpy( strMediaPath, strFileName );
TCHAR* strLastSlash = _tcsrchr(strMediaPath, TEXT('\\'));
*strLastSlash = 0;
if( FAILED( hr = g_pMusicManager->SetSearchDirectory( strMediaPath ) ) )
return DXTRACE_ERR( TEXT("SetSearchDirectory"), hr );
// For DirectMusic must know if the file is a standard MIDI file or not
// in order to load the correct instruments.
BOOL bMidiFile = FALSE;
if( strstr( strFileName, ".mid" ) != NULL ||
strstr( strFileName, ".rmi" ) != NULL )
{
bMidiFile = TRUE;
}
BOOL bWavFile = FALSE;
if( strstr( strFileName, ".wav" ) != NULL )
{
bWavFile = TRUE;
}
// Load the file into a DirectMusic segment
if( FAILED( g_pMusicManager->CreateSegmentFromFile( &g_pMusicSegment, strFileName,
TRUE, bMidiFile ) ) )
{
// Not a critical failure, so just update the status
return S_FALSE;
}
// Update the UI controls to show the segment is loaded
SetDlgItemText( hDlg, IDC_FILENAME, strFileName );
EnablePlayUI( hDlg, TRUE );
// If we are loading a wav, then disable the tempo slider since
// tempo adjustments will not take effect when playing wav files.
EnableWindow( GetDlgItem( hDlg, IDC_TEMPO_SLIDER ), !bWavFile );
EnableWindow( GetDlgItem( hDlg, IDC_TEMPO_GROUPBOX ), !bWavFile );
EnableWindow( GetDlgItem( hDlg, IDC_TEMPO_SLOWTXT ), !bWavFile );
EnableWindow( GetDlgItem( hDlg, IDC_TEMPO_FASTTXT ), !bWavFile );
EnableWindow( GetDlgItem( hDlg, IDC_TEMPO_NORMALTXT ), !bWavFile );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: ProcessDirectMusicMessages()
// Desc: Handle DirectMusic notification messages
//-----------------------------------------------------------------------------
HRESULT ProcessDirectMusicMessages( HWND hDlg )
{
HRESULT hr;
IDirectMusicPerformance8* pPerf = NULL;
DMUS_NOTIFICATION_PMSG* pPMsg;
if( NULL == g_pMusicManager )
return S_OK;
pPerf = g_pMusicManager->GetPerformance();
// Get waiting notification message from the performance
while( S_OK == pPerf->GetNotificationPMsg( &pPMsg ) )
{
switch( pPMsg->dwNotificationOption )
{
case DMUS_NOTIFICATION_SEGEND:
if( pPMsg->punkUser )
{
IDirectMusicSegmentState8* pSegmentState = NULL;
IDirectMusicSegment* pNotifySegment = NULL;
IDirectMusicSegment8* pNotifySegment8 = NULL;
IDirectMusicSegment8* pPrimarySegment8 = NULL;
// The pPMsg->punkUser contains a IDirectMusicSegmentState8,
// which we can query for the segment that the SegmentState refers to.
if( FAILED( hr = pPMsg->punkUser->QueryInterface( IID_IDirectMusicSegmentState8,
(VOID**) &pSegmentState ) ) )
return DXTRACE_ERR( TEXT("QueryInterface"), hr );
if( FAILED( hr = pSegmentState->GetSegment( &pNotifySegment ) ) )
{
// Sometimes the segend arrives after the segment is gone
// This can happen when you load another segment as
// a motif or the segment is ending
if( hr == DMUS_E_NOT_FOUND )
{
SAFE_RELEASE( pSegmentState );
return S_OK;
}
return DXTRACE_ERR( TEXT("GetSegment"), hr );
}
if( FAILED( hr = pNotifySegment->QueryInterface( IID_IDirectMusicSegment8,
(VOID**) &pNotifySegment8 ) ) )
return DXTRACE_ERR( TEXT("QueryInterface"), hr );
// Get the IDirectMusicSegment for the primary segment
pPrimarySegment8 = g_pMusicSegment->GetSegment();
// Figure out which segment this is
if( pNotifySegment8 == pPrimarySegment8 )
{
// Update the UI controls to show the sound as stopped
EnablePlayUI( hDlg, TRUE );
}
// Cleanup
SAFE_RELEASE( pSegmentState );
SAFE_RELEASE( pNotifySegment );
SAFE_RELEASE( pNotifySegment8 );
}
break;
}
pPerf->FreePMsg( (DMUS_PMSG*)pPMsg );
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnPlayAudio()
// Desc:
//-----------------------------------------------------------------------------
HRESULT OnPlayAudio( HWND hDlg )
{
HRESULT hr;
HWND hLoopButton = GetDlgItem( hDlg, IDC_LOOP_CHECK );
BOOL bLooped = ( SendMessage( hLoopButton, BM_GETSTATE, 0, 0 ) == BST_CHECKED );
if( bLooped )
{
// Set the segment to repeat many times
if( FAILED( hr = g_pMusicSegment->SetRepeats( DMUS_SEG_REPEAT_INFINITE ) ) )
return DXTRACE_ERR( TEXT("SetRepeats"), hr );
}
else
{
// Set the segment to not repeat
if( FAILED( hr = g_pMusicSegment->SetRepeats( 0 ) ) )
return DXTRACE_ERR( TEXT("SetRepeats"), hr );
}
// Play the segment and wait. The DMUS_SEGF_BEAT indicates to play on the
// next beat if there is a segment currently playing.
if( FAILED( hr = g_pMusicSegment->Play( DMUS_SEGF_BEAT ) ) )
return DXTRACE_ERR( TEXT("Play"), hr );
EnablePlayUI( hDlg, FALSE );
return S_OK;
}
//-----------------------------------------------------------------------------
// 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 ) );
}
else
{
EnableWindow( GetDlgItem( hDlg, IDC_LOOP_CHECK ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), TRUE );
SetFocus( GetDlgItem( hDlg, IDC_STOP ) );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), FALSE );
}
}

View File

@@ -0,0 +1,139 @@
# Microsoft Developer Studio Project File - Name="PlayAudio" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=PlayAudio - 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 "PlayAudio.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 "PlayAudio.mak" CFG="PlayAudio - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "PlayAudio - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "PlayAudio - 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)" == "PlayAudio - 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" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /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 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)" == "PlayAudio - 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" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /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 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 "PlayAudio - Win32 Release"
# Name "PlayAudio - Win32 Debug"
# Begin Group "Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\PlayAudio.cpp
# End Source File
# End Group
# Begin Group "Resource"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\directx.ico
# End Source File
# Begin Source File
SOURCE=.\PlayAudio.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\dmutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\dmutil.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: "PlayAudio"=.\PlayAudio.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 PlayAudio.dsp
!IF "$(CFG)" == ""
CFG=PlayAudio - Win32 Debug
!MESSAGE No configuration specified. Defaulting to PlayAudio - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "PlayAudio - Win32 Release" && "$(CFG)" != "PlayAudio - 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 "PlayAudio.mak" CFG="PlayAudio - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "PlayAudio - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "PlayAudio - 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)" == "PlayAudio - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\PlayAudio.exe"
CLEAN :
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\PlayAudio.obj"
-@erase "$(INTDIR)\PlayAudio.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\PlayAudio.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" /Fp"$(INTDIR)\PlayAudio.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\PlayAudio.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\PlayAudio.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=comctl32.lib dxerr8.lib winmm.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)\PlayAudio.pdb" /machine:I386 /out:"$(OUTDIR)\PlayAudio.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\PlayAudio.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\PlayAudio.res"
"$(OUTDIR)\PlayAudio.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "PlayAudio - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\PlayAudio.exe"
CLEAN :
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\PlayAudio.obj"
-@erase "$(INTDIR)\PlayAudio.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\PlayAudio.exe"
-@erase "$(OUTDIR)\PlayAudio.ilk"
-@erase "$(OUTDIR)\PlayAudio.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" /Fp"$(INTDIR)\PlayAudio.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\PlayAudio.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\PlayAudio.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=comctl32.lib dxerr8.lib winmm.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)\PlayAudio.pdb" /debug /machine:I386 /out:"$(OUTDIR)\PlayAudio.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\PlayAudio.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\PlayAudio.res"
"$(OUTDIR)\PlayAudio.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("PlayAudio.dep")
!INCLUDE "PlayAudio.dep"
!ELSE
!MESSAGE Warning: cannot find "PlayAudio.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "PlayAudio - Win32 Release" || "$(CFG)" == "PlayAudio - Win32 Debug"
SOURCE=.\PlayAudio.cpp
"$(INTDIR)\PlayAudio.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\PlayAudio.rc
"$(INTDIR)\PlayAudio.res" : $(SOURCE) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
SOURCE=..\..\common\src\dmutil.cpp
"$(INTDIR)\dmutil.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,123 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define IDC_STATIC -1
/////////////////////////////////////////////////////////////////////////////
#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
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAIN DIALOG DISCARDABLE 0, 0, 262, 84
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "DirectX Sample Audio Player"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "Open &file...",IDC_SOUNDFILE,7,7,54,13
CONTROL "&Loop file",IDC_LOOP_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,28,61,10
PUSHBUTTON "&Play",IDC_PLAY,69,26,50,14,WS_DISABLED
PUSHBUTTON "&Stop",IDC_STOP,119,26,50,14,WS_DISABLED
PUSHBUTTON "E&xit",IDCANCEL,205,26,50,14
EDITTEXT IDC_FILENAME,69,7,186,14,ES_AUTOHSCROLL | ES_READONLY
CONTROL "Slider1",IDC_TEMPO_SLIDER,"msctls_trackbar32",
WS_TABSTOP,15,60,103,12
CONTROL "Slider2",IDC_VOLUME_SLIDER,"msctls_trackbar32",
WS_TABSTOP,144,60,109,12
LTEXT "Slow",IDC_TEMPO_SLOWTXT,18,52,16,8
LTEXT "Fast",IDC_TEMPO_FASTTXT,101,52,14,8
LTEXT "Min",IDC_STATIC,148,52,12,8
LTEXT "Max",IDC_STATIC,236,52,14,8
GROUPBOX "Tempo",IDC_TEMPO_GROUPBOX,7,43,115,32
GROUPBOX "Master Volume",IDC_STATIC,139,43,116,32
LTEXT "Normal",IDC_TEMPO_NORMALTXT,56,52,23,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 255
TOPMARGIN, 7
BOTTOMMARGIN, 75
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include <windows.h>\r\n"
"#define IDC_STATIC -1\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\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"
#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,135 @@
//-----------------------------------------------------------------------------
//
// Sample Name: PlayAudio Sample
//
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//
// GM/GS<47> Sound Set Copyright <20>1996, Roland Corporation U.S.
//
//-----------------------------------------------------------------------------
Description
===========
The PlayAudio sample shows how to load a segment and play it on an
audiopath, how to use DirectMusic notifications, and how to change
global performance parameters.
Path
====
Source: DXSDK\Samples\Multimedia\DirectMusic\PlayAudio
Executable: DXSDK\Samples\Multimedia\DirectMusic\Bin
User's Guide
============
Play the default segment, or load another wave, MIDI, or DirectMusic
Producer segment file by clicking Segment File. Adjust the tempo and
volume by using the sliders
Programming Notes
=================
This and other DirectMusic samples uses the DirectMusic sample
framework, CMusicManager and CMusicSegment to help encapsulate some of
the common functionality of DirectMusic. The framework is contained
in dmutil.cpp.
This is how the sample works:
* Upon WM_INITDIALOG. See OnInitDialog()
1. Create a Win32 event, g_hDMusicMessageEvent. This will be
used by DirectMusic to signal the app whenever a DirectMusic
notification comes in.
2. Create a help class CMusicManager called g_pMusicManager.
3. Initialize the CMusicManager class. This does the following.
See CMusicManager::Initialize() in dmutil.cpp
- Creates a IDirectMusicLoader8 using CoCreateInstance
- Creates a IDirectMusicPerformance8 using CoCreateInstance
- Calls IDirectMusicPerformance8::InitAudio to init DirectMusic
using a standard audio path.
4. Call IDirectMusicPerformance8::AddNotificationType() passing in
GUID_NOTIFICATION_SEGMENT. This will make DirectMusic tell us about any
segment notifications that come in. This is needed to by this
sample to know when the segment has ended. However DirectMusic
games may not care when the segment has ended.
5. Call IDirectMusicPerformance8::SetNotificationHandle() passing
in the Win32 event, g_hDMusicMessageEvent. This tells DirectMusic
to signal this event when a notification is available.
* Setting up the app message loop. See WinMain()
1. Create the dialog using CreateDialog().
2. In a loop call MsgWaitForMultipleObjects() passing in
g_hDMusicMessageEvent. This will tell us when g_hDMusicMessageEvent
is signaled. Above we have told DirectMusic to signal this event
whenever a DirectMusic notification has come in.
3. If WAIT_OBJECT_0 is returned, then call ProcessDirectMusicMessages(),
See below for details.
4. If WAIT_OBJECT_0 + 1 is returned, then Windows msgs are available, so
do standard msg processing using PeekMessage().
* When "Open File" is clicked. See OnOpenSoundFile()
1. Get the file name from using GetOpenFileName().
2. Release the any old g_pMusicSegment.
3. Call CMusicManager::CollectGarbage(). See dmutil.cpp.
This calls IDirectMusicLoader8::CollectGarbage which
collects any garbage from any old segment that was present.
This is done because some sophisticated segments, in particular
ones that include segment trigger tracks or script tracks, may
have a cyclic reference. For example, a segment trigger that
references another segment that references the first segment, also
via a segment trigger track.
4. Call CMusicManager::SetSearchDirectory(). See dmutil.cpp
This calls IDirectMusicLoader8::SetSearchDirectory()
passing in the GUID_DirectMusicAllTypes and a directory.
This will tell DirectMusic where to look for files that
are referenced inside of segments.
5. Call CMusicManager::CreateSegmentFromFile() to create a
CMusicSegment called g_pMusicSegment from the file.
See dmutil.cpp. This does the following:
- Calls IDirectMusicLoader8::LoadObjectFromFile() to
load the IDirectMusicSegment8 into pSegment.
- Creates CMusicSegment passing in pSegment.
- If the file is a pure MIDI file then it calls
IDirectMusicSegment8::SetParam passing in
GUID_StandardMIDIFile to DirectMusic this. This makes
sure that patch changes are handled correctly.
- If requested, it calls IDirectMusicSegment8::Download()
this will download the segment's bands to the synthesizer.
Some apps may want to wait before calling this to because
the download allocates memory for the instruments. The
more instruments currently downloaded, the more memory
is in use by the synthesizer.
* When "Play" is clicked. See OnPlayAudio()
1. If the UI says the sound should be looped, then call
CMusicSegment::SetRepeats passing in DMUS_SEG_REPEAT_INFINITE,
otherwise call CMusicSegment::SetRepeats passing in 0.
2. Call CMusicSegment::Play() which calls
IDirectMusicPerformance8::PlaySegmentEx(). See dmutil.cpp.
* Upon a DirectMusic notification. See ProcessDirectMusicMessages().
This sample wants to know if the primary segment has stopped playing
so it can updated the UI so tell the user that they can play
the sound again. This is rather complex, but typically apps
will not need this functionality. Here is what has to be done:
1. Call IDirectMusicPerformance8::GetNotificationPMsg() in a loop
to process each PMsg that has occurred.
2. Switch off the pPMsg->dwNotificationOption. This sample
only handles it if its a DMUS_NOTIFICATION_SEGEND. This tells
us that segment has ended.
3. Call QueryInterface on the pPMsg->punkUser, quering for a
IDirectMusicSegmentState8.
4. Using the IDirectMusicSegmentState8, call GetSegment to
get a IDirectMusicSegment* of the segment it refers to.
This call may fail is the segment may have gone away before this
notification was handled.
5. Call QueryInterface IDirectMusicSegment to get a IDirectMusicSegment8
6. Compare this pointer to the IDirectMusicSegment8 pointer
in g_pMusicSegment, to see if this was the primary segment.
This may not always be the case since segments can have segments enbedded
inside of them, we only want handle when the primary segment has
stopped playing. If it has, then update the UI
7. Cleanup all the interfaces.

View File

@@ -0,0 +1,30 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by PlayAudio.rc
//
#define IDD_MAIN 101
#define IDR_MAINFRAME 102
#define IDR_ACCELERATOR1 131
#define IDC_TEMPO_GROUPBOX 1001
#define IDC_PLAY 1002
#define IDC_STOP 1003
#define IDC_FILENAME 1004
#define IDC_TEMPO_SLIDER 1005
#define IDC_VOLUME_SLIDER 1006
#define IDC_LOOP_CHECK 1009
#define IDC_SOUNDFILE 1011
#define IDC_TEMPO_SLOWTXT 1012
#define IDC_TEMPO_FASTTXT 1013
#define IDC_TEMPO_NORMALTXT 1014
// 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 1015
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,758 @@
//-----------------------------------------------------------------------------
// File: PlayMotif.cpp
//
// Desc: Lets the user play a primary segment using DirectMusic as well as
// any of motifs contained inside the segment.
//
// Copyright (c) 2000-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#define STRICT
#include <windows.h>
#include <basetsd.h>
#include <commdlg.h>
#include <commctrl.h>
#include <objbase.h>
#include <conio.h>
#include <direct.h>
#include <dmusicc.h>
#include <dmusici.h>
#include <dxerr8.h>
#include <tchar.h>
#include <commctrl.h>
#include "resource.h"
#include "DMUtil.h"
#include "DXUtil.h"
//-----------------------------------------------------------------------------
// Function-prototypes
//-----------------------------------------------------------------------------
INT_PTR CALLBACK MainDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
HRESULT OnInitDialog( HWND hDlg );
HRESULT ProcessDirectMusicMessages( HWND hDlg );
VOID OnOpenSegmentFile( HWND hDlg );
HRESULT LoadSegmentFile( HWND hDlg, TCHAR* strFileName );
HRESULT OnPlaySegment( HWND hDlg );
HRESULT OnPlayMotif( HWND hDlg );
VOID EnablePlayUI( HWND hDlg, BOOL bEnable );
struct MOTIF_NODE
{
IDirectMusicSegment* pMotif;
DWORD dwPlayCount;
};
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
CMusicManager* g_pMusicManager = NULL;
CMusicSegment* g_pMusicSegment = NULL;
HINSTANCE g_hInst = NULL;
HANDLE g_hDMusicMessageEvent = 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 )
{
HWND hDlg = NULL;
BOOL bDone = FALSE;
int nExitCode;
HRESULT hr;
DWORD dwResult;
MSG msg;
g_hInst = hInst;
// Display the main dialog box.
hDlg = CreateDialog( hInst, MAKEINTRESOURCE(IDD_MAIN),
NULL, MainDlgProc );
while( !bDone )
{
dwResult = MsgWaitForMultipleObjects( 1, &g_hDMusicMessageEvent,
FALSE, INFINITE, QS_ALLEVENTS );
switch( dwResult )
{
case WAIT_OBJECT_0 + 0:
// g_hDPMessageEvent is signaled, so there are
// DirectPlay messages available
if( FAILED( hr = ProcessDirectMusicMessages( hDlg ) ) )
{
DXTRACE_ERR( TEXT("ProcessDirectMusicMessages"), hr );
return FALSE;
}
break;
case WAIT_OBJECT_0 + 1:
// Windows messages are available
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
if( !IsDialogMessage( hDlg, &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
if( msg.message == WM_QUIT )
{
nExitCode = (int)msg.wParam;
bDone = TRUE;
DestroyWindow( hDlg );
}
}
break;
}
}
return nExitCode;
}
//-----------------------------------------------------------------------------
// 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:
if( FAILED( hr = OnInitDialog( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnInitDialog"), hr );
MessageBox( hDlg, "Error initializing DirectMusic. Sample will now exit.",
"DirectMusic Sample", MB_OK | MB_ICONERROR );
EndDialog( hDlg, 0 );
return TRUE;
}
break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDC_SOUNDFILE:
OnOpenSegmentFile( hDlg );
break;
case IDCANCEL:
PostQuitMessage( IDCANCEL );
break;
case IDC_MOTIF_LIST:
if (HIWORD(wParam) == LBN_DBLCLK )
{
if( FAILED( hr = OnPlayMotif( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnPlayMotif"), hr );
MessageBox( hDlg, "Error playing DirectMusic motif. "
"Sample will now exit.", "DirectMusic Sample",
MB_OK | MB_ICONERROR );
PostQuitMessage( IDABORT );
}
break;
}
if( g_pMusicSegment )
{
if( g_pMusicSegment->IsPlaying() )
{
HWND hListBox = GetDlgItem( hDlg, IDC_MOTIF_LIST );
int nIndex = (int)SendMessage( hListBox, LB_GETCURSEL, 0, 0 );
if( nIndex == LB_ERR )
EnableWindow( GetDlgItem( hDlg, IDC_PLAY_MOTIF ), FALSE );
else
EnableWindow( GetDlgItem( hDlg, IDC_PLAY_MOTIF ), TRUE );
}
}
break;
case IDC_PLAY:
if( FAILED( hr = OnPlaySegment( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnPlaySegment"), hr );
MessageBox( hDlg, "Error playing DirectMusic segment. "
"Sample will now exit.", "DirectMusic Sample",
MB_OK | MB_ICONERROR );
PostQuitMessage( IDABORT );
}
break;
case IDC_STOP:
g_pMusicSegment->Stop( DMUS_SEGF_BEAT );
SetDlgItemText( hDlg, IDC_STATUS, "Primary segment stopped." );
EnablePlayUI( hDlg, TRUE );
break;
case IDC_PLAY_MOTIF:
if( FAILED( hr = OnPlayMotif( hDlg ) ) )
{
DXTRACE_ERR( TEXT("OnPlayMotif"), hr );
MessageBox( hDlg, "Error playing DirectMusic motif. "
"Sample will now exit.", "DirectMusic Sample",
MB_OK | MB_ICONERROR );
PostQuitMessage( IDABORT );
}
break;
default:
return FALSE; // Didn't handle message
}
break;
case WM_DESTROY:
{
// Cleanup everything
HWND hListBox = GetDlgItem( hDlg, IDC_MOTIF_LIST );
DWORD dwCount = (DWORD)SendMessage( hListBox, LB_GETCOUNT, 0, 0 );
for( DWORD i=0; i<dwCount; i++ )
{
MOTIF_NODE* pMotifNode = (MOTIF_NODE*) SendMessage( hListBox, LB_GETITEMDATA, i, 0 );
if( pMotifNode )
{
SAFE_RELEASE( pMotifNode->pMotif );
SAFE_DELETE( pMotifNode );
}
}
CloseHandle( g_hDMusicMessageEvent );
SAFE_DELETE( g_pMusicSegment );
SAFE_DELETE( g_pMusicManager );
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
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
g_hDMusicMessageEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
g_pMusicManager = new CMusicManager();
if( FAILED( hr = g_pMusicManager->Initialize( hDlg ) ) )
return DXTRACE_ERR( TEXT("Initialize"), hr );
// Register segment notification
IDirectMusicPerformance* pPerf = g_pMusicManager->GetPerformance();
GUID guid = GUID_NOTIFICATION_SEGMENT;
if( FAILED( hr = pPerf->AddNotificationType( guid ) ) )
return DXTRACE_ERR( TEXT("AddNotificationType"), hr );
if( FAILED( hr = pPerf->SetNotificationHandle( g_hDMusicMessageEvent, 0 ) ) )
return DXTRACE_ERR( TEXT("SetNotificationHandle"), hr );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY_MOTIF ), FALSE );
CheckRadioButton( hDlg, IDC_RADIO_DEFAULT, IDC_RADIO_MEASURE, IDC_RADIO_MEASURE );
// Load a default music segment
TCHAR strFileName[MAX_PATH];
strcpy( strFileName, DXUtil_GetDXSDKMediaPath() );
strcat( strFileName, "sample.sgt" );
if( S_FALSE == LoadSegmentFile( hDlg, strFileName ) )
{
// Set the UI controls
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("No file loaded.") );
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnOpenSegmentFile()
// Desc: Called when the user requests to open a sound file
//-----------------------------------------------------------------------------
VOID OnOpenSegmentFile( HWND hDlg )
{
static TCHAR strFileName[MAX_PATH] = TEXT("");
static TCHAR strPath[MAX_PATH] = TEXT("");
HWND hListBox = GetDlgItem( hDlg, IDC_MOTIF_LIST );
// Get the default media path (something like C:\MSSDK\SAMPLES\MULTIMEDIA\MEDIA)
if( '\0' == strPath[0] )
{
const TCHAR* szDir = DXUtil_GetDXSDKMediaPath();
strcpy( strPath, szDir );
}
// Setup the OPENFILENAME structure
OPENFILENAME ofn = { sizeof(OPENFILENAME), hDlg, NULL,
TEXT("DirectMusic Content Files\0*.sgt;*.mid;*.rmi\0All Files\0*.*\0\0"), NULL,
0, 1, strFileName, MAX_PATH, NULL, 0, strPath,
TEXT("Open Segment File"),
OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, 0, 0,
TEXT(".sgt"), 0, NULL, NULL };
if( g_pMusicSegment )
g_pMusicSegment->Stop( 0 );
// Update the UI controls to show the sound as loading a file
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), FALSE);
EnableWindow( GetDlgItem( hDlg, IDC_STOP ), FALSE);
EnableWindow( GetDlgItem( hDlg, IDC_PLAY_MOTIF ), FALSE );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Loading file...") );
// Cleanup motif listbox
DWORD dwCount = (DWORD)SendMessage( hListBox, LB_GETCOUNT, 0, 0 );
for( DWORD i=0; i<dwCount; i++ )
{
MOTIF_NODE* pMotifNode = (MOTIF_NODE*) SendMessage( hListBox, LB_GETITEMDATA, i, 0 );
if( pMotifNode )
{
SAFE_RELEASE( pMotifNode->pMotif );
SAFE_DELETE( pMotifNode );
}
}
SendMessage( hListBox, LB_RESETCONTENT, 0, 0 );
// Display the OpenFileName dialog. Then, try to load the specified file
if( TRUE != GetOpenFileName( &ofn ) )
{
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Load aborted.") );
return;
}
if( S_FALSE == LoadSegmentFile( hDlg, strFileName ) )
{
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("Could not create segment from file.") );
}
// Remember the path for next time
strcpy( strPath, strFileName );
char* strLastSlash = strrchr( strPath, '\\' );
strLastSlash[0] = '\0';
}
//-----------------------------------------------------------------------------
// Name: LoadSegmentFile()
// Desc:
//-----------------------------------------------------------------------------
HRESULT LoadSegmentFile( HWND hDlg, TCHAR* strFileName )
{
HRESULT hr;
HWND hListBox = GetDlgItem( hDlg, IDC_MOTIF_LIST );
SetDlgItemText( hDlg, IDC_FILENAME, TEXT("") );
SAFE_DELETE( g_pMusicSegment );
// Have the loader collect any garbage now that the old
// script has been released
g_pMusicManager->CollectGarbage();
// Set the media path based on the file name (something like C:\MEDIA)
// to be used as the search directory for finding DirectMusic content
// related to this file.
TCHAR strMediaPath[MAX_PATH];
_tcscpy( strMediaPath, strFileName );
TCHAR* strLastSlash = _tcsrchr(strMediaPath, TEXT('\\'));
*strLastSlash = 0;
if( FAILED( hr = g_pMusicManager->SetSearchDirectory( strMediaPath ) ) )
return DXTRACE_ERR( TEXT("SetSearchDirectory"), hr );
// For DirectMusic must know if the file is a standard MIDI file or not
// in order to load the correct instruments.
BOOL bMidiFile = FALSE;
if( strstr( strFileName, ".mid" ) != NULL ||
strstr( strFileName, ".rmi" ) != NULL )
{
bMidiFile = TRUE;
}
// Load the file into a DirectMusic segment
if( FAILED( g_pMusicManager->CreateSegmentFromFile( &g_pMusicSegment, strFileName,
TRUE, bMidiFile ) ) )
{
// Not a critical failure, so just update the status
return S_FALSE;
}
IDirectMusicStyle8* pStyle = NULL;
DWORD dwStyleIndex = 0;
while( TRUE )
{
// Get the style from the segment
// Segments may have any number of styles.
hr = g_pMusicSegment->GetStyle( &pStyle, dwStyleIndex );
if( FAILED(hr) )
break;
// Get the names of the motifs from the style.
// Styles may have any number of motifs.
DWORD dwIndex = 0;
while( TRUE )
{
WCHAR wstrMotifName[MAX_PATH];
CHAR strMotifName[MAX_PATH];
if( S_FALSE == pStyle->EnumMotif( dwIndex, wstrMotifName ) )
break;
wcstombs( strMotifName, wstrMotifName, wcslen( wstrMotifName ) + 1 );
int nIndex = (int)SendMessage( hListBox, LB_ADDSTRING, 0, (LPARAM) strMotifName );
MOTIF_NODE* pMotifNode = new MOTIF_NODE;
if( FAILED( hr = pStyle->GetMotif( wstrMotifName, &pMotifNode->pMotif ) ) )
return DXTRACE_ERR( TEXT("GetMotif"), hr );
pMotifNode->dwPlayCount = 0;
SendMessage( hListBox, LB_SETITEMDATA, nIndex, (LPARAM) pMotifNode );
dwIndex++;
}
SAFE_RELEASE( pStyle );
dwStyleIndex++;
}
SendMessage( hListBox, LB_SETCURSEL, 0, 0 );
// Update the UI controls to show the segment is loaded
SetDlgItemText( hDlg, IDC_FILENAME, strFileName );
SetDlgItemText( hDlg, IDC_STATUS, TEXT("File loaded.") );
EnablePlayUI( hDlg, TRUE );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: ProcessDirectMusicMessages()
// Desc: Handle DirectMusic notification messages
//-----------------------------------------------------------------------------
HRESULT ProcessDirectMusicMessages( HWND hDlg )
{
HRESULT hr;
IDirectMusicPerformance* pPerf = NULL;
DMUS_NOTIFICATION_PMSG* pPMsg;
if( NULL == g_pMusicManager )
return S_OK;
pPerf = g_pMusicManager->GetPerformance();
// Get waiting notification message from the performance
while( S_OK == pPerf->GetNotificationPMsg( &pPMsg ) )
{
switch( pPMsg->dwNotificationOption )
{
case DMUS_NOTIFICATION_SEGSTART:
if( pPMsg->punkUser )
{
IDirectMusicSegment* pPrimarySegment = NULL;
IDirectMusicSegmentState8* pSegmentState = NULL;
IDirectMusicSegment* pNotifySegment = NULL;
IDirectMusicSegment8* pPrimarySegment8 = NULL;
// The pPMsg->punkUser contains a IDirectMusicSegmentState8,
// which we can query for the segment that segment it refers to.
if( FAILED( hr = pPMsg->punkUser->QueryInterface( IID_IDirectMusicSegmentState8,
(VOID**) &pSegmentState ) ) )
return DXTRACE_ERR( TEXT("QueryInterface"), hr );
if( FAILED( hr = pSegmentState->GetSegment( &pNotifySegment ) ) )
return DXTRACE_ERR( TEXT("GetSegment"), hr );
// Get the IDirectMusicSegment for the primary segment
pPrimarySegment8 = g_pMusicSegment->GetSegment();
if( FAILED( hr = pPrimarySegment8->QueryInterface( IID_IDirectMusicSegment,
(VOID**) &pPrimarySegment ) ) )
return DXTRACE_ERR( TEXT("QueryInterface"), hr );
// Figure out which segment this is
if( pNotifySegment == pPrimarySegment )
{
SetDlgItemText( hDlg, IDC_STATUS, "Primary segment playing." );
}
else
{
// Look through the motfs and see if they are playing
HWND hListBox = GetDlgItem( hDlg, IDC_MOTIF_LIST );
DWORD dwCount = (DWORD)SendMessage( hListBox, LB_GETCOUNT, 0, 0 );
for( DWORD i=0; i<dwCount; i++ )
{
MOTIF_NODE* pMotifNode = (MOTIF_NODE*) SendMessage( hListBox, LB_GETITEMDATA, i, 0 );
if( pNotifySegment == pMotifNode->pMotif )
{
// If its motif segment update the UI
TCHAR strMotifName[MAX_PATH];
SendMessage( hListBox, LB_GETTEXT, i, (LPARAM) strMotifName );
TCHAR strStatus[MAX_PATH];
if( pMotifNode->dwPlayCount > 0 )
strMotifName[ strlen(strMotifName) - strlen(" (Playing)") ] = 0;
wsprintf( strStatus, "%s motif started playing.", strMotifName );
SetDlgItemText( hDlg, IDC_STATUS, strStatus );
pMotifNode->dwPlayCount++;
if( pMotifNode->dwPlayCount == 1 )
{
int nCurSel = (int)SendMessage( hListBox, LB_GETCURSEL, 0, 0 );
SendMessage( hListBox, LB_DELETESTRING, i, 0 );
strcat( strMotifName, " (Playing)" );
SendMessage( hListBox, LB_INSERTSTRING, i, (LPARAM) strMotifName );
SendMessage( hListBox, LB_SETITEMDATA, i, (LPARAM) pMotifNode );
SendMessage( hListBox, LB_SETCURSEL, nCurSel, 0 );
}
}
}
}
// Cleanup
SAFE_RELEASE( pSegmentState );
SAFE_RELEASE( pNotifySegment );
SAFE_RELEASE( pPrimarySegment );
}
break;
case DMUS_NOTIFICATION_SEGEND:
if( pPMsg->punkUser )
{
IDirectMusicSegment* pPrimarySegment = NULL;
IDirectMusicSegmentState8* pSegmentState = NULL;
IDirectMusicSegment* pNotifySegment = NULL;
IDirectMusicSegment8* pPrimarySegment8 = NULL;
// The pPMsg->punkUser contains a IDirectMusicSegmentState8,
// which we can query for the segment that segment it refers to.
if( FAILED( hr = pPMsg->punkUser->QueryInterface( IID_IDirectMusicSegmentState8,
(VOID**) &pSegmentState ) ) )
return DXTRACE_ERR( TEXT("QueryInterface"), hr );
if( FAILED( hr = pSegmentState->GetSegment( &pNotifySegment ) ) )
{
// Sometimes the segend arrives after the segment is gone
// This can happen when you load another segment as
// a motif or the segment is ending
if( hr == DMUS_E_NOT_FOUND )
{
SAFE_RELEASE( pSegmentState );
return S_OK;
}
return DXTRACE_ERR( TEXT("GetSegment"), hr );
}
// Get the IDirectMusicSegment for the primary segment
pPrimarySegment8 = g_pMusicSegment->GetSegment();
if( FAILED( hr = pPrimarySegment8->QueryInterface( IID_IDirectMusicSegment,
(VOID**) &pPrimarySegment ) ) )
return DXTRACE_ERR( TEXT("QueryInterface"), hr );
// Figure out which segment this is
if( pNotifySegment == pPrimarySegment )
{
// Update the UI controls to show the sound as stopped
SetDlgItemText( hDlg, IDC_STATUS, "Primary segment stopped." );
EnablePlayUI( hDlg, TRUE );
}
else
{
HWND hListBox = GetDlgItem( hDlg, IDC_MOTIF_LIST );
DWORD dwCount = (DWORD)SendMessage( hListBox, LB_GETCOUNT, 0, 0 );
for( DWORD i=0; i<dwCount; i++ )
{
MOTIF_NODE* pMotifNode = (MOTIF_NODE*) SendMessage( hListBox, LB_GETITEMDATA, i, 0 );
if( pNotifySegment == pMotifNode->pMotif )
{
// If its motif segment update the UI
TCHAR strMotifName[MAX_PATH];
SendMessage( hListBox, LB_GETTEXT, i, (LPARAM) strMotifName );
strMotifName[ strlen(strMotifName) - strlen(" (Playing)") ] = 0;
pMotifNode->dwPlayCount--;
if( pMotifNode->dwPlayCount == 0 )
{
int nCurSel = (int)SendMessage( hListBox, LB_GETCURSEL, 0, 0 );
SendMessage( hListBox, LB_DELETESTRING, i, 0 );
SendMessage( hListBox, LB_INSERTSTRING, i, (LPARAM) strMotifName );
SendMessage( hListBox, LB_SETITEMDATA, i, (LPARAM) pMotifNode );
SendMessage( hListBox, LB_SETCURSEL, nCurSel, 0 );
}
TCHAR strStatus[MAX_PATH];
wsprintf( strStatus, "%s motif stopped playing.", strMotifName );
SetDlgItemText( hDlg, IDC_STATUS, strStatus );
}
}
}
// Cleanup
SAFE_RELEASE( pSegmentState );
SAFE_RELEASE( pNotifySegment );
SAFE_RELEASE( pPrimarySegment );
}
break;
}
pPerf->FreePMsg( (DMUS_PMSG*)pPMsg );
}
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnPlaySegment()
// Desc:
//-----------------------------------------------------------------------------
HRESULT OnPlaySegment( HWND hDlg )
{
HRESULT hr;
HWND hLoopButton = GetDlgItem( hDlg, IDC_LOOP_CHECK );
BOOL bLooped = ( SendMessage( hLoopButton, BM_GETSTATE, 0, 0 ) == BST_CHECKED );
if( bLooped )
{
// Set the segment to repeat many times
if( FAILED( hr = g_pMusicSegment->SetRepeats( DMUS_SEG_REPEAT_INFINITE ) ) )
return DXTRACE_ERR( TEXT("SetRepeats"), hr );
}
else
{
// Set the segment to not repeat
if( FAILED( hr = g_pMusicSegment->SetRepeats( 0 ) ) )
return DXTRACE_ERR( TEXT("SetRepeats"), hr );
}
// Play the segment and wait. The DMUS_SEGF_BEAT indicates to play on the
// next beat if there is a segment currently playing. The first 0 indicates
// to play (on the next beat from) now.
if( FAILED( hr = g_pMusicSegment->Play( DMUS_SEGF_BEAT ) ) )
return DXTRACE_ERR( TEXT("Play"), hr );
EnablePlayUI( hDlg, FALSE );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: OnPlayMotif()
// Desc:
//-----------------------------------------------------------------------------
HRESULT OnPlayMotif( HWND hDlg )
{
HRESULT hr;
DWORD dwSegFlags = DMUS_SEGF_SECONDARY;
HWND hListBox = GetDlgItem( hDlg, IDC_MOTIF_LIST );
int nIndex = (int)SendMessage( hListBox, LB_GETCURSEL, 0, 0 );
if( nIndex == LB_ERR )
return S_FALSE;
if( IsDlgButtonChecked( hDlg, IDC_RADIO_DEFAULT ) == BST_CHECKED )
dwSegFlags |= DMUS_SEGF_DEFAULT;
else if( IsDlgButtonChecked( hDlg, IDC_RADIO_IMMEDIATE ) == BST_CHECKED )
dwSegFlags |= 0;
else if( IsDlgButtonChecked( hDlg, IDC_RADIO_GRID ) == BST_CHECKED )
dwSegFlags |= DMUS_SEGF_GRID;
else if( IsDlgButtonChecked( hDlg, IDC_RADIO_BEAT ) == BST_CHECKED )
dwSegFlags |= DMUS_SEGF_BEAT;
else if( IsDlgButtonChecked( hDlg, IDC_RADIO_MEASURE ) == BST_CHECKED )
dwSegFlags |= DMUS_SEGF_MEASURE;
TCHAR strMotifName[ MAX_PATH ];
SendMessage( hListBox, LB_GETTEXT, nIndex, (LPARAM) strMotifName );
WCHAR wstrMotifName[ MAX_PATH ];
mbstowcs( wstrMotifName, strMotifName, MAX_PATH );
IDirectMusicSegment* pMotif = NULL;
MOTIF_NODE* pMotifNode = (MOTIF_NODE*) SendMessage( hListBox, LB_GETITEMDATA, nIndex, 0 );
IDirectMusicPerformance* pPerformance = g_pMusicManager->GetPerformance();
if( FAILED( hr = pPerformance->PlaySegment( pMotifNode->pMotif, dwSegFlags,
0, NULL ) ) )
return DXTRACE_ERR( TEXT("PlaySegment"), hr );
return S_OK;
}
//-----------------------------------------------------------------------------
// 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_MOTIF ), FALSE );
EnableWindow( GetDlgItem( hDlg, IDC_PLAY ), TRUE );
SetFocus( GetDlgItem( hDlg, IDC_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 ), FALSE );
HWND hListBox = GetDlgItem( hDlg, IDC_MOTIF_LIST );
int nIndex = (int)SendMessage( hListBox, LB_GETCURSEL, 0, 0 );
if( nIndex == LB_ERR )
EnableWindow( GetDlgItem( hDlg, IDC_PLAY_MOTIF ), FALSE );
else
EnableWindow( GetDlgItem( hDlg, IDC_PLAY_MOTIF ), TRUE );
}
}

View File

@@ -0,0 +1,140 @@
# Microsoft Developer Studio Project File - Name="PlayMotif" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=PlayMotif - 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 "PlayMotif.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 "PlayMotif.mak" CFG="PlayMotif - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "PlayMotif - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "PlayMotif - 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)" == "PlayMotif - 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" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /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 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
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "PlayMotif - 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" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /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 dxerr8.lib winmm.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 "PlayMotif - Win32 Release"
# Name "PlayMotif - Win32 Debug"
# Begin Group "Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\PlayMotif.cpp
# End Source File
# End Group
# Begin Group "Resource"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\directx.ico
# End Source File
# Begin Source File
SOURCE=.\PlayMotif.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\dmutil.cpp
# End Source File
# Begin Source File
SOURCE=..\..\common\include\dmutil.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: "PlayMotif"=.\PlayMotif.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 PlayMotif.dsp
!IF "$(CFG)" == ""
CFG=PlayMotif - Win32 Debug
!MESSAGE No configuration specified. Defaulting to PlayMotif - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "PlayMotif - Win32 Release" && "$(CFG)" != "PlayMotif - 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 "PlayMotif.mak" CFG="PlayMotif - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "PlayMotif - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "PlayMotif - 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)" == "PlayMotif - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\PlayMotif.exe"
CLEAN :
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\PlayMotif.obj"
-@erase "$(INTDIR)\PlayMotif.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\PlayMotif.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" /Fp"$(INTDIR)\PlayMotif.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\PlayMotif.res" /d "NDEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\PlayMotif.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=dxerr8.lib winmm.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)\PlayMotif.pdb" /machine:I386 /out:"$(OUTDIR)\PlayMotif.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\PlayMotif.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\PlayMotif.res"
"$(OUTDIR)\PlayMotif.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "PlayMotif - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\PlayMotif.exe"
CLEAN :
-@erase "$(INTDIR)\dmutil.obj"
-@erase "$(INTDIR)\dxutil.obj"
-@erase "$(INTDIR)\PlayMotif.obj"
-@erase "$(INTDIR)\PlayMotif.res"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\PlayMotif.exe"
-@erase "$(OUTDIR)\PlayMotif.ilk"
-@erase "$(OUTDIR)\PlayMotif.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" /Fp"$(INTDIR)\PlayMotif.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 /o "NUL" /win32
RSC=rc.exe
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\PlayMotif.res" /d "_DEBUG"
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\PlayMotif.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=dxerr8.lib winmm.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)\PlayMotif.pdb" /debug /machine:I386 /out:"$(OUTDIR)\PlayMotif.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\PlayMotif.obj" \
"$(INTDIR)\dmutil.obj" \
"$(INTDIR)\dxutil.obj" \
"$(INTDIR)\PlayMotif.res"
"$(OUTDIR)\PlayMotif.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("PlayMotif.dep")
!INCLUDE "PlayMotif.dep"
!ELSE
!MESSAGE Warning: cannot find "PlayMotif.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "PlayMotif - Win32 Release" || "$(CFG)" == "PlayMotif - Win32 Debug"
SOURCE=.\PlayMotif.cpp
"$(INTDIR)\PlayMotif.obj" : $(SOURCE) "$(INTDIR)"
SOURCE=.\PlayMotif.rc
"$(INTDIR)\PlayMotif.res" : $(SOURCE) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
SOURCE=..\..\common\src\dmutil.cpp
"$(INTDIR)\dmutil.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,129 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <windows.h>
#define IDC_STATIC -1
/////////////////////////////////////////////////////////////////////////////
#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
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_MAIN DIALOG DISCARDABLE 0, 0, 262, 186
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
CAPTION "DirectMusic Motif Player"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "Segment &file...",IDC_SOUNDFILE,7,7,54,13
EDITTEXT IDC_FILENAME,68,7,186,14,ES_AUTOHSCROLL | ES_READONLY
CONTROL "&Loop segment",IDC_LOOP_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,7,46,61,10
PUSHBUTTON "&Play",IDC_PLAY,69,44,50,14,WS_DISABLED
PUSHBUTTON "&Stop",IDC_STOP,119,44,50,14,WS_DISABLED
LTEXT "Select a motif:",IDC_STATIC,7,60,46,8
LISTBOX IDC_MOTIF_LIST,7,70,247,77,LBS_NOINTEGRALHEIGHT |
WS_VSCROLL | WS_TABSTOP
LTEXT "Align Option:",IDC_STATIC,7,152,43,10
CONTROL "Default",IDC_RADIO_DEFAULT,"Button",BS_AUTORADIOBUTTON,
51,152,39,10
CONTROL "Immediate",IDC_RADIO_IMMEDIATE,"Button",
BS_AUTORADIOBUTTON,92,152,48,10
CONTROL "Grid",IDC_RADIO_GRID,"Button",BS_AUTORADIOBUTTON,142,
152,29,10
CONTROL "Beat",IDC_RADIO_BEAT,"Button",BS_AUTORADIOBUTTON,173,
152,31,10
CONTROL "Measure",IDC_RADIO_MEASURE,"Button",BS_AUTORADIOBUTTON,
206,152,43,10
PUSHBUTTON "Play &Motif",IDC_PLAY_MOTIF,7,165,50,14
PUSHBUTTON "E&xit",IDCANCEL,204,165,50,14
EDITTEXT IDC_STATUS,68,26,186,14,ES_AUTOHSCROLL | ES_READONLY
RTEXT "Status:",IDC_STATIC,7,29,54,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 254
TOPMARGIN, 7
BOTTOMMARGIN, 179
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include <windows.h>\r\n"
"#define IDC_STATIC -1\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\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"
#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,31 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by PlayMotif.rc
//
#define IDD_MAIN 101
#define IDR_MAINFRAME 102
#define IDR_ACCELERATOR1 131
#define IDC_PLAY 1002
#define IDC_STOP 1003
#define IDC_FILENAME 1004
#define IDC_STATUS 1005
#define IDC_MOTIF_LIST 1008
#define IDC_LOOP_CHECK 1009
#define IDC_SOUNDFILE 1011
#define IDC_PLAY_MOTIF 1015
#define IDC_RADIO_DEFAULT 1016
#define IDC_RADIO_IMMEDIATE 1017
#define IDC_RADIO_GRID 1018
#define IDC_RADIO_BEAT 1019
#define IDC_RADIO_MEASURE 1020
// 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 1021
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,101 @@
//-----------------------------------------------------------------------------
// File: play.cpp
//
// Desc: DirectMusic tutorial to show how to play a segment
// on the default audio path
//
// Copyright (c) 2000-2001 Microsoft Corp. All rights reserved.
//-----------------------------------------------------------------------------
#define INITGUID
#include <windows.h>
#include <dmusicc.h>
#include <dmusici.h>
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
IDirectMusicLoader8* g_pLoader = NULL;
IDirectMusicPerformance8* g_pPerformance = NULL;
IDirectMusicSegment8* g_pSegment = NULL;
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: Plays a single wave file using DirectMusic on the default audio path.
//-----------------------------------------------------------------------------
INT APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine,
INT nCmdShow )
{
// Initialize COM
CoInitialize(NULL);
// Create loader object
CoCreateInstance( CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC,
IID_IDirectMusicLoader8, (void**)&g_pLoader );
// Create performance object
CoCreateInstance( CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC,
IID_IDirectMusicPerformance8, (void**)&g_pPerformance );
// Initialize the performance with the standard audio path.
// This initializes both DirectMusic and DirectSound and
// sets up the synthesizer.
g_pPerformance->InitAudio( NULL, NULL, NULL,
DMUS_APATH_SHARED_STEREOPLUSREVERB, 64,
DMUS_AUDIOF_ALL, NULL );
CHAR strPath[MAX_PATH];
GetWindowsDirectory( strPath, MAX_PATH );
strcat( strPath, "\\media" );
// Tell DirectMusic where the default search path is
WCHAR wstrSearchPath[MAX_PATH];
MultiByteToWideChar( CP_ACP, 0, strPath, -1,
wstrSearchPath, MAX_PATH );
g_pLoader->SetSearchDirectory( GUID_DirectMusicAllTypes,
wstrSearchPath, FALSE );
// Load the segment from the file
WCHAR wstrFileName[MAX_PATH] = L"The Microsoft Sound.wav";
if( FAILED( g_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment,
IID_IDirectMusicSegment8,
wstrFileName,
(LPVOID*) &g_pSegment ) ) )
{
MessageBox( NULL, "Media not found, sample will now quit",
"DirectMusic Tutorial", MB_OK );
return 0;
}
// Download the segment's instruments to the synthesizer
g_pSegment->Download( g_pPerformance );
// Play segment on the default audio path
g_pPerformance->PlaySegmentEx( g_pSegment, NULL, NULL, 0,
0, NULL, NULL, NULL );
// Now DirectMusic will play in the backgroud,
// so continue on with our task
MessageBox( NULL, "Click OK to Exit.", "DirectMusic Tutorial", MB_OK );
// Stop the music, and close down
g_pPerformance->Stop( NULL, NULL, 0, 0 );
g_pPerformance->CloseDown();
// Cleanup all interfaces
g_pLoader->Release();
g_pPerformance->Release();
g_pSegment->Release();
// Close down COM
CoUninitialize();
return 0;
}

View File

@@ -0,0 +1,99 @@
# Microsoft Developer Studio Project File - Name="tutorial1" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=tutorial1 - 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 "tutorial1.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 "tutorial1.mak" CFG="tutorial1 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "tutorial1 - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "tutorial1 - 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)" == "tutorial1 - 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" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /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 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)" == "tutorial1 - 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" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /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 winmm.lib dxerr8.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 "tutorial1 - Win32 Release"
# Name "tutorial1 - Win32 Debug"
# Begin Group "Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\tutorial1.cpp
# End Source File
# End Group
# 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: "Play"=.\tutorial1.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,189 @@
# Microsoft Developer Studio Generated NMAKE File, Based on tutorial1.dsp
!IF "$(CFG)" == ""
CFG=tutorial1 - Win32 Debug
!MESSAGE No configuration specified. Defaulting to tutorial1 - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "tutorial1 - Win32 Release" && "$(CFG)" != "tutorial1 - 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 "tutorial1.mak" CFG="tutorial1 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "tutorial1 - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "tutorial1 - 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)" == "tutorial1 - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\tutorial1.exe"
CLEAN :
-@erase "$(INTDIR)\tutorial1.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\tutorial1.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\tutorial1.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 /o "NUL" /win32
RSC=rc.exe
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\tutorial1.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=dxerr8.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)\tutorial1.pdb" /machine:I386 /out:"$(OUTDIR)\tutorial1.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\tutorial1.obj"
"$(OUTDIR)\tutorial1.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "tutorial1 - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\tutorial1.exe"
CLEAN :
-@erase "$(INTDIR)\tutorial1.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\tutorial1.exe"
-@erase "$(OUTDIR)\tutorial1.ilk"
-@erase "$(OUTDIR)\tutorial1.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" /Fp"$(INTDIR)\tutorial1.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 /o "NUL" /win32
RSC=rc.exe
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\tutorial1.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=winmm.lib dxerr8.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)\tutorial1.pdb" /debug /machine:I386 /out:"$(OUTDIR)\tutorial1.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\tutorial1.obj"
"$(OUTDIR)\tutorial1.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("tutorial1.dep")
!INCLUDE "tutorial1.dep"
!ELSE
!MESSAGE Warning: cannot find "tutorial1.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "tutorial1 - Win32 Release" || "$(CFG)" == "tutorial1 - Win32 Debug"
SOURCE=.\tutorial1.cpp
"$(INTDIR)\tutorial1.obj" : $(SOURCE) "$(INTDIR)"
!ENDIF

View File

@@ -0,0 +1,136 @@
//-----------------------------------------------------------------------------
// File: tutorial2.cpp
//
// Desc: DirectMusic tutorial to show how to get an object from
// an audiopath, and set the 3D position of a DirectMusic segment
//
// Copyright (c) 2000-2001 Microsoft Corp. All rights reserved.
//-----------------------------------------------------------------------------
#define INITGUID
#include <windows.h>
#include <dmusicc.h>
#include <dmusici.h>
#include <cguid.h>
//-----------------------------------------------------------------------------
// Defines, constants, and global variables
//-----------------------------------------------------------------------------
IDirectMusicLoader8* g_pLoader = NULL;
IDirectMusicPerformance8* g_pPerformance = NULL;
IDirectMusicSegment8* g_pSegment = NULL;
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: Plays a single wave file using DirectMusic on the default audiopath.
//-----------------------------------------------------------------------------
INT APIENTRY WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine,
INT nCmdShow )
{
// Initialize COM
CoInitialize(NULL);
// Create loader object
CoCreateInstance( CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC,
IID_IDirectMusicLoader8, (void**)&g_pLoader );
// Create performance object
CoCreateInstance( CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC,
IID_IDirectMusicPerformance8, (void**)&g_pPerformance );
// This initializes both DirectMusic and DirectSound and
// sets up the synthesizer.
g_pPerformance->InitAudio( NULL, NULL, NULL,
DMUS_APATH_DYNAMIC_STEREO, 64,
DMUS_AUDIOF_ALL, NULL );
CHAR strPath[MAX_PATH];
GetWindowsDirectory( strPath, MAX_PATH );
strcat( strPath, "\\media" );
// Tell DirectMusic where the default search path is
WCHAR wstrSearchPath[MAX_PATH];
MultiByteToWideChar( CP_ACP, 0, strPath, -1,
wstrSearchPath, MAX_PATH );
g_pLoader->SetSearchDirectory( GUID_DirectMusicAllTypes,
wstrSearchPath, FALSE );
// Load the segment from the file
WCHAR wstrFileName[MAX_PATH] = L"The Microsoft Sound.wav";
if( FAILED( g_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment,
IID_IDirectMusicSegment8,
wstrFileName,
(LPVOID*) &g_pSegment ) ) )
{
MessageBox( NULL, "Media not found, sample will now quit",
"DirectMusic Tutorial", MB_OK );
return 0;
}
// Download the segment's instruments to the synthesizer
g_pSegment->Download( g_pPerformance );
// Tell DirectMusic to repeat this segment forever
g_pSegment->SetRepeats( DMUS_SEG_REPEAT_INFINITE );
// Create an 3D audiopath with a 3d buffer.
// We can then play all segments into this buffer and directly control its
// 3D parameters.
IDirectMusicAudioPath8* p3DAudioPath = NULL;
g_pPerformance->CreateStandardAudioPath( DMUS_APATH_DYNAMIC_3D,
64, TRUE, &p3DAudioPath );
// Play segment on the 3D audiopath
g_pPerformance->PlaySegmentEx( g_pSegment, NULL, NULL, 0,
0, NULL, NULL, p3DAudioPath );
// Now DirectMusic will play in the backgroud,
// so continue on with our task
MessageBox( NULL, "The music is now playing in center. " \
"Click OK to pan music to left.", "DirectMusic Tutorial", MB_OK );
// Get the IDirectSound3DBuffer8 from the 3D audiopath
IDirectSound3DBuffer8* pDSB = NULL;
p3DAudioPath->GetObjectInPath( DMUS_PCHANNEL_ALL, DMUS_PATH_BUFFER, 0,
GUID_NULL, 0, IID_IDirectSound3DBuffer,
(LPVOID*) &pDSB );
// Set the position of sound a little to the left
pDSB->SetPosition( -0.1f, 0.0f, 0.0f, DS3D_IMMEDIATE );
// Wait for input
MessageBox( NULL, "The music is now playing on the left. " \
"Click OK to pan music to right.", "DirectMusic Tutorial", MB_OK );
// Set the position of sound a little to the right
pDSB->SetPosition( 0.1f, 0.0f, 0.0f, DS3D_IMMEDIATE );
// Wait for input
MessageBox( NULL, "The music is now playing on the right. " \
"Click OK to exit.", "DirectMusic Tutorial", MB_OK );
// Stop the music
g_pPerformance->Stop( NULL, NULL, 0, 0 );
// Cleanup all interfaces
pDSB->Release();
p3DAudioPath->Release();
g_pLoader->Release();
g_pSegment->Release();
// Close down DirectMusic after releasing the DirectSound buffers
g_pPerformance->CloseDown();
g_pPerformance->Release();
// Close down COM
CoUninitialize();
return 0;
}

View File

@@ -0,0 +1,103 @@
# Microsoft Developer Studio Project File - Name="tutorial2" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=tutorial2 - 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 "tutorial2.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 "tutorial2.mak" CFG="tutorial2 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "tutorial2 - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "tutorial2 - 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)" == "tutorial2 - 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" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /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 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)" == "tutorial2 - 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" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /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 winmm.lib dxerr8.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 "tutorial2 - Win32 Release"
# Name "tutorial2 - Win32 Debug"
# Begin Group "Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\tutorial2.cpp
# 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: "Play"=.\tutorial2.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,189 @@
# Microsoft Developer Studio Generated NMAKE File, Based on tutorial2.dsp
!IF "$(CFG)" == ""
CFG=tutorial2 - Win32 Debug
!MESSAGE No configuration specified. Defaulting to tutorial2 - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "tutorial2 - Win32 Release" && "$(CFG)" != "tutorial2 - 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 "tutorial2.mak" CFG="tutorial2 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "tutorial2 - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "tutorial2 - 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)" == "tutorial2 - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\tutorial2.exe"
CLEAN :
-@erase "$(INTDIR)\tutorial2.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\tutorial2.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\tutorial2.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 /o "NUL" /win32
RSC=rc.exe
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\tutorial2.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=dxerr8.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)\tutorial2.pdb" /machine:I386 /out:"$(OUTDIR)\tutorial2.exe" /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\tutorial2.obj"
"$(OUTDIR)\tutorial2.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "tutorial2 - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\tutorial2.exe"
CLEAN :
-@erase "$(INTDIR)\tutorial2.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(OUTDIR)\tutorial2.exe"
-@erase "$(OUTDIR)\tutorial2.ilk"
-@erase "$(OUTDIR)\tutorial2.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" /Fp"$(INTDIR)\tutorial2.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 /o "NUL" /win32
RSC=rc.exe
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\tutorial2.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=winmm.lib dxerr8.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)\tutorial2.pdb" /debug /machine:I386 /out:"$(OUTDIR)\tutorial2.exe" /pdbtype:sept /stack:0x200000,0x200000
LINK32_OBJS= \
"$(INTDIR)\tutorial2.obj"
"$(OUTDIR)\tutorial2.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("tutorial2.dep")
!INCLUDE "tutorial2.dep"
!ELSE
!MESSAGE Warning: cannot find "tutorial2.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "tutorial2 - Win32 Release" || "$(CFG)" == "tutorial2 - Win32 Debug"
SOURCE=.\tutorial2.cpp
"$(INTDIR)\tutorial2.obj" : $(SOURCE) "$(INTDIR)"
!ENDIF

View File

@@ -0,0 +1,125 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "3DAudio"=.\3daudio\3DAudio.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "AudioPath"=.\audiopath\audiopath.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "AudioScripts"=.\audioscripts\AudioScripts.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "MusicTool"=.\musictool\MusicTool.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "PlayAudio"=.\playaudio\PlayAudio.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "PlayMotif"=.\PlayMotif\PlayMotif.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "audiofx"=.\audiofx\audiofx.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "tutorial1"=.\tutorials\tut1\tutorial1.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "tutorial2"=.\tutorials\tut2\tutorial2.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################