Note On message.
Inheritance: NoteMessage
示例#1
0
 public void InputNoteOn(Midi.NoteOnMessage msg)
 {
     if (channel == 0 || channel == (int)msg.Channel + 1)
     {
         _deviceInterface.OnMidiNote((int)msg.Channel + 1, msg.Velocity != 0, (int)msg.Pitch);
     }
 }
示例#2
0
 public void NoteOn(NoteOnMessage msg)
 {
     clock.Schedule(new NoteOnMessage(outputDevice, msg.Channel, msg.Note + 4, msg.Velocity,
         msg.BeatTime + 1));
     clock.Schedule(new NoteOnMessage(outputDevice, msg.Channel, msg.Note + 7, msg.Velocity,
         msg.BeatTime + 2));
 }
示例#3
0
        //Is fired when a MIDI note is catched
        public void NoteOn(NoteOnMessage msg)
        {
            AppendTextBox(msg.Pitch.ToString());

              for (int i = 0; i < comboBoxCount; i++)
              {
            if (checkBoxActiveList[i].Checked)
            {

              Pitch selectedNote = (Pitch)Invoke(new Func<Pitch>(() => (Pitch)comboBoxNoteList[i].SelectedItem));

              VirtualKeyCode selectedKey = (VirtualKeyCode)Invoke(new Func<VirtualKeyCode>(() => (VirtualKeyCode)comboBoxKeyList[i].SelectedItem));

              if (msg.Pitch == selectedNote)
              {
            if (selectedKey == VirtualKeyCode.LBUTTON)
            {
              simulator.Mouse.LeftButtonClick();
            }

            else if (selectedKey == VirtualKeyCode.RBUTTON)
            {
              simulator.Mouse.RightButtonClick();
            }

            else if (selectedKey == VirtualKeyCode.MBUTTON)
            {
              simulator.Mouse.XButtonClick(0);
            }

            simulator.Keyboard.KeyPress(selectedKey);
              }
            }
              }
        }
示例#4
0
 public void Schedule(OutputDevice outputDevice, NoteOnMessage msg, float noteLength)
 {
     //outputDevice.SendNoteOn(msg.Channel, msg.Pitch, msg.Velocity);
     //Thread.Sleep();
     clock.Schedule(new NoteOnMessage(outputDevice, msg.Channel, msg.Pitch, msg.Velocity, msg.Time));
     clock.Schedule(new NoteOffMessage(outputDevice, msg.Channel, msg.Pitch, msg.Velocity, msg.Time + noteLength));
 }
示例#5
0
        public void PlayNote(Note note)
        {
            var noteOn = new NoteOnMessage(this._outputDevice, this.PlayerParameters.Channel, note, this._velocity, this._clock.BeatTime);
            var noteOff = new NoteOffMessage(this._outputDevice, this.PlayerParameters.Channel, note, this._velocity, this._clock.BeatTime + 1);

            this._clock.Schedule(noteOn);
            this._clock.Schedule(noteOff);
        }
示例#6
0
 private void midiPress(Midi.NoteOnMessage msg)
 {
     if (OnLaunchpadKeyPressed != null && !rightLEDnotes.Contains(msg.Pitch))
     {
         OnLaunchpadKeyPressed(this, new LaunchpadKeyEventArgs(msg, midiNoteToLed(msg.Pitch)[0], midiNoteToLed(msg.Pitch)[1], msg.Velocity));
     }
     else if (OnLaunchpadCCKeyPressed != null && rightLEDnotes.Contains(msg.Pitch))
     {
         OnLaunchpadCCKeyPressed(this, new LaunchpadCCKeyEventArgs(midiNoteToSideLED(msg.Pitch), msg.Velocity));
     }
 }
