This project has moved and is read-only. For the latest updates, please go here.

SysEx message

Mar 13, 2013 at 11:04 PM
I'm looking to send a simple SysEx message that is just 6 bytes long. In the Sample SysEx utility, all the SysEx messages are put in a stream and then sent to the MidiOutPort.LongData method. Is there any plan to overload LongData so it will accept either a stream (as it is now), or a non-stream (i.e. medium size) message?

Mar 14, 2013 at 7:50 AM
Hi Jake,

The MidiBufferStream object that SendLong takes also represents the structure that is needed at Win32 level (MIDIHDR and buffer in unmanaged memory). These buffers also need to be registered to the MidiPort. That is taken care of by the MidiBufferManager(s). I deliberately designed the MidiBufferStream as it is for optimization (The MidiBufferManager allocates continuous blocks of unmanaged memory to which the MidiBufferStreams are attached).

I understand that it might seem like overhead/overkill for small messages but I feel that its the best design for now - so no, no plans to change that.

Use the BinaryWriter (System.IO) to write your bytes into the MidiBufferStream.

Hope it helps.
Mar 15, 2013 at 1:44 AM
OK - I looked at your SysEx sample and figured out the minimum that had to be done.
This code appears to work now:
        ' Send a long message
        mSysEx = New MidiSysExMessage({&HF0, &H43, &H73, &H1, &H3, &HF7})
        mpOut.BufferManager.Initialize(1, 1024)         ' 1 buffer of 1024 bytes
        Dim midiBuffer As MidiBufferStream = mpOut.BufferManager.RetrieveBuffer
        midiBuffer.Write(mSysEx.GetData, 0, mSysEx.ByteLength)

p.s. did you see my bug report?
Mar 15, 2013 at 7:24 AM
Edited Mar 15, 2013 at 7:27 AM
That looks about right. Note that you call BufferManager.Initialize only once.

If you don't want the 'overhead' of using Midi Message classes you could directly write the sysex bytes into the MidiBufferStream (optionally using a BinaryWriter).

Yeah, I saw your bug report. Hope to work on it this weekend. Thanx.
Mar 16, 2013 at 8:26 AM
Edited Mar 16, 2013 at 8:26 AM
Jake, I just checked in a fix for the MidiNoteName bug.

Hope it works for you.