DirectSound Problem



  • Hi,

    also ich initialisiere meinen sound, und will dann eine midi datei laden:

    IDirectMusicLoader8 * g_pLoader;
      IDirectMusicPerformance8 * g_pPerformance;
      IDirectMusicSegment8 * g_pSound;
      IDirectMusicAudioPath**  ppAudioPath;
    
    ...
      // Init Direct X Sound
    
      CoInitialize(NULL);
      HRESULT hResult;
    
      if ( FAILED(hResult = CoCreateInstance( CLSID_DirectMusicLoader,
                                                                 NULL,
                                                        CLSCTX_INPROC,
                                              IID_IDirectMusicLoader8,
                                                  (void **)&g_pLoader))){
        throw ((std::string)"Couldn't create Loader");
      }
      if ( FAILED(hResult = CoCreateInstance( CLSID_DirectMusicPerformance,
                                                                      NULL,
                                                             CLSCTX_INPROC,
                                              IID_IDirectMusicPerformance8,
                                                  (void **)&g_pPerformance))){
        throw ((std::string)"Couldn't create Performance");
      }
    
      if ( FAILED(hResult = g_pPerformance->InitAudio(  NULL,
                                                        NULL,
                                                        hWnd,
                                                        DMUS_APATH_DYNAMIC_STEREO,
                                                        4,
                                                        DMUS_AUDIOF_ALL,
                                                        NULL
                                                        ))){
        throw ((std::string)"Couldn't initialize Sound");
      }
    
      if ( FAILED(g_pPerformance->GetDefaultAudioPath(ppAudioPath))){
        ppAudioPath = NULL;
      }
    }
    

    laden:

    bool SoundManager::Play(){
      //Stop();
      std::wstring File = ( MainDir + ((std::wstring)L"\\MIDI\\") + Files[Pos] );
      //:0097AA54 "H:\\...\\...\\MIDI\\(john_weeks)green_hill_zone(gm).mid"
      // Lange verzeichnisse durch ... ersetzt
      if ( FAILED(g_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, const_cast <wchar_t*>(( MainDir + ((std::wstring)L"\\MIDI\\") + Files[Pos] ).c_str()), (LPVOID*)&g_pSound )))
        return false; // kommt immer hier raus
      if ( FAILED(g_pSound->Download(g_pPerformance)))
        return false;
      if ( g_pPerformance->PlaySegmentEx(g_pSound, NULL, NULL, DMUS_SEGF_DEFAULT | DMUS_SEGF_SECONDARY, 0, NULL, NULL, NULL ) != S_OK )
        return false;
      return true;
    }
    

    ich versteh nicht wirklich warum er da die datei nicht laden kann :|

    sie wird vorher über find first fileW & findnextfileW gefunden.



  • Gibt denn LoadObjectFromFile keinen Fehlercode zurück?



  • Gute idee, habs gleich mal überprüft

    -2147221008L (0x800401F0)
    

    was mich jetzt aber schon wunder ist:

    If it fails, the method can return one of the error values shown in the following table.

    Return code
    DMUS_E_LOADER_FAILEDCREATE
    DMUS_E_LOADER_FAILEDOPEN
    DMUS_E_LOADER_FORMATNOTSUPPORTED
    DMUS_E_LOADER_NOCLASSID
    E_FAIL
    E_INVALIDARG
    E_OUTOFMEMORY
    E_POINTER
    REGDB_E_CLASSNOTREG

    und es ist keiner dieser.

    das gleiche ergebniss bei *.wav files wie *.mid



  • DirectX Error Lookup schrieb:

    HRESULT: 0x800401f0 (2147746288)
    Name: CO_E_NOTINITIALIZED
    Description: CoInitialize has not been called.
    Severity code: Failed
    Facility Code: FACILITY_ITF (4)
    Error Code: 0x01f0 (496)



  • Ahh danke danke ! Das hat mir sehr geholfen! Jetzt geht es endlich 😃
    Ich hab jetzt das ganze mit CoInitializeEx gemacht und da noch ne abfrage rein obs fehlschlägt, zudem für multi threads initialisiert weil das auch noch mit drinne is.


Anmelden zum Antworten