def test2(harm): # F Major F = Chord("F", None, 0, "F") A7 = Chord("A", ["7"], 1, "A") dmin = Chord("D", ["min"], 2, "D") F_C = Chord("F", None, 3, "C") C7 = Chord("C", ["7"], 4, "C") dmin2 = Chord("D", ["min"], 5, "D") F_C2 = Chord("F", None, 6, "C") Bb = Chord("Bb", None, 7, "Bb") gmin7 = Chord("G", ["min", "7"], 8, "Bb") C72 = Chord("C", ["7"], 9, "C") F_end = Chord("F", None, 10, "F") addHarmony(harm, F, "I") addHarmony(harm, A7, "V7/vi") addHarmony(harm, dmin, "vi") addHarmony(harm, F_C, "I64") addHarmony(harm, C7, "V7") addHarmony(harm, dmin2, "vi") addHarmony(harm, F_C2, "I64") addHarmony(harm, Bb, "IV") addHarmony(harm, gmin7, "ii65") addHarmony(harm, C72, "V7") addHarmony(harm, F_end, "I") addHarmonyRules(harm) run_test(harm)
def simplestTest(harm): G7 = Chord("G", ["7"], 0, "G") C = Chord("C", None, 1, "C") addHarmony(harm, G7, "V7") addHarmony(harm, C, "I") addHarmonyRules(harm) run_test(harm)
def testOne(self): core.config.chords = TimeList() core.config.harmonies = TimeList() harm = createProblem() addHarmony(harm, Chord("C", None, 0), "I") addHarmonyRules(harm) solutions = solveProblem(harm) self.assertEqual(len(solutions), 42)
def test3(harm): addHarmony(harm, Chord("F", None, 0, "F"), "I") addHarmony(harm, Chord("A", ["7"], 1, "G"), "V42/vi") addHarmony(harm, Chord("D", ["min", "7"], 2, "F"), "vi65") addHarmony(harm, Chord("C", ["7"], 3, "E"), "V65") addHarmony(harm, Chord("F", None, 4, "F"), "I") addHarmonyRules(harm) run_test(harm)
def test10_stricter(harm): counter = 0 for i in range(2): addHarmony(harm, Chord("A", ["min"], counter, "C"), "ii") addHarmony(harm, Chord("D", ["7"], counter + 1, "D"), "V7") addHarmony(harm, Chord("G", None, counter + 2, "G"), "I") counter += 3 addHarmonyRules(harm) run_test(harm)
def simpleTest(harm): dmin = Chord("D", ["min"], 0, "F") G = Chord("G", ["7"], 1, "G") C = Chord("C", None, 2, "C") addHarmony(harm, dmin, "ii6") addHarmony(harm, G, "V7") addHarmony(harm, C, "I") addHarmonyRules(harm) run_test(harm)
def test10_n(harm, n): counter = 0 for i in range(n): addHarmony(harm, Chord("A", ["min"], counter), "ii") addHarmony(harm, Chord("D", ["7"], counter + 1), "V7") addHarmony(harm, Chord("G", None, counter + 2), "I") counter += 3 addHarmonyRules(harm) run_test(harm)
def test8(harm): addHarmony(harm, Chord("A", None, 0), "I") addHarmony(harm, Chord("F#", ["min"], 1), "vi") addHarmony(harm, Chord("E", None, 2), "V") addHarmony(harm, Chord("A", None, 3), "I") addHarmonyRules(harm) A5 = core.Note.pitchToNum_absolute("A5") soprano_notes = [A5 + 4, A5, A5 + 2, A5] specify_voice(harm, "s", soprano_notes) run_test(harm)
def testDiminished(self): core.config.chords = TimeList() core.config.harmonies = TimeList() harm = createProblem() gsharpdim7 = Chord("G#", ["dim7"], 0, "G#") addHarmony(harm, gsharpdim7, "vii7") addHarmonyRules(harm) solutions = solveProblem(harm) firstSolution = solutions[0][1] firstSolution = [x[1] for x in firstSolution] self.assertTrue(self.solutionHasNotes(firstSolution, ["G#", "B", "D", "F"]))
def test5(harm): addHarmony(harm, Chord("C", None, 0, "C"), "I") addHarmony(harm, Chord("G", None, 1, "G"), "V") addHarmony(harm, Chord("A", ["min"], 2, "A"), "vi") addHarmony(harm, Chord("E", ["min"], 3, "E"), "iii") addHarmony(harm, Chord("F", None, 4, "F"), "IV") addHarmony(harm, Chord("C", None, 5, "C"), "I") addHarmony(harm, Chord("D", ["min"], 6, "D"), "ii") addHarmony(harm, Chord("G", None, 7, "G"), "V") addHarmony(harm, Chord("C", None, 8, "C"), "I") addHarmonyRules(harm) run_test(harm)
def sequenceTest(harm): emin = Chord("E", ["min"], 0, "E") A7 = Chord("A", ["7"], 1, "E") dmin = Chord("D", ["min"], 2, "D") G7 = Chord("G", ["7"], 3, "D") C = Chord("C", None, 4, "C") addHarmony(harm, emin, "iii") addHarmony(harm, A7, "V43/ii") addHarmony(harm, dmin, "ii") addHarmony(harm, G7, "V43") addHarmony(harm, C, "I") addHarmonyRules(harm) run_test(harm)
def test4(harm): # D: ii6, V, I, V42/IV, IV6, iv6, V64, V7, I addHarmony(harm, Chord("E", ["min"], 0, "G"), "ii6") addHarmony(harm, Chord("A", None, 1, "A"), "V") addHarmony(harm, Chord("D", None, 2, "D"), "I") addHarmony(harm, Chord("D", ["7"], 3, "C"), "V42/IV") addHarmony(harm, Chord("G", None, 4, "B"), "IV6") addHarmony(harm, Chord("G", ["min"], 5, "Bb"), "iv6") addHarmony(harm, Chord("D", None, 6, "A"), "I64") addHarmony(harm, Chord("A", ["7"], 7, "A"), "V7") addHarmony(harm, Chord("D", None, 8, "D"), "I") addHarmonyRules(harm) run_test(harm)
def test6(harm): addHarmony(harm, Chord("Db", None, 0, "Db"), "I") addHarmony(harm, Chord("Db", ["7"], 1, "Cb"), "V42/IV") addHarmony(harm, Chord("Gb", None, 2, "Bb"), "IV6") addHarmony(harm, Chord("Db", None, 3, "Ab"), "I64") addHarmony(harm, Chord("Ab", ["7"], 4, "Ab"), "V7") addHarmony(harm, Chord("Bb", ["min"], 5, "Bb"), "vi") addHarmony(harm, Chord("Eb", ["7"], 6, "Db"), "V42/V") addHarmony(harm, Chord("Ab", None, 7, "C"), "V6") addHarmony(harm, Chord("Db", None, 8, "Db"), "I") addHarmony(harm, Chord("Ab", None, 9, "Eb"), "V64") addHarmony(harm, Chord("Db", None, 10, "F"), "I6") addHarmony(harm, Chord("Ab", None, 11, "Eb"), "V64") addHarmony(harm, Chord("Db", None, 12, "Db"), "I") addHarmonyRules(harm) run_test(harm)
def testSequence(self): core.config.chords = TimeList() core.config.harmonies = TimeList() harm = createProblem() emin = Chord("E", ["min"], 0, "E") A7 = Chord("A", ["7"], 1, "E") dmin = Chord("D", ["min"], 2, "D") G7 = Chord("G", ["7"], 3, "D") C = Chord("C", None, 4, "C") addHarmony(harm, emin, "iii") addHarmony(harm, A7, "V43/ii") addHarmony(harm, dmin, "ii") addHarmony(harm, G7, "V43") addHarmony(harm, C, "I") addHarmonyRules(harm) solutions = solveProblem(harm) self.assertEqual(len(solutions), 128)
def twoTest(harm): addHarmony(harm, Chord("C", None, 0), "I") addHarmony(harm, Chord("G", None, 1), "V") addHarmonyRules(harm) run_test(harm)
def oneTest(harm): C = Chord("C", None, 0) addHarmony(harm, C, "I") addHarmonyRules(harm) run_test(harm)
def test7(harm): addHarmony(harm, Chord("Db", None, 0, "Db"), "I") addHarmony(harm, Chord("Db", ["7"], 1, "Cb"), "V42/IV") addHarmony(harm, Chord("Gb", None, 2, "Bb"), "IV6") addHarmonyRules(harm) run_test(harm)
def t2(harm): addHarmony(harm, Chord("G", ["7"], 0, "G"), "V") addHarmonyRules(harm) run_test(harm)
def t1(harm): addHarmony(harm, Chord("D", ["min"], 0, "F"), "ii6") addHarmonyRules(harm) run_test(harm)
def test9_stricter(harm): for i in range(5): addHarmony(harm, Chord("G", None, i, "G"), "I") addHarmonyRules(harm) run_test(harm)
def test9(harm): for i in range(8): addHarmony(harm, Chord("G", None, i), "I") addHarmonyRules(harm) run_test(harm)