Note Off message.
상속: NoteMessage
예제 #1
0
 public void NoteOff(NoteOffMessage msg)
 {
     clock.Schedule(new NoteOffMessage(outputDevice, msg.Channel, msg.Note + 4, msg.Velocity,
         msg.BeatTime + 1));
     clock.Schedule(new NoteOffMessage(outputDevice, msg.Channel, msg.Note + 7, msg.Velocity,
         msg.BeatTime + 2));
 }
예제 #2
0
 public void InputNoteOff(Midi.NoteOffMessage msg)
 {
     if (channel == 0 || channel == (int)msg.Channel + 1)
     {
         _deviceInterface.OnMidiNote((int)msg.Channel + 1, false, (int)msg.Pitch);
     }
 }
예제 #3
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);
        }
예제 #4
0
 private void OnInputDeviceNoteOff(NoteOffMessage msg)
 {
     OnButtonClick((Button)msg.Pitch, ButtonClickState.Released);
 }
예제 #5
0
 public void NoteOff(NoteOffMessage msg, OutputDevice output)
 {
     if (msg.Pitch.Octave() * 12 + msg.Pitch.PositionInOctave() < 41)
         output.SendNoteOff(msg.Channel, msg.Pitch - 12, msg.Velocity);
 }
예제 #6
0
 public void NoteOff(NoteOffMessage msg)
 {
     lock (this)
     {
         pitchesPressed.Remove(msg.Pitch);
         PrintStatus();
     }
 }
예제 #7
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.
        }
예제 #8
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.
        }
예제 #9
0
 public void NoteOff(NoteOffMessage msg)
 {
     if (!lastSequenceForPitch.ContainsKey(msg.Pitch))
     {
         return;
     }
     List<Pitch> pitches = lastSequenceForPitch[msg.Pitch];
     lastSequenceForPitch.Remove(msg.Pitch);
     for (int i = 1; i < pitches.Count; ++i)
     {
         clock.Schedule(new NoteOffMessage(outputDevice, msg.Channel,
             pitches[i], msg.Velocity, msg.Time + i));
     }
 }
예제 #10
0
파일: Guess.cs 프로젝트: shadow7412/Shimidi
 public void NoteOff(NoteOffMessage msg, OutputDevice output)
 {
     output.SendNoteOn(msg.Channel, currentNote, 127);
 }
예제 #11
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();
            }
        }
예제 #12
0
 public void NoteOff(NoteOffMessage msg)
 {
     try
     {
         NotesDictionary[msg.Pitch.ToString()]. ReleaseKey();
     }
      catch (Exception)
      {
          // ignored
      }
 }
예제 #13
0
 // Method called when the input device receives a NoteOff message.  Updates
 // the input status label.  Respects GUI thread affinity by invoking to the
 // GUI thread if necessary.
 public void NoteOff(NoteOffMessage msg)
 {
     if (InvokeRequired)
     {
         BeginInvoke(noteOffHandler, msg);
         return;
     }
     inputStatusLabel.Text = String.Format("Note Off {0}", msg.Pitch);
 }
예제 #14
0
 public void NoteOff(NoteOffMessage msg, OutputDevice output)
 {
 }
예제 #15
0
        /// <summary>
        /// Process the Note Off message.
        /// </summary>
        /// <param name="message">The note off message.</param>
        public void ProcessMidiMessage(NoteOffMessage message)
        {
            var channel = message.Channel;

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

            NoteOnMessage noteOnMessage = incompleteMessages[channel][message.Pitch];
            if (noteOnMessage == null)
            {
                Trace.TraceWarning("Got note off message but don't have a note on message for channel " + channel.Name() + " and pitch " + message.Pitch.NotePreferringFlats() + ".  Ignoring message.");
                return;
            }

            incompleteMessages[channel][message.Pitch] = null;

            lock (lockObject)
            {
                completedNotes.Add(new Note
                {
                    Channel = channel,
                    StartTime = noteOnMessage.Time,
                    EndTime = message.Time,
                    Pitch = noteOnMessage.Pitch
                });
            }
        }
예제 #16
0
 private void NoteOff(NoteOffMessage msg)
 {
     notesDown.Remove(msg.Pitch);
     try
     {
         operations[msg.Channel].NoteOff(msg, outputDevice);
     }
     catch (KeyNotFoundException) { }
     finally
     {
         Display();
     }
 }