Key Signature via pymusicxml
Example script (scamp): examples/Notation & engraving/Abjad & pymusicxml tweaks/key_sig.py
Download: key_sig.py
Adds a key signature by exporting through pymusicxml and setting it on the first measure.
Topics: Notation & engraving › Abjad & pymusicxml tweaks
from scamp import *
s = Session(tempo=120)
violin = s.new_part("violin")
s.start_transcribing()
for _ in range(3):
for p in [62, 65, 63, 67, 68, 72, 70]:
violin.play_note(p, 0.7, 0.5, "key: Eb")
pymusicxml_score = s.stop_transcribing().to_score().to_music_xml()
pymusicxml_part = pymusicxml_score.contents[0]
pymusicxml_part.measures[0].key = "Eb"
pymusicxml_score.export_to_file("KeySig.musicxml")