Archived

This topic is now archived and is closed to further replies.

Holgersson

Cannot load wave file through IStream

Recommended Posts

Using DirectX Audio i need to load wave file through custom class, which inherited IDirectMusicLoader class. For loading data to pick it up by GetObject function i`m using class public from IStream. Reading and moving of file pointer are made by these functions. STDMETHODIMP CFileStream::Read( void* pv, ULONG cb, ULONG* pcbRead ) { DWORD dw; ReadFile(m_hFile,pv,cb,&dw,NULL); if (cb == dw){ if( pcbRead != NULL ) { *pcbRead = cb; } return S_OK; } return E_FAIL ; } STDMETHODIMP CFileStream::Seek( LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition ) { // fseek can''t handle a LARGE_INTEGER seek... long lOffset; DWORD dwSeek; lOffset = dlibMove.LowPart; DWORD pos = SetFilePointer(m_hFile,lOffset,NULL,dwOrigin); if(pos == 0xffffffff) { return E_FAIL;} if( plibNewPosition != NULL ) { pos = SetFilePointer(m_hFile,0,NULL,FILE_CURRENT); if(pos == 0xffffffff) { return E_FAIL;} plibNewPosition->LowPart = pos; if( lOffset < 0 ) { plibNewPosition->HighPart = -1; } else { plibNewPosition->HighPart = 0; } } return S_OK; } Using this functions i can successfully play midi file, but wave file cannot be read to it`s end.

Share this post


Link to post
Share on other sites
The Dx Sound Capture example comes with a couple of files called ''WaveSoundWrite.h/cpp'' they have a CWaveSoundWrite class in them that should fix you up

Magmai Kai Holmlor
- The disgruntled & disillusioned

Share this post


Link to post
Share on other sites