コード例 #1
0
ファイル: test_jam.py プロジェクト: jcdecho/solo_splicer
    def test_min_vector_tones_match(self):
        chord_info = ChordInfo("CM7")
        print chord_info.chord_info
        assert( chord_info.chord_info['note_base_offsets'] == (0, 4, 7, 11))
        assert( chord_info.chord_info['note_ints_raw'] == (0, 4, 7, 11))
        assert( chord_info.chord_info['note_ints'] == (0, 4, 7, 11))
        
        tone_vector = [0.9] * 12
        tone_vector[1] = 0.6  # good
        tone_vector[5] = 0.5  # good
        tone_vector[8] = 0.4  # good
        tone_vector[10] = 0.3 # good
        (score0, raw_score0) = chord_info.match_tone_vector_min_vector_tones_OLD(
            tone_vector, count=4)
        print "score0: %s  raw_score0: %s" % (score0, raw_score0)
        self.assertEqual(raw_score0, 1.875)
        # 1.875 is potential raw score if all 4 tones are not in chord
        self.assertEqual(score0, 1)

        tone_vector = [0.9] * 12
        tone_vector[0] = 0.6  # bad
        tone_vector[4] = 0.5  # bad
        tone_vector[8] = 0.4  # good
        tone_vector[10] = 0.3 # good
        (score0, raw_score0) = chord_info.match_tone_vector_min_vector_tones_OLD(
            tone_vector, count=4)
        print "score0: %s  raw_score0: %s" % (score0, raw_score0)
        self.assertEqual(raw_score0, 1.5)
        # 1.875 is potential raw score if all 4 tones are not in chord
        self.assertEqual(score0, 1.5 / 1.875)
コード例 #2
0
ファイル: test_jam.py プロジェクト: jcdecho/solo_splicer
    def test_match_tone_vector_delta_average(self):
        """Compare each vector value with the average, score accordingly
        - Raw scores, per value:
          - If below average, and chord tone, 1
          - If above average, and non-chord tone, 1
          - else 0
        - Sum and divide by 12 for total score.
        """
        chord_info = ChordInfo("CM7")
        print chord_info.chord_info
        assert( chord_info.chord_info['note_base_offsets'] == (0, 4, 7, 11))
        assert( chord_info.chord_info['note_ints_raw'] == (0, 4, 7, 11))
        assert( chord_info.chord_info['note_ints'] == (0, 4, 7, 11))

        # Average is 0.5
        tone_vector = [0.5] * 12
        tone_vector[0] = 0.6  # good
        tone_vector[4] = 0.8  # good
        tone_vector[7] = 0.9  # good
        tone_vector[11] = 0.55 # good
        tone_vector[1] = 0.4
        tone_vector[5] = 0.2
        tone_vector[8] = 0.15
        tone_vector[10] = 0.45

        (score0, raw_score0) = chord_info.match_tone_vector_delta_average(
            tone_vector)

        print "score0: %s  raw_score0: %s" % (score0, raw_score0)
        self.assertEqual(raw_score0, 12)
        # 1.875 is potential raw score if all 4 tones are not in chord
        self.assertEqual(score0, 1)
コード例 #3
0
ファイル: test_jam.py プロジェクト: jcdecho/solo_splicer
    def test_max_vector_tones_match(self):
        """For 4 chord tones
        - match returns (score, raw_score)
        - raw_score is any combination of 1, 0.5, 0.25, 0.125
        """
        chord_info = ChordInfo("CM7")
        print chord_info.chord_info
        assert( chord_info.chord_info['note_base_offsets'] == (0, 4, 7, 11))
        assert( chord_info.chord_info['note_ints_raw'] == (0, 4, 7, 11))
        assert( chord_info.chord_info['note_ints'] == (0, 4, 7, 11))

        score0, _ = chord_info.match_tone_vector_max_vector_tones_OLD(
            [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1], count=4)
        print "score0: %s" % score0
        self.assertEqual(score0, 1)

        score1, _ = chord_info.match_tone_vector_max_vector_tones_OLD(
            [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1], count=4)

        score2, _ = chord_info.match_tone_vector_max_vector_tones_OLD(
            [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1], count=4)

        score3, _ = chord_info.match_tone_vector_max_vector_tones_OLD(
            [0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0], count=4)

        self.assertGreater(score0, score1)
        self.assertGreater(score1, score2)
        self.assertGreater(score2, score3)
コード例 #4
0
ファイル: test_jam.py プロジェクト: jcdecho/solo_splicer
    def test_min_max_vector_tones_min_good_ZZZ(self):
        # indexes are min indexes
        # it's good if they match chord anti-tones.
        # - returns (score, raw_score)
        # - score is normalized to 0-1.
        # - raw_score is any combination of 1, 0.5, 0.25, 0.125
        chord_info = ChordInfo("CM7")
        print chord_info.chord_info
        assert( chord_info.chord_info['anti_note_offsets'] == (1, 3, 10))
        assert( chord_info.chord_info['anti_note_ints_raw'] == (1, 3, 10))
        assert( chord_info.chord_info['anti_note_ints'] == (1, 3, 10))
        
        tone_vector = [0.9] * 12
        tone_vector[1] = 0.5  # good
        tone_vector[3] = 0.4  # good
        tone_vector[10] = 0.3  # good

        score, raw_score = chord_info.match_tone_vector_min_max_vector_tones_2(
            tone_vector = tone_vector,
            indexes = chord_info.chord_info['anti_note_ints'],
            min_max = 'min',
            in_is_good = True,
            count=len(chord_info.chord_info['anti_note_ints']))
        print "score: %s  raw_score: %s" % (score, raw_score)
        self.assertEqual(raw_score, 1.75)
        # 1.75 is potential raw score if all 3 tones are in the anti-tones
        self.assertEqual(score, 1)


        tone_vector = [0.9] * 12
        tone_vector[0] = 0.2  # bad
        tone_vector[3] = 0.3  # good
        tone_vector[9] = 0.6  # bad
        # (score0, raw_score0) = chord_info.match_tone_vector_min_vector_tones(
        #     tone_vector, count=4)

        score, raw_score = chord_info.match_tone_vector_min_max_vector_tones_2(
            tone_vector = tone_vector,
            indexes = chord_info.chord_info['anti_note_ints'],
            min_max = 'min',
            in_is_good = True,
            count=len(chord_info.chord_info['anti_note_ints']))

        print "score: %s  raw_score: %s" % (score, raw_score)
        self.assertEqual(raw_score, 0.5)
        # 1.875 is potential raw score if all 4 tones are not in chord
        self.assertEqual(score, 0.5 / 1.75)
コード例 #5
0
ファイル: test_jam.py プロジェクト: jcdecho/solo_splicer
    def test_min_max_vector_tones_min_bad(self):
        # indexes are min indexes
        # it's bad if they match chord tones.
        # - returns (score, raw_score)
        # - score is normalized to 0-1.
        # - raw_score is any combination of 1, 0.5, 0.25, 0.125
        chord_info = ChordInfo("CM7")
        print chord_info.chord_info
        assert( chord_info.chord_info['note_base_offsets'] == (0, 4, 7, 11))
        assert( chord_info.chord_info['note_ints_raw'] == (0, 4, 7, 11))
        assert( chord_info.chord_info['note_ints'] == (0, 4, 7, 11))
        
        tone_vector = [0.9] * 12
        tone_vector[1] = 0.6  # good
        tone_vector[5] = 0.5  # good
        tone_vector[8] = 0.4  # good
        tone_vector[10] = 0.3 # good

        score, raw_score = chord_info.match_tone_vector_min_max_vector_tones_2(
            tone_vector = tone_vector,
            indexes = chord_info.note_ints,
            min_max = 'min',
            in_is_good = False,
            count=len(chord_info.note_ints))
        print "score: %s  raw_score: %s" % (score, raw_score)
        self.assertEqual(raw_score, 1.875)
        # 1.875 is potential raw score if all 4 tones are not in chord
        self.assertEqual(score, 1)


        tone_vector = [0.9] * 12
        tone_vector[0] = 0.6  # bad
        tone_vector[4] = 0.5  # bad
        tone_vector[8] = 0.4  # good
        tone_vector[10] = 0.3 # good

        score, raw_score = chord_info.match_tone_vector_min_max_vector_tones_2(
            tone_vector = tone_vector,
            indexes = chord_info.note_ints,
            min_max = 'min',
            in_is_good = False,
            count=len(chord_info.note_ints))

        print "score: %s  raw_score: %s" % (score, raw_score)
        self.assertEqual(raw_score, 1.5)
        # 1.875 is potential raw score if all 4 tones are not in chord
        self.assertEqual(score, 1.5 / 1.875)
