unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, mmSystem;type TForm1 = class(TForm) Button1: TButton;
procedure Button1Click(Sender: TObject);
private { Private declarations } public { Public declarations } end;
var Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);var handle: HMIDIOUT;
begin
// Open default MIDI Out device */ if midiOutOpen(@handle, Cardinal(-1), 0, 0, CALLBACK_NULL) =0 then
begin
// Output the C note (ie, sound the note) */ midiOutShortMsg(handle , $00403C90);
// Output the E note */ midiOutShortMsg(handle, $00404090);
// Output the G note */ midiOutShortMsg(handle, $00404390);
// Here you should insert a delay so that you can hear the notes sounding */ Sleep(1000);
// Now let's turn off those 3 notes */ midiOutShortMsg(handle, $00003C90);
midiOutShortMsg(handle, $00004090);
midiOutShortMsg(handle, $00004390);
// Close the MIDI device */ midiOutClose(handle);
end;
end;
end.