public override MidiMessage HandleInput(MidiMessage msg, MidiRouter router) { if (msg.MessageType == MidiMessageType.NoteOn) { //note ON #warning workround! System.Threading.Thread.Sleep (50); if (Value == true) { #warning Default is NoteOff! msg.MessageType = MidiMessageType.NoteOn; msg.NoteVelocity = 0; //workaround //msg = this.InitControl (); } } else { //note OFF msg = null; } /*if(msg != null) Console.WriteLine (">: " + msg); */ return msg; }
public override MidiMessage HandleOutput(MidiMessage msg, MidiRouter router) { //Green (Orange = + 36) msg.NoteNumber = this.NoteNumber; msg.MessageType = MidiMessageType.NoteOn; msg.NoteVelocity = 127; return msg; }
public static MidiMessage FilterMessages(MidiMessage msg) { //Pitch up bottom buttons if ((msg.MessageType == MidiMessageType.NoteOn || msg.MessageType == MidiMessageType.NoteOff) && (msg.NoteNumber >= 12 && msg.NoteNumber <= 15)) { msg.NoteNumber += 44; } return msg; }
public override MidiMessage HandleInput(MidiMessage msg, MidiRouter router) { System.Threading.Thread.Sleep (200); if (msg.NoteVelocity == 1) { //right msg.NoteNumber += this.IncRange; msg.NoteVelocity = 127; } return msg; }
public override MidiMessage HandleInput(MidiMessage msg, MidiRouter router) { if(msg.MessageType == MidiMessageType.NoteOn) if (!worker.IsBusy) worker.RunWorkerAsync (router); if (msg.MessageType == MidiMessageType.NoteOff) running = false; return null; }
void ValidateBackwardMidiData(MidiMessage msg) { //search msg in controls var matchedControl = controls.SingleOrDefault (c => c.MidiChannel == msg.MidiChannel && c.NoteNumber == msg.NoteNumber); //handle event if (matchedControl != null) { msg = matchedControl.HandleOutput (msg, router); } if (msg != null) { router.TransmitMidiData (router.Endpoint1, msg); } }
void ValidateMidiData(MidiMessage msg) { //search msg in controls var matchedControl = controls.SingleOrDefault (c => c.MidiChannel == msg.MidiChannel && c.NoteNumber == msg.NoteNumber); //handle event if (matchedControl != null) { msg = matchedControl.HandleInput (msg); } if (msg != null) { client.SendMidiMessage (msg); } }
public override MidiMessage HandleOutput(MidiMessage msg, MidiRouter router) { if (msg.MessageType == MidiMessageType.NoteOn) { this.Value = true; //Green (Orange = + 36 RED = + 72) msg.NoteNumber = this.NoteNumber + 72; msg.MessageType = MidiMessageType.NoteOn; msg.NoteVelocity = 127; } else { this.Value = false; //Red msg.MessageType = MidiMessageType.NoteOn; msg.NoteNumber = this.NoteNumber + 36; msg.NoteVelocity = 127; } return msg; }
public void TransmitMidiData(MidiEndpoint endpoint, MidiMessage msg) { var packages = new MidiPacket[] { msg.ToMidiPacket () }; outputPort.Send (endpoint, packages); }
void HandleMessageReceived(MidiDataReceivedEventHandler eventHandler, MidiPacketsEventArgs e) { foreach (MidiPacket mPacket in e.Packets) { var midiData = new byte[mPacket.Length]; Marshal.Copy (mPacket.Bytes, midiData, 0, mPacket.Length); MidiMessage message = new MidiMessage (); message.ParseRawData (midiData); message.TimeStamp = mPacket.TimeStamp; //rais event if (eventHandler != null) { eventHandler (this, new MidiDataReceivedEventArgs (message)); } } }
public override MidiMessage HandleInput(MidiMessage msg, MidiRouter router) { return msg; }
public MidiDataReceivedEventArgs(MidiMessage Data) { this.Data = Data; }
public void SendMidiMessage(MidiMessage msg) { var packages = new MidiPacket[] { msg.ToMidiPacket () }; //endpoint.Received (packages); this.outputPort.Send (endpoint, packages); }
void HandleMessageReceived(object sender, MidiPacketsEventArgs e) { foreach (MidiPacket mPacket in e.Packets) { var midiData = new byte[mPacket.Length]; Marshal.Copy (mPacket.Bytes, midiData, 0, mPacket.Length); MidiMessage message = new MidiMessage (); message.ParseRawData (midiData); message.TimeStamp = mPacket.TimeStamp; //Console.WriteLine("type: {0} channel: {1} note: {2} velocity: {3}", message.MessageType.ToString(), message.MidiChannel, message.NoteNumber, message.NoteVelocity); //rais event if (MidiDataReceived != null) { MidiDataReceived (this, new MidiDataReceivedEventArgs (message)); } } }