SendNoteOn() public method

Sends a Note On message to this MIDI output device.
channel, pitch, or velocity is /// out-of-range. The device is not open. The message cannot be sent.
public SendNoteOn ( Channel channel, Pitch pitch, int velocity ) : void
channel Channel The channel.
pitch Pitch The pitch.
velocity int The velocity 0..127.
return void
Esempio n. 1
0
 private void ShowColours()
 {
     for (int i = 0; i < 127; i++)
     {
         outputDevice.SendNoteOn(Channel.Channel1, (Pitch)i, i);
     }
 }
Esempio n. 2
0
 protected void NoteOn(Channel channel, Pitch pitch, int velocity)
 {
     if (muted)
     {
         return;
     }
     outputDevice.SendNoteOn(channel, pitch, velocity);
 }
Esempio n. 3
0
 void PlayChordRun(OutputDevice outputDevice, Chord chord, int millisecondsBetween)
 {
     Pitch previousNote = (Pitch)(-1);
     for (Pitch pitch = Pitch.A0; pitch < Pitch.C8; ++pitch)
     {
         if (chord.Contains(pitch))
         {
             if (previousNote != (Pitch)(-1))
             {
                 outputDevice.SendNoteOff(Channel.Channel1, previousNote, 80);
             }
             outputDevice.SendNoteOn(Channel.Channel1, pitch, 80);
             Thread.Sleep(millisecondsBetween);
             previousNote = pitch;
         }
     }
     if (previousNote != (Pitch)(-1))
     {
         outputDevice.SendNoteOff(Channel.Channel1, previousNote, 80);
     }
 }
Esempio n. 4
0
 public static void PlayRunUpKeyboard(OutputDevice outputDevice, Predicate<Note> predicate,
     int millisecondsBetween)
 {
     Note previousNote = (Note)(-1);
     for (Note note = Note.A0; note < Note.C8; ++note)
     {
         if (predicate(note))
         {
             if (previousNote != (Note)(-1))
             {
                 outputDevice.SendNoteOff(Channel.Channel1, previousNote, 80);
             }
             outputDevice.SendNoteOn(Channel.Channel1, note, 80);
             Thread.Sleep(millisecondsBetween);
             previousNote = note;
         }
     }
     if (previousNote != (Note)(-1))
     {
         outputDevice.SendNoteOff(Channel.Channel1, previousNote, 80);
     }
 }
Esempio n. 5
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);
 }
Esempio n. 6
0
        private void btnReceiveOut_Click(object sender, EventArgs e)
        {
            if (listBox2.SelectedItem == null)
            MessageBox.Show("No device selected!");
              else
              {
            outDevice = (OutputDevice)listBox2.SelectedItem;
            outDevice.Open();
            if (comboBox1.SelectedItem != null)
              outDevice.SendNoteOn(Channel.Channel1, (Pitch)comboBox1.SelectedItem, trackBar1.Value);

            outDevice.Close();
              }
        }
Esempio n. 7
0
 public void NoteOff(NoteOffMessage msg, OutputDevice output)
 {
     output.SendNoteOn(msg.Channel, currentNote, 127);
 }
Esempio n. 8
0
        public static void PlayAccord(Note root, Pattern pattern, Direction direction, OutputDevice outputDevice)
        {
            if (pattern == Pattern.Minor)//тоника на 5 струне
            {
                if (direction == Direction.Down)
                {
                    outputDevice.SendNoteOn(Channel.Channel1, root, 80);
                    Thread.Sleep(15);//20
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 7), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12 + 3), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12 + 7), 80);
                }
                else
                {
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12 + 7), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12 + 3), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 7), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, root, 80);
                }
            }
            else //Мажор, тоника на 6 струне
            {
                if (direction == Direction.Down)
                {
                    outputDevice.SendNoteOn(Channel.Channel1, root, 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 7), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12 + 4), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12 + 7), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 24), 80);
                }
                else
                {
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 24), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12 + 7), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12 + 4), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 12), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, (Note)((int)root + 7), 80);
                    Thread.Sleep(15);
                    outputDevice.SendNoteOn(Channel.Channel1, root, 80);
                }
            }

        }
