Пример #1
0
    private void MessageReceived(MidiInMessageEventArgs e)
    {
        ControlChangeEvent cc;

        cc = checked ((ControlChangeEvent)e.MidiEvent);
        lstMIDIEvent.Items.Add(new Config.clsMIDIevent(cc.Channel, (int)cc.Controller, cc.ControllerValue));
    }
Пример #2
0
        private void Midiin_MessageReceived(object sender, MidiInMessageEventArgs e)
        {
            String midimes = e.RawMessage.ToString("X"); String type = ""; int note = 0; int velocity = 0;

            if (midimes != "")
            {
                type = midimes.Substring(midimes.Length - 2);
            }
            while (midimes.Length < 6)
            {
                midimes.Insert(0, "0");
            }
            note     = Convert.ToInt32(midimes.Substring(midimes.Length - 4, 2), 16);
            velocity = note = Convert.ToInt32(midimes.Substring(midimes.Length - 6, 1), 16);
            if (type.Equals("8"))
            {
                this.Invoke(new EventHandler(delegate { richTextBox2.Text = DateTime.Now.ToString().Substring(11, 8) + ", " + note.ToString() + " Note Off, " + velocity.ToString() + '\n' + richTextBox2.Text; }));
            }
            if (type.Equals("9"))
            {
                this.Invoke(new EventHandler(delegate { richTextBox2.Text = DateTime.Now.ToString().Substring(11, 8) + ", " + note.ToString() + " Note On, " + velocity.ToString() + '\n' + richTextBox2.Text; }));
            }
            if (type.Equals("B"))//MessageBox.Show(midimes,"",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
            {
                this.Invoke(new EventHandler(delegate { richTextBox2.Text = DateTime.Now.ToString().Substring(11, 8) + ", CC " + note.ToString() + ", " + velocity.ToString() + '\n' + richTextBox2.Text; }));
            }

            MessageBox.Show(e.RawMessage.ToString());
        }
 private void MidiMessageReceived(object sender, MidiInMessageEventArgs e)
 {
     if (e.MidiEvent is NoteOnEvent noteOnEvent)
     {
         if (bindings.ContainsKey(noteOnEvent.Channel))
         {
             bindings[noteOnEvent.Channel].HandleNoteOn(noteOnEvent.NoteNumber);
         }
     }
     else if (e.MidiEvent is NoteEvent noteEvent)
     {
         if (bindings.ContainsKey(noteEvent.Channel))
         {
             bindings[noteEvent.Channel].HandleNoteOff(noteEvent.NoteNumber);
         }
     }
     else if (e.MidiEvent is ControlChangeEvent controlChange)
     {
         if (bindings.ContainsKey(controlChange.Channel))
         {
             bindings[controlChange.Channel].HandleController((int)controlChange.Controller, controlChange.ControllerValue);
         }
     }
     else
     {
         communication.SendDebugMessage($"Received Midi Message: {e.MidiEvent}");
     }
 }
Пример #4
0
 void midiInput_MessageReceived(object sender, MidiInMessageEventArgs e)
 {
     midiInLogLB.Invoke((Action) delegate
     {
         logList.Add(String.Format("Time {0} Message 0x{1:X8} Event {2}", e.Timestamp, e.RawMessage, e.MidiEvent));
     });
 }
Пример #5
0
        void midiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
        {
            Console.WriteLine(String.Format("Time {0} Message 0x{1:X8} Event {2}", e.Timestamp, e.RawMessage, e.MidiEvent));

            Byte first  = Convert.ToByte((e.RawMessage >> 8) & 0xFF);
            Byte second = Convert.ToByte((e.RawMessage >> 16) & 0xFF);

            switch (e.MidiEvent.CommandCode)
            {
            case MidiCommandCode.ControlChange:
                CC[first].Dispatch(second);
                break;

            case MidiCommandCode.NoteOn:
                Note[first].Dispatch(second);
                break;

            case MidiCommandCode.NoteOff:
                Note[first].Dispatch(0);
                break;

            default:
                break;
            }
        }
Пример #6
0
 void OnMidiMessageAsync(object sender, MidiInMessageEventArgs args)
 {
     Dispatcher.BeginInvoke(
         DispatcherPriority.Normal,
         new DispatcherOperationCallback(_ => DispatchMidiEvent(args)),
         null);
 }
