Chord Symbols?

Is there a way to show chord symbols when exporting to a pdf of xml file?

Thanks!

1 Like

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ā€™)):slight_smile: 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!

2 Likes

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

1 Like

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ā€™):

  • for element in 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 :slight_smile: