Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 public void ConnectSource(MidiEndpoint endpoint) => CoreMidiInterop.MIDIPortConnectSource(Handle, endpoint.Handle, IntPtr.Zero);
Exemple #4
0
 public void Disconnect(MidiEndpoint endpoint) => CoreMidiInterop.MIDIPortDisconnectSource(Handle, endpoint.Handle);