示例#7
0
 private void midiPress(Midi.NoteOnMessage msg)
 {
     //Console.WriteLine("<MIDI> "+msg.Channel+" "+msg.Device+" "+msg.Pitch+" "+msg.Velocity);
     if (msg.Velocity > 0)
     {
         OnLaunchpadKeyPressed?.Invoke(this, new LaunchpadKeyEventArgs(midiNoteToLed(msg.Pitch)[1], midiNoteToLed(msg.Pitch)[0], msg.Velocity));
     }
     else
     {
         OnLaunchpadKeyReleased?.Invoke(this, new LaunchpadKeyEventArgs(midiNoteToLed(msg.Pitch)[1], midiNoteToLed(msg.Pitch)[0], msg.Velocity));
     }
 }
示例#8
0
 public LaunchpadKeyEventArgs(Midi.NoteOnMessage _msg, int _pX, int _pY, int _vol)
 {
     msg = _msg;
     x   = _pX;
     y   = _pY;
     if (_vol == 127)
     {
         press = true;
     }
     else
     {
         press = false;
     }
 }
示例#9
0
 public LaunchpadKeyEventArgs(int _pX, int _pY, int _vol)
 {
     x   = _pX;
     y   = _pY;
     msg = null;
     if (_vol == 127)
     {
         press = true;
     }
     else
     {
         press = false;
     }
 }
示例#10
0
        void NoteOnCommand(NoteOnMessage msg)
        {
            //Console.WriteLine("YAY");
            Dictionary<string, string> x = new Dictionary<string, string>();
            x.Add("Name", "TileCrate");
            x.Add("x", ((int)(((-100 + (int)msg.Pitch * 16) / 16) * 16)).ToString());
            x.Add("y", ((int)(((-100 + (int)msg.Velocity * 4) / 16) * 16)).ToString());
            x.Add("width", ((int)((((int)msg.Velocity * 1) / 16) * 16) / 1).ToString());
            x.Add("height", ((int)((((int)msg.Velocity * 1) / 16) * 16) / 1).ToString());
            Registry.boxes.Add(x);

            Registry.midi.inputDevice.RemoveAllEventHandlers();
            FlxG.state = new PlayState();
            return;



        }
示例#11
0
        public void NoteOn(NoteOnMessage msg, OutputDevice output)
        {
            output.SilenceAllNotes();

            if (!currentNote.Equals(Pitch.A0))
            {
                total++;
                if (msg.Pitch.PositionInOctave().Equals(currentNote.PositionInOctave()))
                {
                    score++;
                    currentNote = availableNotes[random.Next(availableNotes.Count)];
                    clock.Schedule(new NoteOnOffMessage(output,msg.Channel,Pitch.G5,127,clock.Time,clock,1));
                    clock.Schedule(new NoteOnOffMessage(output,msg.Channel,Pitch.C6,127,clock.Time+1,clock,1));
                }
            }
            else
            {
                currentNote = availableNotes[random.Next(availableNotes.Count)];
            }
        }
示例#12
0
 private void NoteOn(NoteOnMessage msg)
 {
     currentChannel = msg.Channel;
     notesDown.Add(msg.Pitch);
     try
     {
         operations[msg.Channel].NoteOn(msg, outputDevice);
     }
     catch (KeyNotFoundException) { }
     finally
     {
         Display();
     }
 }
示例#13
0
 public void NoteOn(NoteOnMessage msg)
 {
     lock (this)
     {
         pitchesPressed[msg.Pitch] = true;
         PrintStatus();
     }
 }
示例#14
0
        /// <summary>
        /// Process the Note On message.
        /// </summary>
        /// <param name="noteOnMessage">The note on message.</param>
        public void ProcessMidiMessage(NoteOnMessage noteOnMessage)
        {
            var channel = noteOnMessage.Channel;

            Trace.TraceInformation("Got note ON  for channel " + channel.Name() + " and pitch " + noteOnMessage.Pitch.NotePreferringFlats());

            Debug.Assert(incompleteMessages[channel][noteOnMessage.Pitch] == null, "there's already a note on message for channel " + channel.Name() + " and pitch " + noteOnMessage.Pitch);

            incompleteMessages[channel][noteOnMessage.Pitch] = noteOnMessage;
        }
 public void TestingNoteOn(NoteOnMessage msg)
 {
     if (isTesting && testing_recieve_passed == false)
     {
         testing_recieve_passed = true;
         testingform.setTestProgress(1);
     }
     if (isTesting && testing_recieve_passed == true && testing_sending_passed == false)
     {
         DeviceManager.targetOutput.SendNoteOn(0, Pitch.E5, 127);
         if (msg.Pitch == Pitch.E5)
         {
             testing_sending_passed = true;
             testingform.setTestProgress(2);
             ResetAllNotes();
             Thread.Sleep(500);
             testingform.setTestProgress(3);
             Thread.Sleep(300);
             testingform.resetTestProgress();
             EndTesting();
         }
     }
 }
示例#16
0
        public override void Run()
        {            
            if (OutputDevice.InstalledDevices.Count == 0)
            {
                Console.WriteLine("Can't do anything with no output device.");
                return;
            }

            float beatsPerMinute = 180;
            Clock clock = new Clock(beatsPerMinute);

            OutputDevice outputDevice = OutputDevice.InstalledDevices[0];
            outputDevice.Open();

            Drummer drummer = new Drummer(clock, outputDevice, 4);

            InputDevice inputDevice = null;
            if (InputDevice.InstalledDevices.Count > 0)
            {
                // Just pick the first input device.  This will throw an exception if there isn't
                // one.
                inputDevice = InputDevice.InstalledDevices[0];
                inputDevice.Open();
            }
            Scaler scaler = new Scaler(clock, inputDevice, outputDevice);

            clock.Start();
            if (inputDevice != null)
            {
                inputDevice.StartReceiving(clock);
            }

            bool done = false;

            while (!done)
            {
                Console.Clear();
                Console.WriteLine("BPM = {0}, Playing = {1}, Scale = {2}", clock.BeatsPerMinute,
                    clock.IsRunning, scaler.GetScaletoUse());
                Console.WriteLine("Escape : Quit");
                Console.WriteLine("Down : Slower");
                Console.WriteLine("Up: Faster");
                Console.WriteLine("Left: Previous Scale");
                Console.WriteLine("Right: Next Scale");
                Console.WriteLine("Space = Toggle Play");
                ConsoleKey key = Console.ReadKey(true).Key;
                Note note;
                if (key == ConsoleKey.Escape)
                {
                    done = true;
                }
                else if (key == ConsoleKey.DownArrow)
                {
                    clock.BeatsPerMinute -= 2;
                }
                else if (key == ConsoleKey.UpArrow)
                {
                    clock.BeatsPerMinute += 2;
                }
                else if (key == ConsoleKey.RightArrow)
                {
                    scaler.NextScale();
                }
                else if (key == ConsoleKey.LeftArrow)
                {
                    scaler.PreviousScale();
                }
                else if (key == ConsoleKey.Spacebar)
                {
                    if (clock.IsRunning)
                    {
                        clock.Stop();
                        if (inputDevice != null)
                        {
                            inputDevice.StopReceiving();
                        }
                        outputDevice.SilenceAllNotes();
                    }
                    else
                    {
                        clock.Start();
                        if (inputDevice != null)
                        {
                            inputDevice.StartReceiving(clock);
                        }
                    }
                }
                else if (key == ConsoleKey.D1)
                {
                    NoteOnMessage msg = new NoteOnMessage(outputDevice, Channel.Channel1, Note.C4,
                        80, clock.BeatTime);
                    NoteOffMessage msg2 = new NoteOffMessage(outputDevice, Channel.Channel1,
                        Note.C4, 80, clock.BeatTime+0.99f);
                    clock.Schedule(msg);
                    clock.Schedule(msg2);
                    scaler.NoteOn(msg);
                }
                else if (ExampleUtil.IsMockNote(key, out note))
                {
                    NoteOnMessage noteOn = new NoteOnMessage(outputDevice, 0, note, 100,
                        clock.BeatTime);
                    NoteOffMessage noteOff = new NoteOffMessage(outputDevice, 0, note, 100,
                        clock.BeatTime + 1);
                    clock.Schedule(noteOn);
                    clock.Schedule(noteOff);
                    scaler.NoteOn(noteOn);
                }

            }

            if (clock.IsRunning)
            {
                clock.Stop();
                if (inputDevice != null)
                {
                    inputDevice.StopReceiving();
                }
                outputDevice.SilenceAllNotes();
            }

            outputDevice.Close();
            if (inputDevice != null)
            {
                inputDevice.Close();
            }
        }
示例#17
0
        private void ReceivingMidiDevice_NoteOn(NoteOnMessage msg)
        {
            // Somehow, when I release a key on my Axiom 61, a NoteOn message is received with Velocity = 0.
            // Not sure if it's specific to Axiom, MidiDotNet library, or my environment setup.
            if (msg.Velocity == 0)
            {
                return;
            }

            if (midiInputLearnTargetControl != null)
            {
                if (eventBuffer.IsEmpty)
                {
                    // Let's try to capture a chord.
                    // While this thread stores the incoming notes to the buffer,
                    // a background thread will watch the time and process the buffer afterwards.
                    new Thread(WaitAndFinalizeChord).Start();
                }

                eventBuffer.Add(msg);
                return;
            }

            if (chkTestMidiInputDevice.Checked)
            {
                Invoke(new Action(() =>
                {
                    lblMidiTestStatus.ForeColor = Color.Green;
                    lblMidiTestStatus.Text = string.Format
                    (
                        "Pitch: {0}   Velocity: {1}",
                        PitchConverter.PitchToString(msg.Pitch),
                        msg.Velocity
                    );
                }));
            }
        }
示例#18
0
 public void Schedule(Channel channel, Pitch pitch, int velocity, float time, float noteLength)
 {
     if (OutputDevice == null) return;
     var msg = new NoteOnMessage(OutputDevice, channel, pitch, velocity, time);
     c.Schedule(OutputDevice, msg, noteLength);
 }
示例#19
0
 // Method called when the input device receives a NoteOn message.  Updates
 // the input status label.  Respects GUI thread affinity by invoking to the
 // GUI thread if necessary.
 public void NoteOn(NoteOnMessage msg)
 {
     if (InvokeRequired) {
         BeginInvoke(noteOnHandler, msg);
         return;
     }
     inputStatusLabel.Text = String.Format("Note On {0}", msg.Pitch);
 }
示例#20
0
        private void MidiInputDevice_NoteOn(NoteOnMessage msg)
        {
            // Allow executing actions only on the active document.
            if (!textView.HasAggregateFocus)
            {
                return;
            }

            // Somehow, when I release a key on my Axiom 61, a NoteOn message is received with Velocity = 0.
            // Not sure if it's specific to Axiom, MidiDotNet library, or my environment setup.
            if (msg.Velocity == 0)
            {
                return;
            }

            // If we're already waiting for a chord to complete, then store the note for further processing and move on.
            if (eventBuffer != null)
            {
                eventBuffer.Add(msg);
                return;
            }

            var chordMatches = mappingMatcher.FindChordMatchesContainingNote(msg.Pitch);
            if (chordMatches.Length > 0)
            {
                // If the note belongs to a chord, we should hold on for a short time
                // and allow other notes from this chord to be received, then execute actions.
                Interlocked.CompareExchange(ref eventBuffer, new MidiEventBuffer(), null);
                eventBuffer.Add(msg);

                // While this thread stores the incoming notes to the buffer,
                // a background thread will watch the time and process the buffer afterwards.
                new Thread(WaitAndFinalizeChord).Start();
                return;
            }

            var singleNoteMatches = mappingMatcher.FindSingleNoteMatches(msg.Pitch);
            ExecuteMappedActions(singleNoteMatches);
        }
示例#21
0
        public override void Run()
        {
            // Create a clock running at the specified beats per minute.
            int beatsPerMinute = 180;
            Clock clock = new Clock(beatsPerMinute);

            // Prompt user to choose an output device (or if there is only one, use that one.
            OutputDevice outputDevice = ExampleUtil.ChooseOutputDeviceFromConsole();
            if (outputDevice == null)
            {
                Console.WriteLine("No output devices, so can't run this example.");
                ExampleUtil.PressAnyKeyToContinue();
                return;
            }
            outputDevice.Open();

            // Prompt user to choose an input device (or if there is only one, use that one).
            InputDevice inputDevice = ExampleUtil.ChooseInputDeviceFromConsole();
            if (inputDevice != null)
            {
                inputDevice.Open();
            }

            Arpeggiator arpeggiator = new Arpeggiator(inputDevice, outputDevice, clock);
            Drummer drummer = new Drummer(clock, outputDevice, 4);

            clock.Start();
            if (inputDevice != null)
            {
                inputDevice.StartReceiving(clock);
            }

            bool done = false;
            while (!done)
            {
                Console.Clear();
                Console.WriteLine("BPM = {0}, Playing = {1}, Arpeggiator Mode = {2}",
                    clock.BeatsPerMinute, clock.IsRunning, arpeggiator.Status);
                Console.WriteLine("Escape : Quit");
                Console.WriteLine("Down : Slower");
                Console.WriteLine("Up: Faster");
                Console.WriteLine("Left: Previous Chord or Scale");
                Console.WriteLine("Right: Next Chord or Scale");
                Console.WriteLine("Space = Toggle Play");
                Console.WriteLine("Enter = Toggle Scales/Chords");
                ConsoleKey key = Console.ReadKey(true).Key;
                Pitch pitch;
                if (key == ConsoleKey.Escape)
                {
                    done = true;
                }
                else if (key == ConsoleKey.DownArrow)
                {
                    clock.BeatsPerMinute -= 2;
                }
                else if (key == ConsoleKey.UpArrow)
                {
                    clock.BeatsPerMinute += 2;
                }
                else if (key == ConsoleKey.RightArrow)
                {
                    arpeggiator.Change(1);
                }
                else if (key == ConsoleKey.LeftArrow)
                {
                    arpeggiator.Change(-1);
                }
                else if (key == ConsoleKey.Spacebar)
                {
                    if (clock.IsRunning)
                    {
                        clock.Stop();
                        if (inputDevice != null)
                        {
                            inputDevice.StopReceiving();
                        }
                        outputDevice.SilenceAllNotes();
                    }
                    else
                    {
                        clock.Start();
                        if (inputDevice != null)
                        {
                            inputDevice.StartReceiving(clock);
                        }
                    }
                }
                else if (key == ConsoleKey.Enter)
                {
                    arpeggiator.ToggleMode();
                }
                else if (ExampleUtil.IsMockPitch(key, out pitch))
                {
                    // We've hit a QUERTY key which is meant to simulate a MIDI note, so
                    // send the Note On to the output device and tell the arpeggiator.
                    NoteOnMessage noteOn = new NoteOnMessage(outputDevice, 0, pitch, 100,
                        clock.Time);
                    clock.Schedule(noteOn);
                    arpeggiator.NoteOn(noteOn);
                    // We don't get key release events for the console, so schedule a
                    // simulated Note Off one beat from now.
                    NoteOffMessage noteOff = new NoteOffMessage(outputDevice, 0, pitch, 100,
                        clock.Time + 1);
                    CallbackMessage.CallbackType noteOffCallback = beatTime =>
                    {
                        arpeggiator.NoteOff(noteOff);
                    };
                    clock.Schedule(new CallbackMessage(beatTime => arpeggiator.NoteOff(noteOff),
                        noteOff.Time));
                }
            }

            if (clock.IsRunning)
            {
                clock.Stop();
                if (inputDevice != null)
                {
                    inputDevice.StopReceiving();
                }
                outputDevice.SilenceAllNotes();
            }

            outputDevice.Close();
            if (inputDevice != null)
            {
                inputDevice.Close();
                inputDevice.RemoveAllEventHandlers();
            }

            // All done.
        }