Пример #7
0
        /// <summary>
        /// Method called when the device recieves a midi event. It plays the according note on the oscillators.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MidiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
        {
            if (e.MidiEvent is NoteEvent ne)
            {
                int noteNumber = ne.NoteNumber;
                Debug.Print($"CommandCode: {ne.CommandCode}");
                if (ne.CommandCode == MidiCommandCode.NoteOn)
                {
                    Debug.Print($"noteNumber: {noteNumber}");
                    int frequency = (int)_midiNotes[noteNumber];

                    O1.Frequency = frequency;
                    O1.Play(noteNumber);

                    O2.Frequency = frequency;
                    O2.Play(noteNumber);

                    O3.Frequency = frequency;
                    O3.Play(noteNumber);
                }
                else if (ne.CommandCode == MidiCommandCode.NoteOff)
                {
                    O1.Stop(noteNumber);
                    O2.Stop(noteNumber);
                    O3.Stop(noteNumber);
                }
            }
        }
        void midiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
        {
            progressLog1.LogMessage(Color.Blue, String.Format("Time {0} Message 0x{1:X8} Event {2}",
                                                              e.Timestamp, e.RawMessage, e.MidiEvent));

            SendMidiOutMessage(e.MidiEvent);
        }
Пример #9
0
        /// <summary>
        /// MIDI in event handler.
        /// </summary>
        /// <param name="sender">Calling object.</param>
        /// <param name="e">Arguments passed.</param>
        private void MidiInDevice_messageHandler(object sender, MidiInMessageEventArgs e)
        {
            // Do nothing if we don't have any tones to play
            if (tonesAvailable == null || tonesAvailable.Length == 0)
            {
                return;
            }

            // Call ToggleTone on the UI thread using Invoke
            ToggleToneDelegate ttd = new ToggleToneDelegate(ToggleTone);

            Object[] args = new Object[2];

            if (MidiEvent.IsNoteOn(e.MidiEvent))
            {
                args[0] = ((NoteOnEvent)e.MidiEvent).NoteNumber;
                args[1] = Toggle.Play;
                Invoke(ttd, args);
            }
            else if (MidiEvent.IsNoteOff(e.MidiEvent))
            {
                args[0] = ((NoteEvent)e.MidiEvent).NoteNumber;
                args[1] = Toggle.Stop;
                Invoke(ttd, args);
            }
        }
Пример #10
0
    private void MidiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
    {
        var midiEvent = e.MidiEvent;

        if (midiEvent.CommandCode == MidiCommandCode.TimingClock)
        {
            return;
        }

        if (midiEvent.CommandCode == MidiCommandCode.AutoSensing)
        {
            return;
        }

        if (midiEvent.CommandCode == MidiCommandCode.PitchWheelChange)
        {
            return;
        }

        if (midiEvent.CommandCode == MidiCommandCode.ControlChange)
        {
            return;
        }

        EnqeueMidiEvent(e.MidiEvent);
    }
Пример #11
0
        private void ProcessMidiMessage(object sender, MidiInMessageEventArgs e)
        {
            var noteEvent = e.MidiEvent as NoteEvent;

            if (noteEvent != null)
            {
                // Use no regex here for performance reasons.
                var channel = noteEvent.Channel;
                var note    = NoteNames[noteEvent.NoteNumber % 12];
                var octave  = noteEvent.NoteNumber / NoteNames.Length;

                _logService.Verbose($"MIDI event: CH:{channel} / N:{note} / O: {octave} / C:{noteEvent.CommandCode} / V:{noteEvent.Velocity}");

                NoteEventReceived?.Invoke(this, new NoteEventReceivedEventArgs(channel, note, octave, noteEvent.Velocity, noteEvent.CommandCode));
                return;
            }

            var controlChangeEvent = e.MidiEvent as ControlChangeEvent;

            if (controlChangeEvent != null)
            {
                // TODO: Handle AllNotesOff event.
            }

            _logService.Warning($"MIDI event: Unsupported! {e.MidiEvent}");
        }
Пример #12
0
    private void controller_MessageReceived(object sender, MidiInMessageEventArgs e)
    {
        var noteOn = e.MidiEvent as NoteOnEvent;

        if (noteOn != null)
        {
            var track = GetTrack(noteOn.NoteNumber);
            if (track != null)
            {
                orchestrator.ActivateTrack(track);
            }
            switch (noteOn.NoteNumber)
            {
            case UP:
                break;

            case DOWN:
                break;

            case LEFT:
                break;

            case RIGHT:
                break;
            }
        }
    }
 private void Device_MessageReceived(object sender, MidiInMessageEventArgs e)
 {
     foreach (var subscriber in subscribers.Where(s => s.EventType == e.MidiEvent.GetType()))
     {
         subscriber.OnEventReceived(e.MidiEvent);
     }
 }
