Search code examples
delphimididelphi-2006

MIDIYOKE in Delphi 2006


I am working with application in delphi. I need to use MIDIYOKE to send output from my application to another application. The second application is Virtual piano keyboard.

enter image description here

I installed all the packages and got MIDI components in the delphi.

I tried using MidiOutputPort1 and MidiInput1 components. I tried playing one MIDI.The code is as follows:

procedure TForm3.Button1Click(Sender: TObject);
var
outputPort : TMidiOutputPort;
begin
 outputPort := TMidiOutputPort.Create (Nil);
   try
    outputPort.PortId := -1;
    outputPort.Active := True;
    outputPort.PatchChange(0, 127, 0); // Gunshot
    outputPort.NoteOn (1, 20, 127);    // Play note at full volume


    Sleep (1000);
    outputPort.NoteOff (0, 60, 0);
finally
outputPort.Free
end
end;

I wanted to estalish connection between my application and Virtual piano keyboard.How to use MidiOutputPort1 and MidiInput1 for the connection between the two.


Solution

  • If both applications support MIDI sync you can use MIDI syncing. In that case MIDIYOKE is the master and Vpk is the slave. Syncing is handled by the following commands:

    mc_MIDI_Timing_Clock           = $F8;
    mc_MIDI_Start                  = $FA;
    mc_MIDI_Continue               = $FB;
    mc_MIDI_Stop                   = $FC;
    

    I used it in the far past, so my knowledge is a bit rusty. What I can gather from my code is that it works as follows: Set the slave in the slave/sync receive/whatever it's called mode. Next send $FA to the channel of your choice. Some (not all) slaves require you to listen to specific channels.

    At each clock tick send $F8 first. Next send the messages, preceded by the $FB message (both data bytes zero). When you're ready send $FC.