Jump to content
mike_vio

[Delphi] - captura sunete de la microfon.

Recommended Posts

Cerea cineva pe forum un program dinasta, m-am gandit ca e folositor si pentru altii.


unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button3: TButton;
Timer1: TTimer;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button3Click(Sender: TObject);
begin
// iesirea din program
Application.Terminate;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
//porneste captura
timer1.Enabled:=True;
mciSendString('OPEN NEW TYPE WAVEAUDIO ALIAS MicSound', nil, 0, Handle);
mciSendString('SET MicSound TIME FORMAT MS ' + // set the time format

'BITSPERSAMPLE 8 ' + // 8 Bit
'CHANNELS 1 ' + // MONO
'SAMPLESPERSEC 8000 ' + // 8 KHz
'BYTESPERSEC 8000', // 8000 Bytes/s
nil, 0, Handle);

mciSendString('RECORD MicSound', nil, 0, Handle);


end;

procedure TForm1.Button2Click(Sender: TObject);
begin
//opreste captura si salveaza fisierul FileName.wav in calea unde e si programul

timer1.Enabled:=false;
mciSendString('STOP MicSound', nil, 0, Handle);
mciSendString(PChar('SAVE MicSound ' + ExtractFilePath(Application.ExeName)+'FileName.wav'), nil, 0, Handle);
mciSendString('CLOSE MicSound', nil, 0, Handle);

end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
// arata cate secunde se inregistreaza
Label2.Caption:=IntToStr(StrToInt(Label2.caption)+1);
end;

end.

deci o forma cu 3 butoane, start + stop + iesire

un timer care numara secundele

o eticheta care arata tipul scurs.

Daca se doreste modul "stealth" se poate renunta la butoane, etichete, iar

form1.show:=false

  • Upvote 2
  • Downvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...