public void Send(MidiEndpoint endpoint, MidiPacket [] arr) { var list = Marshal.AllocHGlobal(Marshal.SizeOf <MidiPacketListNative> ()); try { var p = CoreMidiInterop.MIDIPacketListInit(list); foreach (var item in arr) { p = CoreMidiInterop.MIDIPacketListAdd(list, arr.Length, p, item.TimeStamp, item.Length, item.Bytes); } CoreMidiInterop.MIDISend(Handle, endpoint.Handle, list); } finally { Marshal.FreeHGlobal(list); } }
public void Send(MidiEndpoint endpoint, MidiPacket [] arr) { var msize = Marshal.SizeOf <MIDIPacketNative> (); var size = arr.Select(a => msize + a.Length).Sum(); if (list == IntPtr.Zero || size > buf_size) { if (list != IntPtr.Zero) { Marshal.FreeHGlobal(list); } list = Marshal.AllocHGlobal(buf_size); } var p = CoreMidiInterop.MIDIPacketListInit(list); foreach (var item in arr) { p = CoreMidiInterop.MIDIPacketListAdd(list, 1024, p, item.TimeStamp, item.Length, item.Bytes); } CoreMidiInterop.MIDISend(Handle, endpoint.Handle, list); }
public void ConnectSource(MidiEndpoint endpoint) => CoreMidiInterop.MIDIPortConnectSource(Handle, endpoint.Handle, IntPtr.Zero);
public void Disconnect(MidiEndpoint endpoint) => CoreMidiInterop.MIDIPortDisconnectSource(Handle, endpoint.Handle);