Esempio n. 9
0
        public static string sendMessage(OutputDevice midiDevice, byte[] data)
        {
            int order = data[0];
            string debug;
            switch (order)
            {
                /*NoteOff Channels 1 to 16*/
                case 128:
                    midiDevice.SendNoteOff(Channel.Channel1, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 1";
                    return debug;
                case 129:
                    midiDevice.SendNoteOff(Channel.Channel2, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 2";
                    return debug;
                case 130:
                    midiDevice.SendNoteOff(Channel.Channel3, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 3"; 
                    return debug;
                case 131:
                    midiDevice.SendNoteOff(Channel.Channel4, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 4";
                    return debug;
                case 132:
                    midiDevice.SendNoteOff(Channel.Channel5, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 5"; 
                    return debug;
                case 133:
                    midiDevice.SendNoteOff(Channel.Channel6, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 6"; 
                    return debug;
                case 134:
                    midiDevice.SendNoteOff(Channel.Channel8, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 7"; 
                    return debug;
                case 135:                     
                    midiDevice.SendNoteOff(Channel.Channel8, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 8";
                    return debug;
                case 136:                     
                    midiDevice.SendNoteOff(Channel.Channel9, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 9";
                    return debug;
                case 137:                     
                    midiDevice.SendNoteOff(Channel.Channel10, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 10";
                    return debug;
                case 138:                    
                    midiDevice.SendNoteOff(Channel.Channel11, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 11";
                    return debug;
                case 139:                     
                    midiDevice.SendNoteOff(Channel.Channel2, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 12";
                    return debug;
                case 140:                     
                    midiDevice.SendNoteOff(Channel.Channel13, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 13";
                    return debug;
                case 141:
                    midiDevice.SendNoteOff(Channel.Channel14, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 14";
                    return debug;
                case 142:                     
                    midiDevice.SendNoteOff(Channel.Channel15, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 15";
                    return debug;
                case 143:                     
                    midiDevice.SendNoteOff(Channel.Channel16, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOff Message At Channel 16";
                    return debug;

                /*Note ON Channels 1 to 16*/                    
                case 144:
                    midiDevice.SendNoteOn(Channel.Channel1, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 1";
                    return debug;
                case 145:                     
                    midiDevice.SendNoteOn(Channel.Channel2, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 2";
                    return debug;
                case 146:                     
                    midiDevice.SendNoteOn(Channel.Channel3, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 3";
                    return debug;
                case 147:                     
                    midiDevice.SendNoteOn(Channel.Channel4, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 4";
                    return debug;
                case 148:                     
                    midiDevice.SendNoteOn(Channel.Channel5, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 5";
                    return debug;
                case 149:                     
                    midiDevice.SendNoteOn(Channel.Channel6, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 6";
                    return debug;
                case 150:                     
                    midiDevice.SendNoteOn(Channel.Channel7, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 7";
                    return debug;
                case 151:                     
                    midiDevice.SendNoteOn(Channel.Channel8, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 8";
                    return debug;
                case 152:     
                    midiDevice.SendNoteOn(Channel.Channel9, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 9";
                    return debug;
                case 153:                     
                    midiDevice.SendNoteOn(Channel.Channel10, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 10";
                    return debug;
                case 154:                     
                    midiDevice.SendNoteOn(Channel.Channel11, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 11";
                    return debug;
                case 155:                     
                    midiDevice.SendNoteOn(Channel.Channel12, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 12";
                    return debug;
                case 156:                     
                    midiDevice.SendNoteOn(Channel.Channel13, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 13";
                    return debug;
                case 157:                  
                    midiDevice.SendNoteOn(Channel.Channel14, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 14";
                    return debug;
                case 158:                     
                    midiDevice.SendNoteOn(Channel.Channel15, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 15";
                    return debug;
                case 159:                     
                    midiDevice.SendNoteOn(Channel.Channel16, pitchDetermination.notes(data[1]), data[2]);
                    debug = "Sending NoteOn Message At Channel 16";
                    return debug;
                case 176:
                    midiDevice.SendControlChange(Channel.Channel1, Control.Volume, data[1]);
                    debug = "Sending ControlChange At Channel 1";
                    return debug;
                default:
                     debug = "NO Valido";
                    return debug;
            }
        }