コード例 #1
0
        static byte [] GetBytes(MidiPacket packet)
        {
            var bytes = new byte [packet.Length];

            Marshal.Copy(packet.Bytes, bytes, 0, packet.Length);
            return(bytes);
        }
コード例 #2
0
 public void Send(byte[] mevent, int offset, int length, long timestamp)
 {
     unsafe
     {
         fixed(byte *ptr = mevent)
         {
             arr [0] = new MidiPacket(timestamp, (ushort)length, (IntPtr)(ptr + offset));
             port.Send(details.Endpoint, arr);
         }
     }
 }
コード例 #3
0
        private void SendBufferInternal(IBuffer midiData, TimeSpan timestamp)
        {
            if (midiData is null)
            {
                throw new ArgumentNullException(nameof(midiData));
            }

            if (_port == null)
            {
                throw new InvalidOperationException("Output port is not initialized.");
            }

            var data = midiData.ToArray();

            var packet  = new MidiPacket(0, data, 0, data.Length);
            var packets = new MidiPacket[] { packet };

            _port.Send(_endpoint, packets);
        }