Spanners
Example script (scamp): examples/Tutorial/29_spanners.py
Download: 29_spanners.py
Demonstration of starting and stopping various spanners, such as slurs, hairpins, trills, brackets, and pedal lines. Note that there is some finickiness with both lilypond and MusicXML output. LilyPond does not allow multiple of the same spanner at the same time (at least in the same voice), whereas MusicXML does. If exporting to MusicXML, you can keep the spanners straight by providing a label. On the other hand, implementations of MusicXML in many notation programs mangle spanner input. So there’s that.
Topics: Notation & engraving › Special notations
from scamp import *
s = Session()
violin = s.new_part("Violin")
piano = s.new_part("Piano")
s.start_transcribing()
def violin_part():
# the easiest way to create spanners is with string shorthand: start/stop + the spanner type + addition attributes
# Note: abjad/lilypond only allows two levels of slur: regular slurs and phrasing slurs. MusicXML allows more.
# In order to clarify which spanner you're refering to when there are multiple of the same type, you can give
# the spanner a label starting with a hash, like this: "start slur #1" or "start hairpin > #HARRY"
violin.play_note(61, 0.7, 1/3, "start slur, start phrasing slur, start bracket dashed 'intensely'")
violin.play_note(62, 0.7, 1/3)
violin.play_note(64, 0.7, 1/3, "stop slur")
# you can also pass a spanner start or stop object directly
violin.play_note(61, 0.7, 1/3, StartSlur())
violin.play_note(62, 0.7, 1/3)
violin.play_note(64, 0.7, 1/3, StopSlur())
# hairpin types can be ">" "<", as well as ">o" "o<" for niente hairpins
violin.play_note(65, 0.7, 1/3, "start slur, start hairpin <")
violin.play_note(64, 0.7, 1/3)
violin.play_note(62, 0.7, 1/3, "stop slur")
violin.play_note(65, 0.7, 1/3, "start slur")
violin.play_note(64, 0.7, 1/3)
violin.play_note(62, 0.7, 1/3, "stop bracket, stop slur")
violin.play_note(67, 0.7, 2, "f, start trill flat")
violin.play_note(65, 0.7, 1)
violin.play_note(64, 0.7, 1, "stop phrasing slur, stop trill")
def piano_part():
piano.play_note(33, 0.7, 0.5, "start pedal, start dashes 'cresc.'")
piano.play_note(45, 0.7, 0.5)
piano.play_note(52, 0.7, 0.5)
piano.play_note(57, 0.7, 0.5)
piano.play_note(38, 0.7, 0.5, "change pedal")
piano.play_note(50, 0.7, 0.5)
piano.play_note(53, 0.7, 0.5)
piano.play_note(57, 0.7, 0.5, "stop dashes")
piano.play_chord([43, 50, 58], 0.7, 2, "arpeggiate, stop pedal, f, start hairpin >")
piano.play_chord([45, 49, 57], 0.7, 2, "arpeggiate, stop hairpin, fermata")
fork(piano_part)
violin_part()
performance = s.stop_transcribing()
performance.to_score().show()