Пример #14
0
        private void MidiPushButtonLearnCallback(object sender, MidiInMessageEventArgs e)
        {
            NoteOnEvent evento = (NoteOnEvent)e.MidiEvent;

            _pushButtonMidiNote = evento.NoteNumber;
            GlobalStaticContext.RegisterPadWithMidiNote(this, _pushButtonMidiNote);
            GlobalStaticContext.ExitLearnMode();
        }
Пример #15
0
        private void MidiVolumeSliderLearnCallback(object sender, MidiInMessageEventArgs e)
        {
            ControlChangeEvent evento = (ControlChangeEvent)e.MidiEvent;

            _volumeSliderMidiController = evento.Controller;
            GlobalStaticContext.RegisterPadWithMidiController(this, _volumeSliderMidiController.Value);
            GlobalStaticContext.ExitLearnMode();
        }
Пример #16
0
 private void MessageReceived(object sender, MidiInMessageEventArgs eventArgs)
 {
     byte[] message = BitConverter.GetBytes(eventArgs.RawMessage);
     OnMidiMessageReceived.Invoke(sender, new MidiMessageReceivedEventArgs()
     {
         control = message[1],
         value   = message[2]
     });
 }
Пример #17
0
 void midiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
 {
     if (checkBoxFilterAutoSensing.Checked && e.MidiEvent != null && e.MidiEvent.CommandCode == MidiCommandCode.AutoSensing)
     {
         return;
     }
     progressLog1.LogMessage(Color.Blue, String.Format("Time {0} Message 0x{1:X8} Event {2}",
                                                       e.Timestamp, e.RawMessage, e.MidiEvent));
 }
        private void MessageReceived(object sender, MidiInMessageEventArgs e)
        {
            if (e.MidiEvent.CommandCode == MidiCommandCode.TimingClock || e.MidiEvent.CommandCode == MidiCommandCode.AutoSensing)
            {
                return;
            }
            if (e.MidiEvent is NoteEvent note && note.Channel == Configuration.PlayChannel)
            {
                if (PlayBack.CurrentVoice.ChannelAllocation == null)
                {
                    _outDevice.Send(note.GetAsShortMessage());
                }
                else
                {
                    if (note.Velocity == 0)
                    {
                        RemovePlayingNote(note.NoteNumber);
                    }
                    else
                    {
                        if (!_playingNotes.ContainsKey(note.NoteNumber))
                        {
                            _playingNotes[note.NoteNumber] = new HashSet <KeyValuePair <int, int> >();
                        }
                        for (var i = 0; i < 16; ++i)
                        {
                            var newNote = new NoteOnEvent(0, i + 1, note.NoteNumber, note.Velocity, 1);
                            if (i >= PlayBack.CurrentVoice.ChannelAllocation.Length)
                            {
                                continue;
                            }
                            var channelSide = PlayBack.CurrentVoice.ChannelAllocation[i];
                            var splitPoint  = PlayBack.CurrentVoice.SplitPoint;
                            newNote.NoteNumber = PlayBack.CurrentVoice.ChannelTransposition[i] + note.NoteNumber;
                            // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault
                            switch (channelSide)
                            {
                            case VoiceComposition.ChannelSide.Left when note.NoteNumber > splitPoint:
                            case VoiceComposition.ChannelSide.Right when note.NoteNumber <= splitPoint:
                            case VoiceComposition.ChannelSide.None:
                                continue;

                            default:
                                _outDevice.Send(newNote.GetAsShortMessage());
                                _playingNotes[note.NoteNumber]
                                .Add(new KeyValuePair <int, int>(i + 1, newNote.NoteNumber));
                                break;
                            }
                        }
                    }
                }

                if (note.Velocity != 0)
                {
                    PlayBack.NoteReceived(note.NoteNumber);
                }
            }
        public void OnButtonPress(object?sender, MidiInMessageEventArgs e)
        {
            Console.WriteLine($"{e.Timestamp}: {e.MidiEvent}: {e.RawMessage}");
            var controlChangeEvent = ((ControlChangeEvent)e.MidiEvent);

            if (controlChangeEvent.ControllerValue == 127)
            {
                OnButtonPress(controlChangeEvent.Controller);
            }
        }
Пример #20
0
        private void MidiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
        {
            MidiEvent          me  = e.MidiEvent;
            ControlChangeEvent cce = me as ControlChangeEvent;

            if (cce != null)
            {
                potVal = cce.ControllerValue;
            }
        }
Пример #21
0
    /// <summary>
    /// 左回転、右回転、タッチ、フェーダーのイベントをセット
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void midiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
    {
        //if (checkBoxFilterAutoSensing.Checked && e.MidiEvent != null && e.MidiEvent.CommandCode == MidiCommandCode.AutoSensing)
        if (e.MidiEvent != null && e.MidiEvent.CommandCode == MidiCommandCode.AutoSensing)
        {
            return;
        }

        if (e.MidiEvent.CommandCode == MidiCommandCode.ControlChange)
        {
            ControlChangeEvent cc = (ControlChangeEvent)e.MidiEvent;
            switch (_config.CheckMidiEvent(cc))
            {
            case EnumMidiResult.L_TABLE_LEFT:
                SetTurnTable(0, 1, e.Timestamp);
                break;

            case EnumMidiResult.L_TABLE_RIGHT:
                SetTurnTable(0, -1, e.Timestamp);
                break;

            case EnumMidiResult.L_TABLE_TOUCH_ON:
                turntable[0].Touch = true;
                break;

            case EnumMidiResult.L_TABLE_TOUCH_OFF:
                turntable[0].Touch = false;
                break;

            case EnumMidiResult.R_TABLE_LEFT:
                SetTurnTable(1, 1, e.Timestamp);
                break;

            case EnumMidiResult.R_TABLE_RIGHT:
                SetTurnTable(1, -1, e.Timestamp);
                break;

            case EnumMidiResult.R_TABLE_TOUCH_ON:
                turntable[1].Touch = true;
                break;

            case EnumMidiResult.R_TABLE_TOUCH_OFF:
                turntable[1].Touch = false;
                break;

            case EnumMidiResult.X_FADER:
                xfader = cc.ControllerValue;
                break;

            default:
                break;
            }
        }
        //progressLog1.LogMessage(Color.Blue, String.Format("Time {0} Message 0x{1:X8} Event {2}", e.Timestamp, e.RawMessage, e.MidiEvent));
    }
Пример #22
0
        void midiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
        {
            progressLog1.LogMessage(Color.Blue, String.Format("Time {0} Message 0x{1:X8} Event {2}",
                                                              e.Timestamp, e.RawMessage, e.MidiEvent));

            //SendMidiOutMessage(e.MidiEvent);
            if (VSTForm.vst != null)
            {
                MidiEvent midiEvent = e.MidiEvent;
                byte[]    midiData  = { 0, 0, 0 };
                if (midiEvent is NAudio.Midi.NoteEvent)
                {
                    NAudio.Midi.NoteEvent me = (NAudio.Midi.NoteEvent)midiEvent;
                    midiData = new byte[] {
                        0x90,                                           // Cmd
                        (byte)me.NoteNumber,                            // Val 1
                        (byte)me.Velocity,                              // Val 2
                    };
                }
                else if (midiEvent is NAudio.Midi.ControlChangeEvent)
                {
                    NAudio.Midi.ControlChangeEvent cce = (NAudio.Midi.ControlChangeEvent)midiEvent;
                    midiData = new byte[] {
                        0xB0,                                                   // Cmd
                        (byte)cce.Controller,                                   // Val 1
                        (byte)cce.ControllerValue,                              // Val 2
                    };
                }
                else if (midiEvent is NAudio.Midi.PitchWheelChangeEvent)
                {
                    // Pitch Wheel Value 0 is minimum, 0x2000 (8192) is default, 0x4000 (16384) is maximum
                    NAudio.Midi.PitchWheelChangeEvent pe = (PitchWheelChangeEvent)midiEvent;
                    midiData = new byte[] {
                        0xE0,                                                   // Cmd
                        (byte)(pe.Pitch & 0x7f),                                // Val 1
                        (byte)((pe.Pitch >> 7) & 0x7f),                         // Val 2
                    };
                }
                progressLog1.LogMessage(Color.Chocolate, String.Format("Sending mididata 0x00{0:X2}{1:X2}{2:X2}",
                                                                       midiData[2], midiData[1], midiData[0]));
                VstMidiEvent vse =
                    new VstMidiEvent(/*DeltaFrames*/ 0,
                                     /*NoteLength*/ 0,
                                     /*NoteOffset*/ 0,
                                     midiData,
                                     /*Detune*/ 0,
                                     /*NoteOffVelocity*/ 0);

                VstEvent[] ve = new VstEvent[1];
                ve[0] = vse;

                VSTForm.vst.pluginContext.PluginCommandStub.ProcessEvents(ve);
            }
        }
Пример #23
0
        /// <summary>
        /// Process input midi event.
        /// </summary>
        void MidiIn_MessageReceived(object?sender, MidiInMessageEventArgs e)
        {
            // Decode the message. We only care about a few.
            MidiEvent     me   = MidiEvent.FromRawMessage(e.RawMessage);
            MidiEventArgs?mevt = null;

            switch (me)
            {
            case NoteOnEvent evt:
                mevt = new MidiEventArgs()
                {
                    Channel  = evt.Channel,
                    Note     = evt.NoteNumber,
                    Velocity = evt.Velocity
                };
                break;

            case NoteEvent evt:
                mevt = new MidiEventArgs()
                {
                    Channel  = evt.Channel,
                    Note     = evt.NoteNumber,
                    Velocity = 0
                };
                break;

            case ControlChangeEvent evt:
                mevt = new MidiEventArgs()
                {
                    Channel         = evt.Channel,
                    ControllerId    = (int)evt.Controller,
                    ControllerValue = evt.ControllerValue
                };
                break;

            case PitchWheelChangeEvent evt:
                mevt = new MidiEventArgs()
                {
                    Channel         = evt.Channel,
                    ControllerId    = MidiEventArgs.PITCH_CONTROL,
                    ControllerValue = evt.Pitch
                };
                break;
            }

            if (mevt is not null)
            {
                // Pass it up for handling.
                InputEvent?.Invoke(this, mevt);
            }
            // else ignore??
        }
Пример #24
0
        private void MidiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
        {
            //TODO: add other cases for dials, pitch wheel, etc...
            switch (e.MidiEvent.CommandCode)
            {
            case MidiCommandCode.NoteOn:
                Messenger.Default.Send(((NoteOnEvent)e.MidiEvent));
                break;

            default:
                break;
            }
        }
Пример #25
0
        private void MidiInOnMessageReceived(object?sender, MidiInMessageEventArgs e)
        {
            switch (e.MidiEvent.CommandCode)
            {
            case MidiCommandCode.ControlChange:
                HandleControlChangeEvent(e);
                break;

            default:
                Console.Out.WriteLine($"MidiInputManager: Received unhandled event code: {e.MidiEvent.CommandCode}");
                return;
            }
        }
Пример #26
0
 private void midiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
 {
     if (e.MidiEvent is NoteOnEvent)
     {
         NoteOnEvent noteOn = (NoteOnEvent)e.MidiEvent;
         engine.addActiveMIDIKey(noteOn.NoteNumber);
     }
     else if (e.MidiEvent is NoteEvent)
     {
         NoteEvent noteOff = (NoteEvent)e.MidiEvent;
         engine.removeActiveMIDIKey(noteOff.NoteNumber);
     }
 }
Пример #27
0
        public virtual void midiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
        {
            WindowTools.Dump(e.MidiEvent);

            foreach (var fader in faders)
            {
                fader.HandleEvent(e);
            }

            foreach (var button in buttons)
            {
                button.HandleEvent(e);
            }
        }
Пример #28
0
        private void MidiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
        {
            var msg = BitConverter.GetBytes(e.RawMessage);

            if (msg[0] >> 4 == 9 && msg[2] > 0)
            {
                // var channel = (msg[0] & 0x0F) + 1;
                var note = msg[1];
                // var velocity = msg[2];

                if (_arpThreadRunning)
                {
                    _arpNotes.AddNote(note);
                }
                else
                {
                    _synthEngine.NoteOn(note);
                }
            }
            if (msg[0] >> 4 == 8 || (msg[0] >> 4 == 9 && msg[2] == 0))
            {
                // var channel = (msg[0] & 0x0F) + 1;
                var note = msg[1];

                if (_arpThreadRunning)
                {
                    _arpNotes.RemoveNote(note);
                }
                else
                {
                    _synthEngine.NoteOff(note);
                }
            }

            if (msg[1] == 7)
            {
                Dispatcher.Invoke(() =>
                {
                    VolumeSlider.Value = msg[2] * 100 / 128f;
                });
            }

            if (msg[1] == 1)
            {
                Dispatcher.Invoke(() =>
                {
                    FilterCutoff.LinearValue = msg[2] * 19980 / 127 - 20;
                });
            }
        }
Пример #29
0
        private void midiInReceived(object sender, MidiInMessageEventArgs e)
        {
            if (e.MidiEvent == null)
            {
                return;
            }

            NoteEvent noteEvent;

            try
            {
                noteEvent = (NoteEvent)e.MidiEvent;
            } catch (Exception)
            {
                Console.WriteLine("midicontroller exc");
                return;
            }

            if (MidiEvent.IsNoteOn(e.MidiEvent))
            {
                int calculatedNote = offsetNote(noteEvent.NoteNumber, KeyboardController.KeyOffset);
                MidiOutput.play(calculatedNote);
                if (currentlyPressedKeys.ContainsKey(calculatedNote))
                {
                    return;
                }

                if (Guide == null)
                {
                    return;
                }

                currentlyPressedKeys.Add(calculatedNote, GuidesController.StopWatch.ElapsedMilliseconds);
                Guide.ActiveKeys = currentlyPressedKeys;
                Guide.UpdatePianoKeys();
                //Thread.Sleep inside GUI is just for example
            }
            else
            {
                int calculatedNote = offsetNote(noteEvent.NoteNumber, KeyboardController.KeyOffset);
                MidiOutput.stop(calculatedNote);
                if (Guide == null)
                {
                    return;
                }
                currentlyPressedKeys.Remove(calculatedNote);
                Guide.ActiveKeys = currentlyPressedKeys;
                Guide.UpdatePianoKeys();
            }
        }
Пример #30
0
        /// <summary>
        /// From Mark Heath example http://mark-dot-net.blogspot.com/2008/10/midi-in-for-babysmash.html
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void midiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
        {
            NoteOnEvent noteOnEvent = e.MidiEvent as NoteOnEvent;

            if (noteOnEvent != null)
            {
                var uie = this.figuresUserControlQueue.FirstOrDefault().Value.FirstOrDefault();
                if (uie != null)
                {
                    ProcessMidiNoteOn(uie, noteOnEvent);
                }
            }

            //Dispatcher.BeginInvoke(Action()=>new EventHandler<MidiInMessageEventArgs>(midiIn_MessageReceived), sender, e);
        }
Пример #31
0
 static void midiIn_ErrorReceived(object sender, MidiInMessageEventArgs e)
 {
     throw new NotImplementedException();
 }
Пример #32
0
 static void midiIn_MessageReceived(object sender, MidiInMessageEventArgs e)
 {
     if (e.MidiEvent is NAudio.Midi.NoteOnEvent && MIDIReceived_NoteOn != null)
     {
         MIDIDataReceivedEventArgs eMIDI = new MIDIDataReceivedEventArgs();
         eMIDI.Cmd = 0x99;
         eMIDI.Data1 = (byte)((NAudio.Midi.NoteOnEvent)e.MidiEvent).NoteNumber;
         eMIDI.Data2 = (byte)((NAudio.Midi.NoteOnEvent)e.MidiEvent).Velocity;
         MIDIReceived_NoteOn(eMIDI);
         UtilityAudio.MIDI_NoteOn(eMIDI.Data1, eMIDI.Data2);
     }
     else if (e.MidiEvent is NAudio.Midi.ControlChangeEvent && MIDIReceived_CC != null)
     {
         MIDIDataReceivedEventArgs eMIDI = new MIDIDataReceivedEventArgs();
         eMIDI.Cmd = 0xB9;
         eMIDI.Data1 = (byte)((NAudio.Midi.ControlChangeEvent)e.MidiEvent).Controller;
         eMIDI.Data2 = (byte)((NAudio.Midi.ControlChangeEvent)e.MidiEvent).ControllerValue;
         MIDIReceived_CC(eMIDI);
         UtilityAudio.MIDI_CC(eMIDI.Data1, eMIDI.Data2);
     }
     else if (e.MidiEvent is NAudio.Midi.SysexEvent && MIDIReceived_SysEx != null)
     {
         MIDIDataReceivedEventArgs eMIDI = new MIDIDataReceivedEventArgs();
         //e.RawMessage;//Meglio leggere direttamente questo...
         /*if(...)
         {
             eMIDI.Cmd = 0xB9;
             eMIDI.Data1 = (byte)((NAudio.Midi.SysexEvent)e.MidiEvent).;
             eMIDI.Data2 = (byte)((NAudio.Midi.SysexEvent)e.MidiEvent).ControllerValue;
             MIDIReceived_SysEx(eMIDI);
         }*/
     }
 }