LAME Encoder Library
LAME Encoder Library is a COM/DLL MP3 encoder component that uses lame_enc.dll for encoding MP3 files for use in Win32 and Win64 (Windows XP/Vista/7/8/10) software.
Encodes WAV/RF64 and audio file formats supported by BASS: WAV/RF64, AIFF, MP3, MP2, MP1, Ogg Vorbis (and formats supported by BASS plugins) and OS supported formats like AAC/MP4, Flac, etc. to MP3 format.
There is an extended version of LAME Encoding Library, called BASS Encoder Library that, additionaly to MP3, ads Opus, FLAC and Ogg Vorbis encoding functionality too.
- Encode various audio file formats into MP3 format
- COM class usable by developer environments/platforms supporting COM classes like VBScript
- Stream encoding interface (send sample data to the component and receive the encoded MP3 data)
- ID3v1, ID3v2, Lyrics3, APEv2, Flac, Ogg Vorbis, Opus, MP4, WAV LIST INFO, BEXT and CART and WMA tags are transfered to output file
- Optionaly specify segment to encode or use silence detection to trim leading and trailing silence
- Normalize the volume to arbitrary amount
- Optional lowpass and highpass filtering
- Supports using the LAMEEncoder.dll itself natively without COM, Delphi and C++ API included
- As no external .exe is started the library is usable for Windows Store apps
Developer environment/platform supporting COM classes or DLLs.
Run an elevated command prompt, change dir into the folder where 'LAMEEncoder.dll' is located, run the following: "regsvr32 LAMEEncoder.dll". This should register the COM class. Do this for the desired Win32 and/or Win64 version.
When using the BASS method bass.dll and bass_fx.dll is needed on the search path, eg. beside your .exe, or copy the needed DLLs to \Windows\System32\ (Win64 DLLs on a 64 bit OS) and/or \Windows\SysWOW64\ (Win32 DLLs on a 64 bit OS) folder. If the OS is 32 bit then copy the needed DLLs to \Windows\System32\ (from the Win32 folder).
To use the library in VBScript, on a 64 bit OS, the VBScript process is 64 bit so the needed DLLs have to be from the Win64 folder, beside the .VBS file or in the System32 folder as written above.
After registering the DLL it can be accessed like:
VBScript usage example, output 320 kbps, 44 100 Hz, 2 channel CBR MP3 audio file:
set myobject = createobject("LAMEEncoder.TLAMEEncodeFile")
myobject.EncodeWAVFile "E:\Test.wav", "E:\Test.mp3", 320, nothing
myobject.EncodeFileWithBASS "E:\Test.wav", "E:\Test.mp3", 320, 44100, 2, 0, 0, 0, 0, nothing
set myobject = nothing
Please see the Delphi tutorials on how to use the library with Delphi.
- function EncodeFileWithBASS (const FileName, OutputFileName: WideString; BitRate: Integer; ResampleSampleRate, Channels: SYSUINT; VBR: Integer; StartPosition, Length, Normalize: Double; const ProgressCallback: IProgress): HResult;
- If 'ResampleSampleRate' is 0 then the source file's sample rate is used. Valid range is 8000 to 48000.
- If 'Channels' is 0 then the source file's channel count is used. Valid value is 1 or 2.
- Set 'VBR' to a non-zero value to enable VBR encoding mode.
- 'StartPosition' and 'Length' are in seconds. Use 0 for all.
- Set 'Normalize' to 1.0 (100%) or specify 0 (don't change).
- 'ProgressCallback' is an interface callback for encoding progress reporting. Set to nil if you don't wish to use a progress callback.
Using LAMEEncoder.dll natively: There are 5 exported functions available:
- function EncodeFileSilenceDetected (const FileName, OutputFileName: WideString; BitRate: Integer; ResampleSampleRate, Channels: SYSUINT; VBR: Integer; MaxSilenceVolume, PrependLength, AppendLength, Normalize: Double; const ProgressCallback: IProgress): HResult; stdcall;
- Same as EncodeFileWithBASS() with 3 different parameters:
- 'MaxSilenceVolume' set to 1.0 for 100%, usualy value is 0.05 - 0.1.
- 'PrependLength' and 'AppendLength' are in seconds, extend the detected segment by this amount.
The first 3 functions can be used to directly call the 3 encoder functions.
- function LAMEEncodeWAVFile(FileName, OutputFileName: PWideChar; BitRate: Integer; ProgressCallback: IProgress): HResult; stdcall;
- function LAMEEncodeFileWithBASS(FileName, OutputFileName: PWideChar; BitRate, ResampleSampleRate, Channels, VBR: Integer; TransferTags: LongBool; StartPosition, Length, Normalize: Double; ProgressCallback: IProgress): HResult; stdcall;
- function LAMEEncodeFileWithBASSSilenceDetected(FileName, OutputFileName: PWideChar; BitRate, ResampleSampleRate, Channels, VBR: Integer; TransferTags: LongBool; MaxSilenceVolume, PrependLength, AppendLength, Normalize: Double; ProgressCallback: IProgress): HResult; stdcall;
- function LAMEEncoderGetFile: ILAMEEncodeFile; stdcall;
- function LAMEEncoderGetStream: ILAMEEncodeStream; stdcall;
The last 2 functions return the interface for the 'ILAMEEncodeFile' and 'ILAMEEncodeStream' classes.
HResult error codes
- S_OK: Success.
- S_FALSE: Unknown error occured or catastrophic failure.
- 2: lame_enc.dll could not be loaded.
- 3: bass.dll could not be loaded.
- 8: bass_fx.dll could not be loaded.
- E_INVALIDARG: Parameters specified are invalid.
LAME Encoder Library in shareware and commercial software?
The component is free for use in free software. If you like it and use it in a shareware or commercial (or any other money making - advertising, in app. selling, etc.) product you need one of the licenses.