Jump to content
  • Advertisement


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


Resampling using ACM functions

This topic is 5912 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''m trying to resample audio data in a buffer from 44,100Hz to 48000Hz, using the following Win32 C code:-
(olddata is unsigned char *, preinitialized)
(mmckinfoSubchunk is MMCKINFO, preinitialized)
WAVEFORMATEX wfxSrc, wfxDest;
DWORD dwOutputSize;
unsigned char *newdata;
wfxSrc.wFormatTag = WAVE_FORMAT_PCM;
wfxSrc.nChannels = 1;
wfxSrc.nSamplesPerSec = 44100;
wfxSrc.nAvgBytesPerSec = 88200;
wfxSrc.nBlockAlign = 2;
wfxSrc.wBitsPerSample = 16;
wfxDest.wFormatTag = WAVE_FORMAT_PCM;
wfxDest.nChannels = 1;
wfxDest.nSamplesPerSec = 48000;
wfxDest.wBitsPerSample = 16;
wfxDest.nBlockAlign = 2;
wfxDest.nAvgBytesPerSec = 96000;
if (acmStreamOpen(&hAcm, NULL, &wfxSrc, &wfxDest, NULL, 0, 0, 0) != 0)
	return -1;

acmStreamSize(hAcm, mmckinfoSubchunk.cksize, &dwOutputSize, ACM_STREAMSIZEF_SOURCE);
newdata = malloc(dwOutputSize);
ZeroMemory(&acmsh, sizeof(ACMSTREAMHEADER));
acmsh.cbStruct = sizeof(ACMSTREAMHEADER);
acmsh.pbSrc = olddata;
acmsh.cbSrcLength = mmckinfoSubchunk.cksize;
acmsh.pbDst = newdata;
acmsh.cbDstLength = dwOutputSize;
acmStreamPrepareHeader(hAcm, &acmsh, 0);
if (acmStreamConvert(hAcm, &acmsh, 0) != 0)
	return -1;

if (acmStreamUnprepareHeader(hAcm, &acmsh, 0) != 0)
	return -1;

acmStreamClose(hAcm, 0);
Although no errors are generated, nothing actually changes with the data either. It''s as if it just copies it straight over. Can anyone see anything wrong with this?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!