Split staves (grand staff)

Yeah, it would be good add grand staves to SCAMP sometime! For now, though, this should be a pretty effective work-around:

from scamp import *

s = Session()

piano_treble = s.new_part("piano", clef_preference="treble")
piano_bass = s.new_part("piano", clef_preference="bass")

# call this instead of `piano.play_note`
def play_piano_note(pitch, volume, length, properties=None):
    if pitch >= 60:  # this cut off is at middle C, but could be wherever
        piano_treble.play_note(pitch, volume, length, properties)
    else:
        piano_bass.play_note(pitch, volume, length, properties)

# Demonstration using random notes

import random

s.start_transcribing()

while s.beat() < 12:
    play_piano_note(random.randint(40, 100), 1.0, 0.25)
    
s.stop_transcribing().to_score().show()
2 Likes