コード例 #6
0
ファイル: test_jam.py プロジェクト: jcdecho/solo_splicer
    def test_min_max_vector_tones_max_good(self):
        # indexes are max indexes
        # it's good if they match chord tones.
        # - returns (score, raw_score)
        # - score is normalized to 0-1.
        # - raw_score is any combination of 1, 0.5, 0.25, 0.125

        chord_info = ChordInfo("CM7")
        print chord_info.chord_info
        assert( chord_info.chord_info['note_base_offsets'] == (0, 4, 7, 11))
        assert( chord_info.chord_info['note_ints_raw'] == (0, 4, 7, 11))
        assert( chord_info.chord_info['note_ints'] == (0, 4, 7, 11))

        score0, _ = chord_info.match_tone_vector_min_max_vector_tones_2(
            tone_vector = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1],
            indexes = chord_info.note_ints,
            min_max = 'max',
            in_is_good = True,
            count=len(chord_info.note_ints))

        score1, _ = chord_info.match_tone_vector_min_max_vector_tones_2(
            tone_vector = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1],
            indexes = chord_info.note_ints,
            min_max = 'max',
            in_is_good = True,
            count=len(chord_info.note_ints))

        score2, _ = chord_info.match_tone_vector_min_max_vector_tones_2(
            tone_vector = [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1],
            indexes = chord_info.note_ints,
            min_max = 'max',
            in_is_good = True,
            count=len(chord_info.note_ints))

        score3, _ = chord_info.match_tone_vector_min_max_vector_tones_2(
            tone_vector = [0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0],
            indexes = chord_info.note_ints,
            min_max = 'max',
            in_is_good = True,
            count=len(chord_info.note_ints))

        self.assertGreater(score0, score1)
        self.assertGreater(score1, score2)
        self.assertGreater(score2, score3)
コード例 #7
0
ファイル: test_jam.py プロジェクト: jcdecho/solo_splicer
    def test_min_max_vector_tones_max_bad_ZZZ(self):
        # indexes are max indexes
        # it's bad if they match chord anti-tones.
        # - returns (score, raw_score)
        # - score is normalized to 0-1.
        # - raw_score is any combination of 1, 0.5, 0.25
        # Here, scores should be getting increasingly good.

        chord_info = ChordInfo("CM7")
        print chord_info.chord_info
        assert( chord_info.chord_info['anti_note_offsets'] == (1, 3, 10))
        assert( chord_info.chord_info['anti_note_ints_raw'] == (1, 3, 10))
        assert( chord_info.chord_info['anti_note_ints'] == (1, 3, 10))

        # score0, _ = chord_info.match_tone_vector_max_vector_tones(
        #     [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1], count=4)
        score0, _ = chord_info.match_tone_vector_min_max_vector_tones_2(
            tone_vector = [0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0],
            indexes = chord_info.chord_info['anti_note_ints'],
            min_max = 'max',
            in_is_good = False,
            count=len(chord_info.chord_info['anti_note_ints']))

        # score1, _ = chord_info.match_tone_vector_max_vector_tones(
        #     [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1], count=4)
        score1, _ = chord_info.match_tone_vector_min_max_vector_tones_2(
            tone_vector = [1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0],
            indexes = chord_info.chord_info['anti_note_ints'],
            min_max = 'max',
            in_is_good = False,
            count=len(chord_info.chord_info['anti_note_ints']))

        # score2, _ = chord_info.match_tone_vector_max_vector_tones(
        #     [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1], count=4)
        score2, _ = chord_info.match_tone_vector_min_max_vector_tones_2(
            tone_vector = [1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0],
            indexes = chord_info.chord_info['anti_note_ints'],
            min_max = 'max',
            in_is_good = False,
            count=len(chord_info.chord_info['anti_note_ints']))

        self.assertLess(score0, score1)
        self.assertLess(score1, score2)
コード例 #8
0
ファイル: test_jam.py プロジェクト: jcdecho/solo_splicer
 def test_indexes_of_min_n(self):
     chord_info = ChordInfo("CM7")
     res = chord_info.indexes_of_min_n(
         [0.2, 0.3, 0.9, 0.9, 0.8, 0.9, 0.1, 0.2, 0.3, 5, 5, 1], count=4)
     print "res: %s" % res
     self.assertEqual(res, [6, 0, 7, 1])
コード例 #9
0
ファイル: test_jam.py プロジェクト: jcdecho/solo_splicer
 def test_indexes_of_max_n(self):
     chord_info = ChordInfo("CM7")
     res = chord_info.indexes_of_max_n(
         [4, 0, 0, 0, 8, 9, 0, 2, 0, 0, 0, 1], count=4)
     print "res: %s" % res
     self.assertEqual(res, [5, 4, 0, 7])