I'm writing jazz pieces using music21, and then exporting them to MuseScore with stream.show(). Before playing the song, I use the Text palette in MuseScore to add "Swing" over the first note, and then the playback has a swing feel to it. I was wondering if I could add this directly using music21.
Saving the modified musicXML file, I noticed that the first measure contains a block with the information needed for swing style, but I haven't found a mechanism that allows me to add this using music21. Here's what the musicXML file looks like with the needed elements for swing style:
<Measure>
<voice>
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Tempo>
<tempo>2.66667</tempo>
<followText>1</followText>
<text><sym>metNoteHalfUp</sym> = 80</text>
</Tempo>
<SystemText>
<swing unit="eighth" ratio="60"/>
<style>tempo</style>
<text>Swing</text>
</SystemText>