可以不用Delphi的控件录音么???(50分)

  • 主题发起人 主题发起人 nutria
  • 开始时间 开始时间
N

nutria

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,可不可以在Delphi中不用Mediaplayer控件而实现录音呢??

请教,如何实现呢??
 
可以录音!

你拖这个控件下来试试就知道了
而且它都封装好了,实现简单的功能是没有问题的!
 
如果不用Delphi的控件怎么录音呢??

谁知道??
 
可以找很多的第三方小控件,

也可以自己用 MM API函数来写,不是很复杂的
 
谁能给个具体点的例子??

先多谢了!
 
用WindowsAPI写是很麻烦的事

这个MediaPlayer控件还用例子?

拖下来你就知道了!
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,mmsystem, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button4: TButton;
SaveDialog1: TSaveDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin

mciSendString('close p1',0,0,0);
mciSendStringA('open new type WAVEAudio alias p1',0,0,0);
mciSendString('record p1',0,0,0);
end;


procedure TForm1.Button2Click(Sender: TObject);
begin

mciSendString('stop p1',0,0,0);
end;


procedure TForm1.Button3Click(Sender: TObject);
begin

mciSendString('play p1',0,0,0);
end;


procedure TForm1.Button4Click(Sender: TObject);
var s:string;
begin

if SaveDialog1.Execute then

s:='save p1 '+SaveDialog1.filename;
mciSendString(pchar(s),0,0,0);
end;


end.
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MMSystem, StdCtrls, ExtCtrls, ComCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
ProgressBar1: TProgressBar;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
hWavIn: THandle;
wavHdr: TWaveHdr;
IsRecording: Boolean;
buff: String;
end;


var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
tf: TWaveFormatEx;
r, n: Cardinal;
begin

tf.wFormatTag := WAVE_FORMAT_PCM;
tf.nChannels := 1;
tf.nSamplesPerSec := 22000;
tf.wBitsPerSample := 16;
tf.nAvgBytesPerSec := 22000 * 16 div 8;
tf.nBlockAlign := 2;
tf.cbSize := 0;
r := waveInOpen(@hWavIn, WAVE_MAPPER, @tf, 0, 0, 0);
if r = MMSYSERR_NOERROR then

begin

//ShowMessage('ok');
wavHdr.dwFlags := 0;
SetLength(buff, 500*1000);
wavHdr.lpData := PChar(buff);
wavHdr.dwBufferLength := Length(buff);
n := waveInPrepareHeader(hWavIn, @wavHdr, SizeOf(wavHdr));
if n = MMSYSERR_NOERROR then

begin

n := waveInAddBuffer(hWavIn, @wavHdr, SizeOf(wavHdr));
if n = MMSYSERR_NOERROR then

begin

n := waveInStart(hWavIn);
if n = MMSYSERR_NOERROR then

begin

IsRecording := True;
end
else

ShowMessage('start error');
end
else

ShowMessage('prepare error');
end
else

ShowMessage('prepare error');
end
else

ShowMessage('error');
// if r = MMSYSERR_NOERROR then

// waveInClose(hWavIn);
Button1.Enabled := False;
end;


procedure TForm1.Timer1Timer(Sender: TObject);
var
mm: TMMTime;
begin

if IsRecording then

begin

if (wavHdr.dwFlags and WHDR_DONE) <> 0 then

begin

IsRecording := False;
Button1.Enabled := True;
if hWavIn <> 0 then

begin

waveInReset(hWavIn);
waveInClose(hWavIn);
hWavIn := 0;
end;

end
else

begin

waveInGetPosition(hWavIn, @mm, SizeOf(mm));
ProgressBar1.Max := 500;
ProgressBar1.Position := mm.cb div 1000;
end;

end;

end;


end.

 
你到 www.torry.net 上面去找找吧,肯定有不少,
还有一些外国的控件大站,像 Delphi32,DelphiCity.net 等等
www.vclcomponents.com
www.appcontrols.com
www.programmersheaven.com
 
playicq上面也有多媒体的组件包
 
用ACM控件。
 
Example for sound-Input using mmsystem.pas file.
http://www.torry.net/samples/samples/graphics/wavein.zip
http://www.carlosb.com/downloads/waveio.zip
http://www.delphispirit.com/files/vcl/mmedia/audio/acm.zip
http://www.delphispirit.com/files/vcl/mmedia/audio/audio.zip
http://www.delphispirit.com/files/vcl/mmedia/audio/taudioio.zip
 
http://www.torry.net/audio.htm
 
用WIN API啊~~
 
不是有现成的东西可以用吗
 
多人接受答案了。
 
后退
顶部