Click to See Complete Forum and Search --> : Playing a PCM audio file


anshnen
December 3rd, 2005, 01:34 AM
I want to play a file with an extension .pcm and has the following class defined for it:

class CPCMFile
{
public:
WAVEFORMATEX* m_pwfx; // Pointer to WAVEFORMATEX structure
HMMIO m_hmmio; // MM I/O handle for the WAVE
MMCKINFO m_ck; // Multimedia RIFF chunk
MMCKINFO m_ckRiff; // Use in opening a WAVE file
DWORD m_dwSize; // The size of the wave file
MMIOINFO m_mmioinfoOut;
DWORD m_dwFlags;
BOOL m_bIsReadingFromMemory;
BYTE* m_pbData;
BYTE* m_pbDataCur;
ULONG m_ulDataSize;
char m_strFileName[_MAX_PATH];

protected:
HRESULT ReadMMIO();
HRESULT WriteMMIO( WAVEFORMATEX *pwfxDest );

public:
CPCMFile();
~CPCMFile();

HRESULT Open( LPTSTR strFileName, WAVEFORMATEX* pwfx, DWORD dwFlags );
HRESULT OpenFromMemory( BYTE* pbData, ULONG ulDataSize, WAVEFORMATEX* pwfx, DWORD dwFlags );
HRESULT Close();

HRESULT Read( BYTE* pBuffer, DWORD dwSizeToRead, DWORD* pdwSizeRead );
HRESULT Write( UINT nSizeToWrite, BYTE* pbData, UINT* pnSizeWrote );

DWORD GetSize();
HRESULT ResetFile();
WAVEFORMATEX* GetFormat() { return m_pwfx; };
};

I dont understand if it is a normal .wav file or it has been modified ?

golanshahar
December 3rd, 2005, 11:56 AM
this article might help:
PCM Audio and Wave Files (http://www.codeguru.com/Cpp/G-M/multimedia/audio/article.php/c8935/)


Cheers

anshnen
December 4th, 2005, 01:38 PM
Ohh sorry for that question, i got a bit confused with the .pcm file i had to play. It turned out to be a .wav file without all its headers. I just appended all the relavant headers and it played alrite.

Thank you.

yiannakop
December 6th, 2005, 05:15 AM
Ohh sorry for that question, i got a bit confused with the .pcm file i had to play. It turned out to be a .wav file without all its headers. I just appended all the relavant headers and it played alrite.

Thank you.
Actually that is what raw pcm files are: wav files without the header information. :wave: