(olddata is unsigned char *, preinitialized)
(mmckinfoSubchunk is MMCKINFO, preinitialized)
ACMSTREAMHEADER acmsh;
HACMSTREAM hAcm;
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)
{
printf("Error.");
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)
{
printf("Error.");
return -1;
}
if (acmStreamUnprepareHeader(hAcm, &acmsh, 0) != 0)
{
printf("Error.");
return -1;
}
acmStreamClose(hAcm, 0);
Resampling using ACM functions
Hi,
I''m trying to resample audio data in a buffer from 44,100Hz to 48000Hz, using the following Win32 C code:-
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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement