Esempio n. 1
0
        void SendNote()
        {
            for (int i = 0; i < Midi.DestinationCount; i++)
            {
                var endpoint = MidiEndpoint.GetDestination(i);

                var note = (byte)(rand.Next() % 127);

                // play note
                outputPort.Send(endpoint, new MidiPacket [] { new MidiPacket(0, new byte [] { 0x90, note, 127 }) });
                Thread.Sleep(300);
                // turn it off
                outputPort.Send(endpoint, new MidiPacket [] { new MidiPacket(0, new byte [] { 0x80, note, 0 }) });
            }
        }
Esempio n. 2
0
 public virtual void Send(MidiMessage message)
 {
     if (port != null)
     {
         port.Send(message);
     }
 }
Esempio n. 3
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);
         }
     }
 }
Esempio n. 4
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);
        }
Esempio n. 5
0
        void SendMIDI(byte type, byte channel, byte value)
        {
            for (int i = 0; i < Midi.DestinationCount; i++)
            {
                var endpoint = MidiEndpoint.GetDestination(i);
                outputPort.Send(endpoint, new MidiPacket[] { new MidiPacket(0, new byte[] { type, channel, value }) });
                Debug.WriteLine("Midi Value: " + value + " Sent @ " + DateTime.Now.Millisecond.ToString() + "\r\n");


                //outputPort.Send(endpoint, new MidiPacket[] { new MidiPacket(0, new byte[] { 0xB0, (byte)(myMidiModulation.CCNumber), ccByte }) });

                //var ccVal = (byte)(rand.Next () % 127);
                // play ccVal then turn off after 300 miliseconds

                /*
                 * outputPort.Send (endpoint, new MidiPacket [] { new MidiPacket (0, new byte [] { 0x90, ccVal, 127 }) });
                 * Thread.Sleep (300);
                 * outputPort.Send (endpoint, new MidiPacket [] { new MidiPacket (0, new byte [] { 0x80, ccVal, 0 }) });
                 */
            }
        }