Exemple #1
0
    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)
Exemple #2
0
    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)
Exemple #3
0
    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)
Exemple #4
0
    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)