public void GetAlphabetsWithLikelihoodsTest2() { Workspace workspace = new Workspace(-1, false, -1); // TODO: Initialize to an appropriate value int upbeatOffset; Key key; List <Measure> measures = Rhythm.ParseRhythmMeasures(workspace, "HG QF# QB | QC ED EC QB QG", out upbeatOffset, out key); workspace.Key = key; Group target = new Group(workspace, measures[0], measures[1]); List <Tuple <Alphabet, float> > actual; actual = target.GetAlphabetsWithLikelihoods(); Alphabet argmax = FindBestAlphabet(actual); Assert.AreEqual("C Major:G triad", argmax.Name); Assert.AreEqual(5, argmax.RootScaleDegree.Number); Assert.AreEqual(Alteration.None, argmax.RootScaleDegree.Alteration); Assert.AreEqual(7, argmax.RootPitchClass); }
public void TestParseMeasuresKey() { int upbeatOffset; Key key; Workspace w = new Workspace(-1, false, -1); List <Measure> measures = Rhythm.ParseRhythmMeasures(w, "C: QC QC QC QC", out upbeatOffset, out key); Assert.AreEqual(0, key.Fifths); Assert.AreEqual(KeyMode.Major, key.Mode); measures = Rhythm.ParseRhythmMeasures(w, "Cm: QC QC QC QC", out upbeatOffset, out key); Assert.AreEqual(0, key.Fifths); Assert.AreEqual(KeyMode.Minor, key.Mode); measures = Rhythm.ParseRhythmMeasures(w, "C#: QC QC QC QC", out upbeatOffset, out key); Assert.AreEqual(7, key.Fifths); Assert.AreEqual(KeyMode.Major, key.Mode); measures = Rhythm.ParseRhythmMeasures(w, "Bbm: QC QC QC QC", out upbeatOffset, out key); Assert.AreEqual(-2, key.Fifths); Assert.AreEqual(KeyMode.Minor, key.Mode); }
public void TestParseMeasures() { int upbeatOffset; Key key; Workspace w = new Workspace(-1, false, -1); List <Measure> measures = Rhythm.ParseRhythmMeasures(w, "Q | QQQ_ | QQQ | H_E.S", out upbeatOffset, out key); Assert.AreEqual(0, key.Fifths); Assert.AreEqual(KeyMode.Major, key.Mode); Assert.AreEqual(4, measures.Count); Assert.AreEqual(4, upbeatOffset); Measure m0 = measures[0]; Measure m1 = measures[1]; Measure m2 = measures[2]; Measure m3 = measures[3]; Assert.AreEqual(4, m0.MeasureDuration); Assert.AreEqual(12, m1.MeasureDuration); Assert.AreEqual(12, m2.MeasureDuration); Assert.AreEqual(12, m3.MeasureDuration); Assert.AreEqual(1, m0.rhythm.AttackPoints.Count); Assert.AreEqual(3, m1.rhythm.AttackPoints.Count); Assert.AreEqual(2, m2.rhythm.AttackPoints.Count); Assert.AreEqual(4, m2.rhythm.AttackPoints[0]); Assert.AreEqual(8, m2.rhythm.AttackPoints[1]); Assert.AreEqual(2, m3.rhythm.AttackPoints.Count); Assert.AreEqual(0, m3.rhythm.AttackPoints[0]); Assert.AreEqual(11, m3.rhythm.AttackPoints[1]); Assert.AreEqual(4, m0.rhythm.GetDurationIncludingTiesAfterByAttackPoint(m0.rhythm.AttackPoints[0])); Assert.AreEqual(4, m1.rhythm.GetDurationIncludingTiesAfterByAttackPoint(m1.rhythm.AttackPoints[0])); Assert.AreEqual(4, m1.rhythm.GetDurationIncludingTiesAfterByAttackPoint(m1.rhythm.AttackPoints[1])); Assert.AreEqual(8, m1.rhythm.GetDurationIncludingTiesAfterByAttackPoint(m1.rhythm.AttackPoints[2])); Assert.AreEqual(4, m2.rhythm.GetDurationIncludingTiesAfterByAttackPoint(m2.rhythm.AttackPoints[0])); Assert.AreEqual(4, m2.rhythm.GetDurationIncludingTiesAfterByAttackPoint(m2.rhythm.AttackPoints[1])); Assert.AreEqual(11, m3.rhythm.GetDurationIncludingTiesAfterByAttackPoint(m3.rhythm.AttackPoints[0])); Assert.AreEqual(1, m3.rhythm.GetDurationIncludingTiesAfterByAttackPoint(m3.rhythm.AttackPoints[1])); }
public void TestShiftRhythmMeasures() { int upbeatOffset; Key key; Workspace w = new Workspace(-1, false, -1); List <Measure> measures = Rhythm.ParseRhythmMeasures(w, "Q | QQQ_ | QQQ | H_E.S", out upbeatOffset, out key); Assert.AreEqual(4, upbeatOffset); List <Measure> expected = Rhythm.ParseRhythmMeasures(w, "QQQ | HQ | QH_ | E.S ", out upbeatOffset, out key); List <Measure> shifted = Rhythm.ShiftRhythmMeasures(w, measures, 4); Assert.AreEqual(0, upbeatOffset); AssertMeasureListsEqual(expected, shifted); measures = Rhythm.ParseRhythmMeasures(w, "H | QQQQ | HQQ_ | QQH_ | W_ | H", out upbeatOffset, out key); Assert.AreEqual(8, upbeatOffset); expected = Rhythm.ParseRhythmMeasures(w, "HQQ | QQH | QHQ | W_ | W", out upbeatOffset, out key); Assert.AreEqual(0, upbeatOffset); shifted = Rhythm.ShiftRhythmMeasures(w, measures, 8); AssertMeasureListsEqual(expected, shifted); }