Cannot load wave file through IStream

Started by
0 comments, last by Holgersson 22 years, 12 months ago
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.
Advertisement
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
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement