Is there a way to show chord symbols when exporting to a pdf of xml file?
Thanks!
Is there a way to show chord symbols when exporting to a pdf of xml file?
Thanks!
The work around I came up with is exporting the xml in SCAMP using score.export_music_xml(file_path) and then using the music21 library to open the score using converter.parse(file_path) and using a for loop (for measure in score.recurse(classFilter=(āMeasureā)) and measure by measure adding the chords using the harmony.ChordSymbol class and measure.insert(offsetOrItemOrList=current_beat, itemOrNone=chord_symbol).
This way you can add the chords on the beat you need using the āoffsetOrItemOrListā param.
Keep in mind that the ChordSymbol constructor requires the following parameters: harmony.ChordSymbol(root, bass, kind).
You can find more information about the ākindā attribute in the musicxml docs.
Good luck!
Sorry for the lack of response! Iām glad that you found a workaround, and appreciate you sharing it. Iāll think about adding this functionality in the future
Was able to figure it out, thanks frantzes.e for the reply man! Just wanted to share my solution as my situation was a little different and for anyone else curious. I used SCAMP to generate chords per bar and needed a way to both analyze the chords and write them as symbols:
(using music21)
for measure in score.parts[0].getElementsByClass(āMeasureā):
if isinstance(element, chord.Chord):*
element.simplifyEnharmonics(inPlace = True)*
symbol = harmony.chordSymbolFigureFromChord(element)*
chord_symbol = harmony.ChordSymbol(symbol)*
measure.insert(element.offset, chord_symbol)*
This should work with any music xml file containing block chords