PlayNote() private method

Plays a musical note by adjusting the pitch of a note.
private PlayNote ( int note ) : void
note int Note to play
return void
Example #1
0
 private void Update()
 {
     for (int i = 0; i < keys.Length; i++)
     {
         if (Input.GetKeyDown(keys[i]))
         {
             instrument.PlayNote(i);
             for (int j = 0; j < harmony.Length; j++)
             {
                 instrument.PlayNote(i + harmony[j]);
             }
         }
     }
 }
        public void Play(Instrument instrument, MetronomeMark metronomeMark, ChordOffset[] melody)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            for (var strumIndex = 0; strumIndex < melody.Length;)
            {
                if (this.Abort)
                {
                    return;
                }

                var strum = melody[strumIndex];

                if (stopwatch.ElapsedMilliseconds > metronomeMark.WholeNoteLength.Multiply(strum.Offest).TotalMilliseconds)
                {
                    var chord = strum.Chord;

                    foreach (var note in chord.Notes)
                    {
                        instrument.GoToOctave(note);
                        instrument.PlayNote(note);
                    }

                    strumIndex++;
                }
                else
                {
                    Thread.Sleep(TimeSpan.FromMilliseconds(1));
                }
            }

            stopwatch.Stop();
        }
Example #3
0
 public void Play(float signal)
 {
     if (instrument != null)
     {
         audioSource.volume = signal;
         instrument.PlayNote(midiNote);
     }
     pulsar.GetComponent <ScalePulse>().Pulse(signal);
 }
Example #4
0
 public void Play()
 {
     if (instrument != null)
     {
         LogManager.Log("play " + midiNote);
         instrument.PlayNote(midiNote);
     }
     pulsar.GetComponent <ScalePulse>().Pulse(1.0f);
 }
Example #5
0
 // Update is called once per frame
 void Update()
 {
     for (int i = 0; i < 12; i++)
     {
         if (Input.GetKeyDown(keyMapping [i]))
         {
             instrument.PlayNote(octave * 12 + i);
         }
     }
 }
Example #6
0
        private static void PlayChord(Instrument instrument, Chord chord)
        {
            var notes = chord.Notes.ToArray();

            for (var noteIndex = 0; noteIndex < notes.Length; noteIndex++)
            {
                instrument.PlayNote(notes[noteIndex]);

                if (noteIndex < notes.Length - 1)
                {
                    PrepareNoteOctave(instrument, notes[noteIndex + 1]);
                }
            }
        }
        private void NoteOnHandler(object sender, MouseEventArgs e)
        {
            PictureBox pb       = sender as PictureBox;
            byte       note     = Convert.ToByte(Convert.ToByte(pb.Name.Substring(2)) + 60);
            byte       velocity = 53;

            if (instrument.Engaged == false)
            {
                MessageBox.Show("Please open the device first");
            }
            else
            {
                instrument.PlayNote(note, velocity);
            }
        }