FireMonkey version 2 (FM2) now supports playing and capturing audio files. The following is a simple Delphi XE3 application unit (my form had one TButton on it) that uses the TAudioCaptureDevice to record audio coming in from the default audio input (in my case, the built-in microphone on my notebook computer).
unit AudioUnit;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Media;
type
TForm3 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
MyAudio : TAudioCaptureDevice;
end;
var
Form3: TForm3;
implementation
{$R *.fmx}
procedure TForm3.Button1Click(Sender: TObject);
begin
if Button1.Text = 'Start Audio Capture' then begin
MyAudio := TCaptureDeviceManager.Current.DefaultAudioCaptureDevice;
if MyAudio <> nil then begin
Button1.Text := 'Stop Audio Capture';
MyAudio.FileName := 'TestAudio.mp3';
MyAudio.StartCapture;
end
else
Caption := 'Audio capture devices not available.';
end
else begin
MyAudio.StopCapture;
Button1.Text := 'Start Audio Capture'
end;
end;
end.
It’s so easy! You can get started today - download the free trial or purchase Delphi XE3, C++Builder XE3 or RAD Studio XE3.
{ 1 } Comments
Cool and yes Delphi makes most development tasks easy!
Post a Comment