📄 audiodev.pas
字号:
unit AudioDev;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, AMIWAVELib_TLB, reg;
type
TFormAudioDevices = class(TForm)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
ComboWaveOutputDevice: TComboBox;
ComboWaveInputDevice: TComboBox;
CommandOutCaps: TButton;
CommandInCaps: TButton;
CommandOk: TButton;
procedure FormCreate(Sender: TObject);
procedure CommandOkClick(Sender: TObject);
procedure ComboWaveOutputDeviceChange(Sender: TObject);
procedure ComboWaveInputDeviceChange(Sender: TObject);
procedure CommandOutCapsClick(Sender: TObject);
procedure CommandInCapsClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function Iif(expr1:integer; expr2:integer; truepart:string; falsepart:string):string;
const
AppName='Am Sound Recorder';
var
FormAudioDevices: TFormAudioDevices;
implementation
uses Main;
{$R *.dfm}
procedure TFormAudioDevices.FormCreate(Sender: TObject);
var i:integer;
begin
//Enumerate wave output devices
ComboWaveOutputDevice.Text := 'Select Play Device';
for i := 0 to FormamSoundRecorder.amWavePro1.WaveOutNumDevs - 1 do
ComboWaveOutputDevice.AddItem(FormamSoundRecorder.amWavePro1.WaveOutGetName(i),self);
//Get saved wave out ID from registry
i := GetSetting(AppName, 'Settings', 'Wave Output ID', -1);
if not(i = -1) then ComboWaveOutputDevice.ItemIndex := i;
//Enumerate wave input devices
ComboWaveInputDevice.Text := 'Select Record Device';
for i := 0 to FormamSoundRecorder.amWavePro1.WaveInNumDevs - 1 do
ComboWaveInputDevice.AddItem(FormamSoundRecorder.amWavePro1.WaveInGetName(i),self);
//Get saved wave in ID from registry
i := GetSetting(AppName, 'Settings', 'Wave Input ID', -1);
if not(i = -1) then ComboWaveInputDevice.ItemIndex := i;
end;
procedure TFormAudioDevices.CommandOkClick(Sender: TObject);
begin
Self.Close;
end;
procedure TFormAudioDevices.ComboWaveOutputDeviceChange(Sender: TObject);
begin
//Save in the registry the wave output device ID
SaveSetting(AppName, 'Settings', 'Wave Output ID', ComboWaveOutputDevice.ItemIndex);
end;
procedure TFormAudioDevices.ComboWaveInputDeviceChange(Sender: TObject);
begin
//Save in the registry the wave input device ID
SaveSetting(AppName, 'Settings', 'Wave Input ID', ComboWaveOutputDevice.ItemIndex);
end;
procedure TFormAudioDevices.CommandOutCapsClick(Sender: TObject);
var strCaps : String;
Caps : integer;
begin
//Display the capabilities of the wave output device for the seclected device
Caps := FormamSoundRecorder.amWavePro1.WaveInGetCaps(ComboWaveInputDevice.ItemIndex);
strCaps := 'Natively supported play formats:' + #13#10;
strCaps := strCaps + '8kHz, 8 Bit ' + #9 + #9 + IIf(Caps , am8000Hz8bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '8kHz, 16 Bit ' + #9 + #9 + IIf(Caps , am8000Hz16bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '11.25kHz, 8 Bit ' + #9 + #9 + IIf(Caps , am11025Hz8bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '11.25kHz, 16 Bit ' + #9 + IIf(Caps , am11025Hz16bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '22.05kHz, 8 Bit ' + #9 + #9 + IIf(Caps , am2205Hz8bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '22.05kHz, 16 Bit ' + #9 + IIf(Caps , am2205Hz16bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '44.1kHz, 8 Bit ' + #9 + #9 + IIf(Caps , am44100Hz8bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '44.1kHz, 16 Bit ' + #9 + #9 + IIf(Caps , am44100Hz16bit, 'Yes', 'No') + #13#10;
Showmessage('Wave Output Capabilities' + #13#10 + strCaps);
end;
function Iif(expr1:integer; expr2:integer; truepart:string; falsepart:string):string;
begin
if ((expr1 and expr2)>0) then result:=truepart else result:=falsepart;
end;
procedure TFormAudioDevices.CommandInCapsClick(Sender: TObject);
var strCaps : String;
Caps : integer;
begin
//Display the capabilities of the wave output device for the seclected device
Caps := FormamSoundRecorder.amWavePro1.WaveInGetCaps(ComboWaveInputDevice.ItemIndex);
strCaps := 'Natively supported record formats:' + #13#10;
strCaps := strCaps + '8kHz, 8 Bit ' + #9 + #9 + IIf(Caps , am8000Hz8bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '8kHz, 16 Bit ' + #9 + #9 + IIf(Caps , am8000Hz16bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '11.25kHz, 8 Bit ' + #9 + #9 + IIf(Caps , am11025Hz8bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '11.25kHz, 16 Bit ' + #9 + IIf(Caps , am11025Hz16bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '22.05kHz, 8 Bit ' + #9 + #9 + IIf(Caps , am2205Hz8bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '22.05kHz, 16 Bit ' + #9 + IIf(Caps , am2205Hz16bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '44.1kHz, 8 Bit ' + #9 + #9 + IIf(Caps , am44100Hz8bit, 'Yes', 'No') + #13#10;
strCaps := strCaps + '44.1kHz, 16 Bit ' + #9 + #9 + IIf(Caps , am44100Hz16bit, 'Yes', 'No') + #13#10;
Showmessage('Wave Input Capabilities' + #13#10 + strCaps);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -