0

I'm trying to figure out how to make a simple Winform app that sends a SysEx MIDI message when I click a button, so button 1 sends:-

F0 7F 22 02 50 01 31 00 31 00 31 F7

Button 2 sends:

F0 7F 22 02 50 01 32 00 31 00 31 F7

and so on...

I was able to find lots of info about sending notes and instrument data but nothing really about sysex. I have played with the Sanford reference which seemed to get me closer but still nothing about Sysex usage.

Vega
  • 27,856
  • 27
  • 95
  • 103
Simon Wait
  • 65
  • 1
  • 4

1 Answers1

2

There are various MIDI libraries available, and most support SysEx in one form or another. I've mostly used the managed-midi package although I've used the Sanford package before.

In managed-midi at least, sending a SysEx message is as simple as obtaining an IMidiOutput (usually from a MidiAccessManager) and then calling the Send method. For example:

// You'd do this part just once, of course...
var accessManager = MidiAccessManager.Default;
var portId = access.Outputs.First().Id;
var port = await access.OpenOutputAsync(portId);

// You'd port this part in your button click handler.
// The data is copied from the question, so I'm assuming it's okay...
var message = new byte[] {
    0xF0, 0x7F, 0x22, 0x02, 0x50, 0x01,
    0x31, 0x00, 0x31, 0x00, 0x31, 0xF7 };

port.Send(message, 0, message.Length, timestamp: 0);
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194