Exemplo n.º 1
0
    def test_scale(self):
        scale = ChromaticScale.get_chromatic_scale(
            ChromaticScale.parse_notation("0:9"),
            ChromaticScale.parse_notation("8:0"))
        start = ChromaticScale.location_to_index((0, 9))
        end = ChromaticScale.location_to_index((8, 0)) + 1

        for i in range(start, end):
            logging.info('{0}{1}   {1}'.format(
                i, ChromaticScale.index_to_location(i), scale[i - start]))

        assert is_close(scale[ChromaticScale.location_to_index((4, 9)) - start], 440.0), \
            "Error A:4 = {0} should be 440.0".format(scale[ChromaticScale.location_to_index((4, 9)) - start])
        assert is_close(scale[ChromaticScale.location_to_index((4, 0)) - start], 261.625565301), \
            "Error C:4 = {0} should be 261.625565301".format(scale[ChromaticScale.location_to_index((4, 0)) - start])
Exemplo n.º 2
0
 def test_book_example(self):
     location = ChromaticScale.parse_notation("4:9")
     print(location)
     index = ChromaticScale.location_to_index(location)
     print(index)
     loc = ChromaticScale.index_to_location(index)
     print(loc)
Exemplo n.º 3
0
 def test_parse_chromatic_location(self):
     for i in range(0, 12):
         s = str(4) + ':' + str(i)
         location = ChromaticScale.parse_notation(s)
         assert location[0] == 4 and location[1] == i