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(); }
public void Play(float signal) { if (instrument != null) { audioSource.volume = signal; instrument.PlayNote(midiNote); } pulsar.GetComponent <ScalePulse>().Pulse(signal); }
public void Play() { if (instrument != null) { LogManager.Log("play " + midiNote); instrument.PlayNote(midiNote); } pulsar.GetComponent <ScalePulse>().Pulse(1.0f); }
// 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); } } }
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); } }