示例#22
0
 public void NoteOn(NoteOnMessage msg)
 {
     lock (this)
     {
         List<Pitch> pitches = new List<Pitch>();
         if (playingChords)
         {
             Chord chord = new Chord(msg.Pitch.NotePreferringSharps(),
                 Chord.Patterns[currentChordPattern], 0);
             Pitch p = msg.Pitch;
             for (int i = 0; i < chord.NoteSequence.Length; ++i)
             {
                 p = chord.NoteSequence[i].PitchAtOrAbove(p);
                 pitches.Add(p);
             }
         }
         else
         {
             Scale scale = new Scale(msg.Pitch.NotePreferringSharps(),
                 Scale.Patterns[currentScalePattern]);
             Pitch p = msg.Pitch;
             for (int i = 0; i < scale.NoteSequence.Length; ++i)
             {
                 p = scale.NoteSequence[i].PitchAtOrAbove(p);
                 pitches.Add(p);
             }
             pitches.Add(msg.Pitch + 12);
         }
         lastSequenceForPitch[msg.Pitch] = pitches;
         for (int i = 1; i < pitches.Count; ++i)
         {
             clock.Schedule(new NoteOnMessage(outputDevice, msg.Channel,
                 pitches[i], msg.Velocity, msg.Time + i));
         }
     }
 }
示例#23
0
 public void NoteOn(NoteOnMessage msg)
 {
     Scale scale = new Scale(msg.Note.Family(), Scale.Patterns[scaleToUse]);
     List<Note> scaleNotes = scale.Traverse(msg.Note, msg.Note+12);
     float delay = msg.BeatTime+1;
     for (int i = 1; i < scaleNotes.Count; ++i, delay++)
     {
         clock.Schedule(new NoteOnOffMessage(outputDevice, msg.Channel, scaleNotes[i],
         msg.Velocity, delay, 0.99f));
     }
     scaleNotes = scale.Traverse(msg.Note+12, msg.Note);
     for (int i = 1; i < scaleNotes.Count; ++i, delay++)
     {
         clock.Schedule(new NoteOnOffMessage(outputDevice, msg.Channel, scaleNotes[i],
         msg.Velocity, delay, 0.99f));
     }
 }
示例#24
0
 public void NoteOn(NoteOnMessage msg, OutputDevice output)
 {
     if(msg.Pitch.Octave()*12+msg.Pitch.PositionInOctave() < 41)
         output.SendNoteOn(msg.Channel, msg.Pitch - 12, msg.Velocity);
 }
示例#25
0
        public void NoteOn(NoteOnMessage msg)
        {
            /**
             * Keeping the control from cross-threading
             */
            if (txtMessages.InvokeRequired) {
                NoteOnCallback d = new NoteOnCallback(NoteOn);
                txtMessages.Invoke(d, new object[] { msg });
            } else {
                PrintMessage("ON / " + msg.Pitch + " / " + msg.Velocity);

                /**
                 * When Pause is ON, just play the test_sound
                 */
                if (checkPause) {
                    if (msg.Velocity > VELOCITY_MIN) {
                        this.doPlay();
                    }
                } else {
                    /**
                     * If the button means NEXT, put the cursor on the next marker
                     */
                    if (msg.Pitch == this.pitchPrevious) {
                        if (msg.Velocity > VELOCITY_MIN) {
                            this.doPrevious();
                        }

                    /**
                     * If the button means STOP, stop everything
                     */
                    } else if (msg.Pitch == this.pitchStop) {
                        if (msg.Velocity > VELOCITY_MIN) {
                            this.doStop();
                        }

                    /**
                     * If the button means NEXT, put the cursor on the next marker
                     */
                    } else if (msg.Pitch == this.pitchNext) {
                        if (msg.Velocity > VELOCITY_MIN) {
                            this.doNext();
                        }

                    /**
                     * If the button means PLAY, play the media marker
                     */
                    } else if (msg.Pitch == this.pitchPlay) {
                        if (msg.Velocity > VELOCITY_MIN) {
                            //Selecting ON ACTION
                            markerButtons[buttonCounter].BackColor = System.Drawing.ColorTranslator.FromHtml("#a1f73b");
                            this.doPlay();
                        } else if (msg.Velocity == VELOCITY_MIN) {
                            this.doNext();
                        }
                    }
                }
            }
        }
