捕捉 midi 输入消息的基本程序
uses MMSystem;
var hMidiIn: Integer;
procedure midiCallBack(hdrvr: HDRVR; uMsg: UINT; dwUser: DWORD; dw1, dw2: DWORD) stdcall;
begin
case uMsg of
MIM_OPEN: ;
MIM_CLOSE: ;
MIM_DATA: Form1.Memo1.Lines.Add(IntToStr(dw1));
MIM_LONGDATA: ;
MIM_ERROR: ;
MIM_LONGERROR: ;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
midiInOpen(@hMidiIn, 0, Cardinal(@midiCallBack), 0, CALLBACK_FUNCTION);
midiInStart(hMidiIn);
Caption := IntToStr(hMidiIn);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
midiInStop(hMidiIn);
midiInClose(hMidiIn);
Caption := '0'
end;