Search code examples
pythonmusic21music-notation

transpose pitch down an octave?


Using music21, how can I transpose a pitch down an octave?

If I use p.transpose(-12), flats get changed to sharps:

import music21
p = music21.pitch.Pitch('D-4')
print(p.transpose(-12))

output

C#3

Solution

  • Instead of -P12, use -P8, like this:

    import music21
    p = music21.pitch.Pitch('D-4')
    print(p.transpose('-P8'))