コード例 #1
0
ファイル: test_main.py プロジェクト: Sanseer/Robatim
    def test_chord_pitches(self):
        def check_chord(chord_symbol, chord_pitch_names):
            new_chord = robatim.Chord(chord_symbol, 0)
            pitch_str_sequence = []
            for chord_pitch in new_chord.pitches:
                pitch_str_sequence.append(str(chord_pitch))
            self.assertEqual(chord_pitch_names, pitch_str_sequence)

        robatim.Engraver.scale_obj = robatim.Scale("Bb", "ionian")
        check_chord("I_MAJ", ["Bb", "D", "F"])
        check_chord("V7_MAJ-MIN", ["F", "A", "C", "Eb"])
        check_chord("II6_DIM", ["C", "Eb", "Gb"])
        check_chord("VI_MIN", ["G", "Bb", "D"])

        robatim.Engraver.scale_obj = robatim.Scale("F#", "aeolian")
        check_chord("I_MIN", ["F#", "A", "C#"])
        check_chord("IV6/5_MIN", ["B", "D", "F#", "A"])
        check_chord("bVII_MAJ", ["E", "G#", "B"])
        check_chord("I6/4_MIN", ["F#", "A", "C#"])

        robatim.Engraver.scale_obj = robatim.Scale()
        check_chord("I7_MAJ", ["C", "E", "G", "B"])
        check_chord("#IV6_DIM", ["F#", "A", "C"])
        check_chord("bIII_AUG", ["Eb", "G", "B"])
        check_chord("VII7_HALF-DIM", ["B", "D", "F", "A"])
コード例 #2
0
ファイル: test_main.py プロジェクト: Sanseer/Robatim
    def test_scalar_shift(self):

        robatim.Engraver.scale_obj = robatim.Scale("G", "lydian")
        starting_note = robatim.Note("G4")
        self.assertEqual(str(starting_note.scalar_shift(1)), "A4")
        self.assertEqual(str(starting_note.scalar_shift(-1)), "F#4")
        self.assertEqual(str(starting_note.scalar_shift(9)), "B5")
        self.assertEqual(str(starting_note.scalar_shift(-11)), "C#3")

        robatim.Engraver.scale_obj = robatim.Scale("F", "phrygian")
        starting_note = robatim.Note("F3")
        self.assertEqual(str(starting_note.scalar_shift(5)), "Db4")
        self.assertEqual(str(starting_note.scalar_shift(0)), "F3")
        self.assertEqual(str(starting_note.scalar_shift(-5)), "Ab2")
        self.assertEqual(str(starting_note.scalar_shift(14)), "F5")
コード例 #3
0
ファイル: test_main.py プロジェクト: Sanseer/Robatim
    def test_relative_degree(self):
        chosen_scale_obj = robatim.Engraver.scale_obj = robatim.Scale("Ab")
        starting_note = robatim.Note("Ab4")

        chosen_note = robatim.Note("Ab4")
        self.assertEqual(
            chosen_scale_obj.get_relative_degree(starting_note, chosen_note),
            0)
        chosen_note = robatim.Note("B3")
        self.assertEqual(
            chosen_scale_obj.get_relative_degree(starting_note, chosen_note),
            -6)
        chosen_note = robatim.Note("F####4")
        self.assertEqual(
            chosen_scale_obj.get_relative_degree(starting_note, chosen_note),
            -2)
        chosen_note = robatim.Note("Eb2")
        self.assertEqual(
            chosen_scale_obj.get_relative_degree(starting_note, chosen_note),
            -17)

        chosen_note = robatim.Note("C5")
        self.assertEqual(
            chosen_scale_obj.get_relative_degree(starting_note, chosen_note),
            2)
        chosen_note = robatim.Note("G#6")
        self.assertEqual(
            chosen_scale_obj.get_relative_degree(starting_note, chosen_note),
            13)
        chosen_note = robatim.Note("Db5")
        self.assertEqual(
            chosen_scale_obj.get_relative_degree(starting_note, chosen_note),
            3)
コード例 #4
0
ファイル: test_main.py プロジェクト: Sanseer/Robatim
    def test_scale_degrees(self):

        chosen_scale_obj = robatim.Engraver.scale_obj = robatim.Scale("Ab")
        chosen_note = robatim.Note("Bb3")
        self.assertEqual(chosen_scale_obj.get_absolute_degree(chosen_note), 1)
        chosen_note = robatim.Note("F4")
        self.assertEqual(chosen_scale_obj.get_absolute_degree(chosen_note), 5)
        chosen_note = robatim.Note("Eb2")
        self.assertEqual(chosen_scale_obj.get_absolute_degree(chosen_note), 4)
コード例 #5
0
ファイル: test_main.py プロジェクト: Sanseer/Robatim
    def test_scale_pitches(self):
        def analyze_scale_members(chosen_scale_obj, scale_sequence):
            for scale_pitch in chosen_scale_obj.scale_pitches_seq:
                self.assertIn(str(scale_pitch), scale_sequence)

        scale_members = {
            ("G", "ionian"): ("G", "A", "B", "C", "D", "E", "F#"),
            ("C", "aeolian"): ("C", "D", "Eb", "F", "G", "Ab", "Bb"),
            ("D", "dorian"): ("D", "E", "F", "G", "A", "B", "C"),
            ("G#", "ionian"): ("G#", "A#", "B#", "C#", "D#", "E#", "F##"),
        }
        for scale_parameters, scale_sequence in scale_members.items():
            analyze_scale_members(robatim.Scale(*scale_parameters),
                                  scale_sequence)