private static void PlaySonata(Matrix m) { int quarterNoteLength = 250; for (int i = 0; i < 24; i++) { Tone[] tones; if (i == 0) { tones = m.Row(0); } else { tones = RandomSequence(m); } if (i > 7) { quarterNoteLength = 750; } if (i > 11) { quarterNoteLength = 150; } PlayTones(tones, quarterNoteLength); } }
private static void PlayBinarySection(Matrix m, int quarterNoteLength) { for (int i = 0; i < 2; i++) { Tone[] tones; if (i == 0) { tones = m.Row(0); } else { tones = RandomSequence(m); } PlayTones(tones, quarterNoteLength); } foreach (Note n in notesPlayed.SelectMany(nl => nl)) PlayNote(n); notesPlayed.Clear(); Console.WriteLine(""); }
private static Tone[] RandomSequence(Matrix m) { Tone[] tones; var playColumn = rand.Next(0, 2) == 0; var backwards = rand.Next(0, 2) == 0; int index = rand.Next(0, 12); if (playColumn) { tones = m.Column(index).ToArray(); } else { tones = m.Row(index); } if (backwards) { tones = tones.Reverse().ToArray(); } return tones; }