1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
unit umain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
mmsystem;
type
{ TMain }
TMain = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Main: TMain;
implementation
{$R *.lfm}
{ TMain }
procedure TMain.Button1Click(Sender: TObject);
var
phwi : LPHWAVEIN;
pwfx : WAVEFORMATEX;
res : MMRESULT;
begin
// Paramètres d'un en-tête de fichier WAV au format PCM : 44100Hz, 8 bits, mono
with pwfx do
begin
wFormatTag := WAVE_FORMAT_PCM;
nChannels := 1;
nSamplesPerSec := 44100;
nAvgBytesPerSec := nSamplesPerSec * nBlockAlign;
nBlockAlign := (nChannels * wBitsPerSample) div 8;
wBitsPerSample := 8;
cbSize := 0;
end;
res := waveInOpen(@phwi, WAVE_MAPPER, @pwfx, Main.Handle, 0, CALLBACK_WINDOW);
if res = MMSYSERR_NOERROR then
begin
end
else
begin
case res of
MMSYSERR_ALLOCATED: ShowMessage('Specified resource is already allocated.');
MMSYSERR_BADDEVICEID: ShowMessage('Specified device identifier is out of range.');
MMSYSERR_NODRIVER: ShowMessage('No device driver is present.');
MMSYSERR_NOMEM: ShowMessage('Unable to allocate or lock memory.');
WAVERR_BADFORMAT: ShowMessage('Attempted to open with an unsupported waveform-audio format.');
else ShowMessage('Unknow error.');
end;
end;
end;
end. |
Partager