예제 #1
0
        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;
        }
예제 #2
0
 public override MidiMessage HandleOutput(MidiMessage msg, MidiRouter router)
 {
     //Green (Orange = + 36)
     msg.NoteNumber = this.NoteNumber;
     msg.MessageType = MidiMessageType.NoteOn;
     msg.NoteVelocity = 127;
     return msg;
 }
예제 #3
0
파일: Xone.cs 프로젝트: cansik/midimodifier
        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;
        }
예제 #4
0
 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;
 }
예제 #5
0
        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;
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        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;
        }
예제 #9
0
 public void TransmitMidiData(MidiEndpoint endpoint, MidiMessage msg)
 {
     var packages = new MidiPacket[] { msg.ToMidiPacket () };
     outputPort.Send (endpoint, packages);
 }
예제 #10
0
        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));
                }
            }
        }
예제 #11
0
 public override MidiMessage HandleInput(MidiMessage msg, MidiRouter router)
 {
     return msg;
 }
 public MidiDataReceivedEventArgs(MidiMessage Data)
 {
     this.Data = Data;
 }
예제 #13
0
 public void SendMidiMessage(MidiMessage msg)
 {
     var packages = new MidiPacket[] { msg.ToMidiPacket () };
     //endpoint.Received (packages);
     this.outputPort.Send (endpoint, packages);
 }
예제 #14
0
        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));
                }
            }
        }