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:
@@ -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>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
@@ -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 |
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user