def get_chord_prog(bs, transpose=0): """コード進行取得、移調する(オプション)""" cp = ChordProgression([ elem.text.replace('♭', 'b').replace('maj', 'M') for elem in bs.select('span ruby rt') if elem.text not in ('N.C', 'N.C.') ]) cp.transpose(transpose) return ' '.join([str(c) for c in cp])
def chord_transpose(chords, step): """Function that tranposes the chords by specified step amount Args: chords (list): List of chords to transpose step (int): The number of steps to transpose up (positive integer) or down (negative integer) Returns: list: tuple containing list of original chords and list of transposed chords """ original_chords = ChordProgression(chords) transposed_chords = ChordProgression(chords) transposed_chords.transpose(step) return original_chords, transposed_chords
def test_transpose(self): cp = ChordProgression(["C", "F", "G"]) cp.transpose(3) self.assertEqual(cp.chords, [Chord("Eb"), Chord("Ab"), Chord("Bb")])