MP3 -> WAV -> MP3
MP3 -> WAV посредством mp3dec.dll
(библиотека бесплатная, найти в итнернете не проблема),
вот хэдер для неё:
unit Mp3decDll;
interface
uses Windows;
const
MPGLIB_ERROR = -1;
MPGLIB_OK = 0;
MPGLIB_NEED_MORE = 1;
type
MPGLIB_ERR = integer;
H_STREAM = integer;
var
MpgLib_OpenStream : function(var hStream : H_STREAM) : MPGLIB_ERR;
cdecl;
MpgLib_DecodeChunk : function(hStream : H_STREAM;
pInStream : PBYTE;
nInSize : integer;
pOutStream : PBYTE;
nOutSize : integer;
var pnOutBytes : integer) : MPGLIB_ERR;
cdecl;
MpgLib_CloseStream : function(hStream : H_STREAM) : MPGLIB_ERR;
cdecl;
MpgLib_Version : procedure(lpszVersionString : PChar; nSize : integer);
cdecl;
MpgLib_GetBitRate : function : integer; cdecl;
MpgLib_Flush : function : integer; cdecl;
function RequestDLLLoading: Boolean;
implementation
var
MPGLibDLL : THANDLE = 0;
function RequestDLLLoading: Boolean;
begin
if (MPGLibDLL = 0) then
begin
MPGLibDLL := LoadLibrary('Mp3dec.dll');
if (MPGLibDLL <> 0) then
begin
@MpgLib_OpenStream := GetProcAddress(MPGLibDLL, 'MpgLib_OpenStream');
@MpgLib_DecodeChunk := GetProcAddress(MPGLibDLL, 'MpgLib_DecodeChunk');
@MpgLib_CloseStream := GetProcAddress(MPGLibDLL, 'MpgLib_CloseStream');
@MpgLib_Version := GetProcAddress(MPGLibDLL, 'MpgLib_Version');
@MpgLib_GetBitRate := GetProcAddress(MPGLibDLL, 'MpgLib_GetBitRate');
@MpgLib_Flush := GetProcAddress(MPGLibDLL, 'MpgLib_Flush');
end;
end;
Result := (MPGLibDLL <> 0);
end;
initialization
finalization
if (MPGLibDLL<>0) then FreeLibrary(MPGLibDLL);
end.
WAV -> MP3 Попробуйте lame.dll (библиотека бесплатная, найти в итнернете не проблема),
вот хэдер для неё:
unit Lame_dll;
interface
uses Windows;
const
BE_CONFIG_MP3 = 0;
BE_CONFIG_LAME = 256;
type
THBESTREAM = ULONG;
PHBESTREAM = ^THBESTREAM;
TBEERR = ULONG;
PSHORT = ^SHORT;
PBYTE = ^Byte;
const
BE_ERR_SUCCESSFUL = $00000000;
BE_ERR_INVALID_FORMAT = $00000001;
BE_ERR_INVALID_FORMAT_PARAMETERS = $00000002;
BE_ERR_NO_MORE_HANDLES = $00000003;
BE_ERR_INVALID_HANDLE = $00000004;
BE_ERR_BUFFER_TOO_SMALL = $00000005;
BE_MAX_HOMEPAGE = 256;
BE_MP3_MODE_STEREO = 0;
BE_MP3_MODE_JSTEREO = 1;
BE_MP3_MODE_DUALCHANNEL = 2;
BE_MP3_MODE_MONO = 3;
MPEG1 = 1;
MPEG2 = 0;
type
MPEG_QUALITY = (NORMAL_QUALITY, LOW_QUALITY, HIGH_QUALITY, VOICE_QUALITY);
PLHV1 = ^TLHV1;
TLHV1 = packed record
dwStructVersion : DWORD;
dwStructSize : DWORD;
dwSampleRate : DWORD;
dwReSampleRate : DWORD;
nMode : INTEGER;
dwBitrate : DWORD;
dwMaxBitrate : DWORD;
nQuality : DWORD;
dwMpegVersion : DWORD;
dwPsyModel : DWORD;
dwEmphasis : DWORD;
bPrivate : BOOL;
bCRC : BOOL;
bCopyright : BOOL;
bOriginal : BOOL;
bWriteVBRHeader : BOOL;
bEnableVBR : BOOL;
nVBRQuality : integer;
btReserved : array [1..255] of byte;
end;
PLameMP3 = ^TLameMP3;
TLameMP3 = packed record
dwSampleRate : DWORD;
byMode : Byte;
wBitrate : Word;
bPrivate,
bCRC,
bCopyright,
bOriginal : BOOLean;
end;
PAAC = ^TAAC;
TAAC = packed record
dwSampleRate : DWORD;
byMode : Byte;
wBitrate : Word;
byEncodingMethod : Byte;
end;
PFormat = ^TFormat;
TFormat = packed record
case dwConfig : DWord of
BE_CONFIG_MP3 : (MP3 : TLameMP3);
BE_CONFIG_LAME : (LHV1 : TLHV1);
end;
PBECONFIG = ^TBECONFIG;
TBECONFIG = packed record
Format : TFormat;
end;
PBEVersion = ^TBEVersion;
TBEVersion = packed record
byDLLMajorVersion,
byDLLMinorVersion,
byMajorVersion,
byMinorVersion,
byDay,
byMonth : Byte;
wYear : Word;
zHomepage : Array[0..BE_MAX_HOMEPAGE] of char;
end;
function beInitStream(var pbeConfig : TBEConfig; var dwSamples : DWORD; var dwBufferSize : DWORD; var phbeStream : THBESTREAM) : TBeErr; cdecl; external 'lame.dll';
function beEncodeChunk(hbeStream : THBEStream; nSamples : DWORD; pSamples : PShort; pOutput : PByte; var pdwOutput : DWORD) : TBeErr; cdecl; external 'lame.dll';
function beDeinitStream(hbeStream : THBEStream; pOutput : PByte; var pdwOutput : DWORD) : TBeErr; cdecl; external 'lame.dll';
function beCloseStream(hbeStream : THBEStream) : TBeErr; cdecl; external 'lame.dll';
procedure beVersion(var pbeVersion : TBEVersion); cdecl; external 'lame.dll';
implementation
end.