//----------------------------------------------------------------------------- // Name: CMusicManager::GetMotifFromStyle() // Desc: //----------------------------------------------------------------------------- HRESULT CMusicManager::GetMotifFromStyle( IDirectMusicSegment8** ppMotif8, TCHAR* strStyle, TCHAR* strMotif ) { UNREFERENCED_PARAMETER( strMotif ); HRESULT hr; IDirectMusicStyle8* pStyle = NULL; IDirectMusicSegment* pMotif = NULL; if( FAILED( hr = CreateStyleFromFile( &pStyle, strStyle ) ) ) return DXTRACE_ERR_MSGBOX( TEXT("CreateStyleFromFile"), hr ); if( pStyle ) { // DMusic only takes wide strings WCHAR wstrMotif[MAX_PATH]; DXUtil_ConvertGenericStringToWideCb( wstrMotif, strStyle, sizeof(wstrMotif) ); hr = pStyle->GetMotif( wstrMotif, &pMotif ); SAFE_RELEASE( pStyle ); if( FAILED( hr ) ) return DXTRACE_ERR_MSGBOX( TEXT("GetMotif"), hr ); pMotif->QueryInterface( IID_IDirectMusicSegment8, (LPVOID*) ppMotif8 ); } return S_OK; }
//----------------------------------------------------------------------------- // Name: CMusicManager::CreateScriptFromFile() // Desc: //----------------------------------------------------------------------------- HRESULT CMusicManager::CreateScriptFromFile( CMusicScript** ppScript, TCHAR* strFileName ) { HRESULT hr; IDirectMusicScript* pScript = NULL; // DMusic only takes wide strings WCHAR wstrFileName[MAX_PATH]; DXUtil_ConvertGenericStringToWideCb( wstrFileName, strFileName, sizeof(wstrFileName) ); if ( FAILED( hr = m_pLoader->LoadObjectFromFile( CLSID_DirectMusicScript, IID_IDirectMusicScript8, wstrFileName, (LPVOID*) &pScript ) ) ) return DXTRACE_ERR( TEXT("LoadObjectFromFile"), hr ); if ( FAILED( hr = pScript->Init( m_pPerformance, NULL ) ) ) return DXTRACE_ERR_MSGBOX( TEXT("Init"), hr ); *ppScript = new CMusicScript( m_pPerformance, m_pLoader, pScript ); if (!*ppScript) return E_OUTOFMEMORY; return hr; }
//----------------------------------------------------------------------------- // Name: CMusicScript::GetVariableObject() // Desc: Gets an object from the script //----------------------------------------------------------------------------- HRESULT CMusicScript::GetVariableObject( TCHAR* strVariable, REFIID riid, LPVOID FAR *ppv ) { // DMusic only takes wide strings WCHAR wstrVariable[MAX_PATH]; DXUtil_ConvertGenericStringToWideCb( wstrVariable, strVariable, sizeof(wstrVariable) ); return m_pScript->GetVariableObject( wstrVariable, riid, ppv, NULL ); }
//----------------------------------------------------------------------------- // Name: CMusicScript::SetVariableObject() // Desc: Sets an object in the script //----------------------------------------------------------------------------- HRESULT CMusicScript::SetVariableObject( TCHAR* strVariable, IUnknown *punkValue ) { // DMusic only takes wide strings WCHAR wstrVariable[MAX_PATH]; DXUtil_ConvertGenericStringToWideCb( wstrVariable, strVariable, sizeof(wstrVariable) ); return m_pScript->SetVariableObject( wstrVariable, punkValue, NULL ); }
//----------------------------------------------------------------------------- // Name: CMusicScript::GetVariableNumber() // Desc: Gets the value of a variable in the script //----------------------------------------------------------------------------- HRESULT CMusicScript::GetVariableNumber( TCHAR* strVariable, LONG* plValue ) { // DMusic only takes wide strings WCHAR wstrVariable[MAX_PATH]; DXUtil_ConvertGenericStringToWideCb( wstrVariable, strVariable, sizeof(wstrVariable) ); return m_pScript->GetVariableNumber( wstrVariable, plValue, NULL ); }
//----------------------------------------------------------------------------- // Name: CMusicScript::Play() // Desc: Calls a routine in the script //----------------------------------------------------------------------------- HRESULT CMusicScript::CallRoutine( TCHAR* strRoutine ) { // DMusic only takes wide strings WCHAR wstrRoutine[MAX_PATH]; DXUtil_ConvertGenericStringToWideCb( wstrRoutine, strRoutine, sizeof(wstrRoutine) ); return m_pScript->CallRoutine( wstrRoutine, NULL ); }
//----------------------------------------------------------------------------- // Name: CMusicManager::CreateChordMapFromFile() // Desc: //----------------------------------------------------------------------------- HRESULT CMusicManager::CreateStyleFromFile( IDirectMusicStyle8** ppStyle, TCHAR* strFileName ) { // DMusic only takes wide strings WCHAR wstrFileName[MAX_PATH]; DXUtil_ConvertGenericStringToWideCb( wstrFileName, strFileName, sizeof(wstrFileName) ); return m_pLoader->LoadObjectFromFile( CLSID_DirectMusicStyle, IID_IDirectMusicStyle8, wstrFileName, (LPVOID*) ppStyle ); }
//----------------------------------------------------------------------------- // Name: CMusicManager::Create3DSegmentFromFile() // Desc: //----------------------------------------------------------------------------- HRESULT CMusicManager::Create3DSegmentFromFile( C3DMusicSegment** pp3DMusicSegment, TCHAR* strFileName, BOOL bDownloadNow, BOOL bIsMidiFile, IDirectMusicAudioPath8* p3DAudioPath ) { HRESULT hr; IDirectMusicSegment8* pSegment = NULL; // DMusic only takes wide strings WCHAR wstrFileName[MAX_PATH]; DXUtil_ConvertGenericStringToWideCb( wstrFileName, strFileName, sizeof(wstrFileName) ); if ( FAILED( hr = m_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, wstrFileName, (LPVOID*) &pSegment ) ) ) { if( hr == DMUS_E_LOADER_FAILEDOPEN ) return hr; return DXTRACE_ERR( TEXT("LoadObjectFromFile"), hr ); } if( *pp3DMusicSegment != NULL ) SAFE_DELETE(*pp3DMusicSegment); *pp3DMusicSegment = new C3DMusicSegment( m_pPerformance, m_pLoader, pSegment, p3DAudioPath ); if (!*pp3DMusicSegment) return E_OUTOFMEMORY; if( FAILED( hr = (*pp3DMusicSegment)->Init() ) ) return DXTRACE_ERR( TEXT("SetParam"), hr ); if( bIsMidiFile ) { if( FAILED( hr = pSegment->SetParam( GUID_StandardMIDIFile, 0xFFFFFFFF, 0, 0, NULL ) ) ) return DXTRACE_ERR( TEXT("SetParam"), hr ); } if( bDownloadNow ) { if( FAILED( hr = (*pp3DMusicSegment)->Download() ) ) return DXTRACE_ERR( TEXT("Download"), hr ); } return S_OK; }
//----------------------------------------------------------------------------- // Name: CMusicManager::SetSearchDirectory() // Desc: Sets the search directory. If not called, the current working // directory is used to load content. //----------------------------------------------------------------------------- HRESULT CMusicManager::SetSearchDirectory( const TCHAR* strMediaPath ) { if( NULL == m_pLoader ) return E_UNEXPECTED; if( NULL == strMediaPath ) return E_INVALIDARG; // DMusic only takes wide strings WCHAR wstrMediaPath[MAX_PATH]; DXUtil_ConvertGenericStringToWideCb( wstrMediaPath, strMediaPath, sizeof(wstrMediaPath) ); return m_pLoader->SetSearchDirectory( GUID_DirectMusicAllTypes, wstrMediaPath, FALSE ); }