最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - transpose pitch down an octave? - Stack Overflow

programmeradmin4浏览0评论

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

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
Share Improve this question asked Feb 17 at 23:21 Jeff LearmanJeff Learman 3,3191 gold badge24 silver badges33 bronze badges 6
  • For most practical purposes, C sharp and D flat are the same note. Probably the printed representation of the note is affected by the key signature. – kindall Commented Feb 17 at 23:29
  • Try -8 instead of -12 – Starship Commented Feb 18 at 0:37
  • @kindall -- a pitch doesn't have a key or key signature, and I couldn't find a way to transpose using a key or key signature (other than perhaps adding the note to a stream and transposing that, and then removing it from the stream and discarding it.) – Jeff Learman Commented 2 days ago
  • @Starship -- when a number is used, it's interpreted as semitones. – Jeff Learman Commented 2 days ago
  • 1 @JeffLearman I meant -P8 (which you also say is what worked for you) – Starship Commented 2 days ago
 |  Show 1 more comment

1 Answer 1

Reset to default 0

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

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

评论列表(0)

  1. 暂无评论