internal static unsafe void WriteToJackMidi(this MidiEventCollection <MidiOutEvent> midiEvents, uint nframes) { float *portBuf = PortApi.GetBuffer(midiEvents.Port._port, nframes); MidiApi.ClearBuffer(portBuf); foreach (MidiOutEvent midiEvent in midiEvents) { byte *buffer = MidiApi.ReserveEvent(portBuf, (uint)midiEvent.Time, (uint)midiEvent.MidiData.Length); StructPointer <byte> bufferPointer = new StructPointer <byte> ((IntPtr)buffer, (uint)midiEvent.MidiData.Length); bufferPointer.Array = midiEvent.MidiData; bufferPointer.CopyToPointer(); } }