示例#26
0
 public void NoteOn(NoteOnMessage msg, OutputDevice output)
 {
 }
示例#27
0
 private void OnInputDeviceNoteOn(NoteOnMessage msg)
 {
     OnButtonClick((Button)msg.Pitch, ButtonClickState.Pressed);
 }
示例#28
0
        public override void Run()
        {
            // Create a clock running at the specified beats per minute.
            int beatsPerMinute = 180;
            Clock clock = new Clock(beatsPerMinute);
            
            // Utility function prompts user to choose an output device (or if there is only one,
            // returns that one).
            OutputDevice outputDevice = ExampleUtil.ChooseOutputDeviceFromConsole();
            if (outputDevice == null)
            {
                Console.WriteLine("No output devices, so can't run this example.");
                ExampleUtil.PressAnyKeyToContinue();
                return;
            }
            outputDevice.Open();

            // Utility function prompts user to choose an input device (or if there is only one,
            // returns that one).
            InputDevice inputDevice = ExampleUtil.ChooseInputDeviceFromConsole();
            if (inputDevice != null)
            {
                inputDevice.Open();
            }

            Arpeggiator arpeggiator = new Arpeggiator(inputDevice, outputDevice, clock);

            Console.WriteLine("Press Escape when finished.");

            clock.Start();
            if (inputDevice != null)
            {
                inputDevice.StartReceiving(clock);
            }

            while (true)
            {
                ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                if (keyInfo.Key == ConsoleKey.Escape)
                {
                    break;
                }
                Note note;
                if (ExampleUtil.IsMockNote(keyInfo.Key, out note))
                {
                    NoteOnMessage noteOn = new NoteOnMessage(outputDevice, 0, note, 100,
                        clock.BeatTime);
                    NoteOffMessage noteOff = new NoteOffMessage(outputDevice, 0, note, 100,
                        clock.BeatTime+1);
                    clock.Schedule(noteOn);
                    clock.Schedule(noteOff);
                    arpeggiator.NoteOn(noteOn);
                    arpeggiator.NoteOff(noteOff);
                }
            }

            clock.Stop();

            // Close the devices.
            outputDevice.Close();

            if (inputDevice != null)
            {
                inputDevice.StopReceiving();
                inputDevice.Close();
            }

            // All done.
        }
示例#29
0
        private void mInputDevice_NoteOn(NoteOnMessage msg)
        {
            LaunchpadButton button = GetButton(msg.Pitch);
            if (button == null)
                return;

            button.State = (ButtonPressState)msg.Velocity;

            if (ButtonPressed != null && button.State == ButtonPressState.Down) {
                if ((int)msg.Pitch % 16 == 8)
                    ButtonPressed.Invoke(this, new ButtonPressEventArgs((SideButton)((int)msg.Pitch / 16)));
                else
                    ButtonPressed.Invoke(this, new ButtonPressEventArgs((int)msg.Pitch % 16, (int)msg.Pitch / 16));
            }
        }
示例#30
0
 public void NoteOn(NoteOnMessage msg)
 {
     try
     {
         NotesDictionary[msg.Pitch.ToString()].PressKey();
     }
     catch (Exception)
     {
         // ignored
     }
 }