Example #1
0
        public void Play(InstrumentType instrument, MetronomeMark metronomeMark, ChordOffset[] melody)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            for (var strumIndex = 0; strumIndex < melody.Length;)
            {
                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 #2
0
 private static void PrepareNoteOctave(InstrumentType instrument, Note note)
 {
     instrument.GoToOctave(note);
 }
Example #3
0
 private static void PrepareChordsOctave(InstrumentType instrument, Chord chord)
 {
     instrument.GoToOctave(chord.Notes.First());
 }