it also appears to come with an ACM wrapper.
"Cleaver" <brucec...@netzero.com> wrote in message
news:852da4ccd71368a8...@localhost.talkaboutsoftware.com...
You can use the MP3 ACM codec that comes with Windows (but I
think it can not encode at more than 56Kbps/24KHz) or you
can use the free LAME ACM codec or the free LAME DLL. The
following shows how to use the Windows' ACM codec (the LAME
ACM codec is named L"lameacm.acm") and it assumes the codec
is in the system's path (usually a codec is installed in
%WinDir%\System32, which is in the system's path by
default). The LAME DLL API is documented in the LAME
distribution.
OpenDriver(L"l3codeca.acm")
GetDriverModuleHandle()
GetProcAddress("DriverProc")
acmDriverAdd(ACM_DRIVERADDF_LOCAL|ACM_DRIVERADDF_FUNCTION)
acmDriverOpen()
acmStreamOpen()
acmStreamSize(ACM_STREAMSIZEF_SOURCE)
acmStreamSize(ACM_STREAMSIZEF_DESTINATION)
acmStreamPrepareHeader()
acmStreamConvert()
acmStreamUnprepareHeader()
acmStreamClose()
acmDriverClose()
acmDriverRemove()
CloseDriver()
The destination format must be (for MPE3, 44100Hz, 128Kbps,
stereo):
#include <mmreg.h>
MPEGLAYER3WAVEFORMAT.wfx.wFormatTag
= WAVE_FORMAT_MPEGLAYER3;
MPEGLAYER3WAVEFORMAT.wfx.nChannels
= 2;
MPEGLAYER3WAVEFORMAT.wfx.nSamplesPerSec
= 44100;
MPEGLAYER3WAVEFORMAT.wfx.nAvgBytesPerSec
= 16000;
MPEGLAYER3WAVEFORMAT.wfx.nBlockAlign
= 1;
MPEGLAYER3WAVEFORMAT.wfx.wBitsPerSample
= 0;
MPEGLAYER3WAVEFORMAT.wfx.cbSize
= MPEGLAYER3_WFX_EXTRA_BYTES;
MPEGLAYER3WAVEFORMAT.wID
= MPEGLAYER3_ID_MPEG;
MPEGLAYER3WAVEFORMAT.fdwFlags
= MPEGLAYER3_FLAG_PADDING_OFF;
MPEGLAYER3WAVEFORMAT.nBlockSize
= 417;
MPEGLAYER3WAVEFORMAT.nFramesPerBlock
= 1;
MPEGLAYER3WAVEFORMAT.nCodecDelay
= 1393;
nBlockSize is the actual MP3 frame_size * nFramesPerBlock.
The frame_size can be calculated from nSamplesPerSec and
nAvgBytesPerSec using the MP3 header tables and a simple
expression.
nAvgBytesPerSec is bitrate_in_Kbps * 1000 / 8.
nCodecDelay is a "magic" value used by the l3codeca.acm
codec while LAME uses 0.
The best way to fill your MPEGLAYER3WAVEFORMAT is to use
acmFormatEnum(ACM_FORMATENUMF_WFORMATTAG)
with
MPEGLAYER3WAVEFORMAT l3wfx = {
{ WAVE_FORMAT_MPEGLAYER3, },
};
ACMFORMATDETAILS afd = {
sizeof(ACMFORMATDETAILS),
0,
WAVE_FORMAT_MPEGLAYER3,
NOTHING,
(LPWAVEFORMATEX)&l3wfx,
sizeof(l3wfx),
};
and match the first ACMFORMATDETAILS that contains a
MPEGLAYER3WAVEFORMAT matching yoir sample rate, bit rate and
channel count.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net