Link to home
Start Free TrialLog in
Avatar of sinha_abhijeet
sinha_abhijeet

asked on

wave file resampling

Hi,
I am new to VC++.
How do I resample(upsample/downsample) any wave file to a predefined value. Basically how do I change the attributes denoted by the WAVEFORMATEX structure, of an already existing file. (for example I have to convert any wav file into 8 khz 16 bit, PCM). The file will be an already existing one and not one to be recorded.
Thanx in advance.
Avatar of Svetlin_Panayotov
Svetlin_Panayotov

There's good article on how to do something similar with DirectSound:
http://msdn.microsoft.com/archive/en-us/directx9_c/directx/htm/capturingwaveforms.asp
but they are capturing the sound there.Since you already have your WAV file you can read it into memory (mmioRead etc.), use it from there and write it to another file with different sample rate using CWaveFile.

Avatar of sinha_abhijeet

ASKER

Instead of using directsound I tried to use the ACM class of wav format converters.
But I tried it too and it does change the file format and also reduces the size as we are downsampling. It also playes well( as a downsamled wave would play) but when I give it to a amr converter software as that is my primary purpose, it does not work. i downloaded some software and did the wav format coversion and then the amr converter could properly convert the wav file into an amr. So, there's something wrong or missing in my code. I am doing it just like the msdn documentation says. Is there something that somebody knows abt this class of wav conversion that is missing? what is it that these professional softwaremakers know that we don't?
thanx in advance

The acmStreamOpen function opens a conversion stream.
The acmStreamSize function calculates the appropriate size of the source or destination buffer.
The acmStreamPrepareHeader function prepares source and destination buffers to be used in a conversion.
The acmStreamConvert function converts data in a source buffer into the destination format, writing the converted data into the destination buffer.
The acmStreamUnprepareHeader function cleans up the source and destination buffers prepared by acmStreamPrepareHeader. You must call this function before freeing the source and destination buffers.
The acmStreamClose function closes a conversion stream.
ASKER CERTIFIED SOLUTION
Avatar of Svetlin_Panayotov
Svetlin_Panayotov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial