Code to transpose a measure a half step up to B then back down

39 views
Skip to first unread message

Carl Konopka

unread,
Mar 1, 2024, 7:04:52 AMMar 1
to music21
I have a measure of music in a mxl file where I want to create 23 measures transposed from C to B by a half step each up and then back down a half step for 23 measures in total.

I'm trying to use chatgpt to write the code, but it can't seem to create the bass stave.

I'm thinking it would be easy.

Could anyone help me out and write the code for me?

Thanks
philipp_for_chatgpt.mxl

mrhg...@gmail.com

unread,
May 10, 2024, 10:18:22 AMMay 10
to music21
Here you go:

from music21 import converter
s = converter.parse("tinyNotation: 4/4 c1 c# d d# e f f# g g# a a# b b- a a- g g f e e- d d- c")
s.write("mxl", "./test.mxl")

mrhg...@gmail.com

unread,
May 10, 2024, 10:19:20 AMMay 10
to music21
Oops with that last `g` as `g-`.

... less haste more speed ... 

mrhg...@gmail.com

unread,
May 10, 2024, 10:21:05 AMMay 10
to music21
Oh and you mention bass clef. In that case just use the lower octave with upper case
... yes, that way around ;) ...
"tinyNotation: 4/4 C1 C# D D# E F F# G G# A A# B B- A A- G G- F E E- D D- C "

Reply all
Reply to author
Forward
0 new messages