采样率等参数设好了吗?
问题: 高手何在?请教如何录音成mp3 ( 积分: 200 )
分类: 控件 - 开发
来自: chensunear, 时间: 2005-02-24 11:44:00, ID: 2995760
请教高手我想用mmtools控件录音成mp3。如果你知道别的方法也行如利用lame_enc.dll实现也可以,总之能录音成mp3格式即可当然是用delphi程序实现。请高手赐教,大富翁不会没有高手吧?
来自: mianbaosoft, 时间: 2005-02-24 15:31:47, ID: 2996205
没有用过,自己多试试,多搜索一下
来自: app2001, 时间: 2005-02-24 15:36:22, ID: 2996210
http://www.delphibbs.com/keylife/iblog_show.asp?xid=2022
作者?: journer
标题?: 公开对MP3的研究结果
关键字:
分类?: 项目案例分析
密级?: 公开
(评分:★★★ , 回复: 4, 阅读: 433) »»
1、MP3帧格式
2、ID3标签
3、MP3解码
4、MP3编码
5、MP3播放器硬件
6、MP3播放器软件
你看这个资料对你有没有帮助吧??
来自: chensunear, 时间: 2005-02-24 17:39:15, ID: 2996484
谢谢你们的关注,只是泛泛而谈不能解决实际问题
来自: dawnsong, 时间: 2005-02-24 18:37:10, ID: 2996566
参考高手的例子
http://www.vclxx.org/DELPHI/D32FREE/BLADEENC.ZIP
以下内容引自该例
unit Example;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, Gauges, StdCtrls;
type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
BitBtn1: TBitBtn;
Gauge1: TGauge;
BitBtn2: TBitBtn;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDblClick(Sender: TObject);
private
{ Private declarations }
RawFileName,
Mp3FileName : String;
public
{ Public declarations }
end;
var
Form1: TForm1;
const
FormCap = 'Blade Encoder shell (Bladeenc.dll v.0.82)';
implementation
{$R *.DFM}
uses bladedll;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
if openDialog1.Execute then
begin
SpeedButton1.Caption := OpenDialog1.Filename;
RawFileName := OpenDialog1.Filename;
end;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
var
TmpStr : String;
begin
if RawFileName <> '' then
begin
TmpStr := RawFileName;
Delete(TmpStr,Pos(ExtractFileExt(RawFileName),RawFileName),Length(RawFileName));
SaveDialog1.FileName := TmpStr+'.mp3';
end;
if SaveDialog1.Execute then
begin
SaveDialog1.DefaultExt := '.mp3';
SpeedButton2.Caption := SaveDialog1.Filename;
Mp3FileName := SaveDialog1.FileName;
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
BladeHandle : THbeStream;
beConfig : TBeConfig;
NumSamples,
mp3bufferSize : DWORD;
Err : TBeErr;
Mp3Buffer,
rawBuffer : pointer;
Mp3File,
RawFile : TFileStream;
FileLength,
do
ne,
dwWrite,
toread,
isread,
toWrite,
IsWritten : DWORD;
procedure CleanUp;
begin
beCloseStream(BladeHandle);
RawFile.Free;
Mp3File.Free;
FreeMem(Mp3Buffer);
FreeMem(RawBuffer);
end;
begin
RawBuffer := nil;
Mp3Buffer := nil;
if RawFileName = '' then
begin
SpeedButton1Click(Sender);
if RawFileName = '' then
exit;
end;
if Mp3FileName = '' then
begin
SpeedButton2Click(Sender);
if Mp3FileName = '' then
exit;
end;
RawFile := TFileStream.Create(RawFileName,fmOpenRead);
mp3File := TFileStream.Create(Mp3FileName,fmCreate or fmShareDenyNone);
FillChar(BeConfig,SizeOf(BeConfig),#0);
With BeConfig.Formatdo
begin
dwConfig := BE_CONFIG_MP3;
mp3.dwSampleRate := 44100;
mp3.byMode := BE_MP3_MODE_STEREO;
mp3.wBitrate := 128;
mp3.bPrivate := False;
mp3.bCRC := False;
mp3.bCopyright := False;
mp3.bOriginal := False;
end;
Err := BeInitStream(BeConfig, NumSamples, Mp3BufferSize, BladeHandle);
if Err <> BE_ERR_SUCCESSFUL then
begin
MessageDlg('Error opening encoding stream '+IntToStr(Err),MtError,[MbOk],0);
Exit;
end;
GetMem(Mp3Buffer,mp3BufferSize);
GetMem(RawBuffer,NumSamples);
FileLength := RawFile.Size;
do
ne := 0;
Gauge1.MinValue := 0;
Gauge1.MaxValue := FileLength;
whiledo
ne <> FileLengthdo
begin
if (done + (NumSamples * 2) < FileLength) then
toRead := NumSamples * 2
else
toRead := Filelength -do
ne;
isread := RawFile.Read(Rawbuffer^,ToRead);
if IsRead <> ToRead then
begin
Messagedlg('Read Error',MtError,[MbOk],0);
Cleanup;
Exit;
end;
Err := beEncodeChunk(BladeHandle,(Toread div 2), RawBuffer, mp3Buffer, toWrite);
if Err <> BE_ERR_SUCCESSFUL then
begin
MessageDlg('beEncodeChunk failed '+IntToStr(Err),mtError,[MbOk],0);
CleanUp;
Exit;
end;
IsWritten := mp3File.Write(mp3buffer^,ToWrite);
if ToWrite <> isWritten then
begin
Messagedlg('Write Error',MtError,[MbOk],0);
Cleanup;
Exit;
end;
do
ne :=do
ne + ToRead;
Gauge1.AddProgress(ToRead);
Application.processMessages;
end;
Err := beDeinitStream(BladeHandle, mp3Buffer, dwWrite);
if Err <> BE_ERR_SUCCESSFUL then
begin
MessageDlg('beExitStream failed '+intToStr(Err),mtError,[MbOk],0);
Cleanup;
Exit;
end;
isWritten := mp3File.Write(mp3Buffer^,dwWrite);
if dwWrite <> isWritten then
begin
MessageDlg('Write error',MtError,[MbOk],0);
CleanUp;
exit;
end;
CleanUp;
Messagedlg('Done',Mtinformation,[Mbok],0);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
RawFileName := '';
mp3FileName := '';
Form1.Caption := formCap;
end;
procedure TForm1.FormDblClick(Sender: TObject);
var
Version : TBeVersion;
begin
beVersion(Version);
ShowMessage(
'BladeEnc DLL version : '+IntToStr(Version.byDLLMajorVersion)+'.'+IntToStr(Version.byDLLMinorVersion)+#13+
'BladeEnc version : '+IntToStr(Version.byMajorVersion)+'.'+IntToStr(Version.byMinorVersion)+#13+
'BladeEnc date : '+IntToStr(Version.byDay)+'-'+IntToStr(Version.byMonth)+'/'+IntToStr(Version.wYear)+#13+
'BladeEnc Homepage : '+Version.zHomepage);
end;
end.
unit bladedll;
(*
Bladedll.h
+++++++++++++++++++++++++++
+ Blade's Encoder DLL +
+++++++++++++++++++++++++++
------------------------------------------------------
- Version 1.00 (7 November 1998) - Jukka Poikolainen -
------------------------------------------------------
Initial version
------------------------------------------------------
- Version x.xx (x xxxxxxxx xxxx) - xxxxx xxxxxxxxxxx -
------------------------------------------------------
Delphi Version (D3 and D4).
Jack Kallestrup (jack.kallestrup@vip.cybercity.dk)
thanks to Leif Lundberg for helping with the calling convension.
Changes :
Calling convention changed from stdcall to cdecl.
Added TFormat record
*)
interface
uses windows;
//type definitions
const
// encoding formats
BE_CONFIG_MP3 = 0;
BE_CONFIG_ACC = 1;
type
// type definitions
THBeStream = ULONG;
PHBeStream = ^THBEStream;
TBeErr = ULONG;
PSHORT = ^SHORT;
PBYTE = ^Byte;
// error codes
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 = 400000004;
// other constants
BE_MAX_HOMEPAGE = 256;
// format specific variables
BE_MP3_MODE_STEREO = 0;
BE_MP3_MODE_DUALCHANNEL = 2;
BE_MP3_MODE_MONO = 3;
type
PMP3 = ^TMP3;
TMP3 = packed record
dwSampleRate : DWORD;
// 48000, 44100 and 32000 allowed
byMode : Byte;
// BE_MP3_MODE_STEREO, BE_MP3_MODE_DUALCHANNEL, BE_MP3_MODE_MONO
wBitrate : Word;
// 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320 allowed
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_XXXXX
BE_CONFIG_MP3 : (mp3 : TMp3);
BE_CONFIG_ACC : (acc : TAac);
end;
PBEConfig = ^TBEConfig;
TBEConfig = packed record
Format : TFormat;
// Currently only BE_CONFIG_MP3 is supported
end;
PBEVersion = ^TBEVersion;
TBEVersion = packed record
// BladeEnc DLL Version number
byDLLMajorVersion,
byDLLMinorVersion,
// BladeEnc Engine Version Number
byMajorVersion,
byMinorVersion,
// DLL Release date
byDay,
byMonth : Byte;
wYear : Word;
// BladeEnc Homepage URL
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 'BLADEENC.DLL';
(*
pbeConfig = Type of mp3
dwSamples = Maximum number of samples to encode
dwBufferSize = Maximum mp3 buffer size
hbeStream = BladeEnc-stream
*)
function beEncodeChunk(hbeStream : THBEStream;
nSamples : DWORD;
pSamples : PShort;
pOutput : PByte;
var pdwOutput : DWORD) : TBeErr;
cdecl;
external 'BLADEENC.DLL';
(*
hbeStream =
nSamples = Number of samples to encode
pSamples = Pointer to buffer with Samples to encode
pOutput = Pointer to buffer to recieve encoded samples
pdwOutput = number of samples encoded
*)
function beDeinitStream(hbeStream : THBEStream;
pOutput : PByte;
var pdwOutput : DWORD) : TBeErr;
cdecl;
external 'BLADEENC.DLL';
(*
hbeStream =
pOutput = Pointer to buffer holding encoded samples
pdwOutput = Number of samples to write
*)
function beCloseStream(hbeStream : THBEStream) : TBeErr;
cdecl;
external 'BLADEENC.DLL';
procedure beVersion(var pbeVersion : TBEVersion);
cdecl;
external 'BLADEENC.DLL';
implementation
end.
来自: chensunear, 时间: 2005-02-26 15:34:49, ID: 2998364
dawnsong, 你好应用该例子确实可以将录制的wav文件转换为mp3格式但在用procedure TForm1.BitBtn1Click(Sender: TObject);转换中最后内存总是出问题报错语句为最后一句即Messagedlg('Done',Mtinformation,[Mbok],0);如将该句屏蔽则变为上一句,依次往上屏蔽总是最后一句出问题,提示为某地址不可访问,不可读。请你指教,也请知道的各位大虾继续谈论,发言者给分,能最终解决问题者至少给200。
来自: 天真, 时间: 2005-02-26 15:52:37, ID: 2998383
用 directshow很简单德
不过卧现在没找到好德MP3的编解码器
问题讨论没有结束 ...