Piano staves

Hi. I’m trying to print my piano part with piano staves, as usual for a piano, with a bass and treble clef, but I don’t know how. Any idea?
Another thing: is it possible to make a tutorial on quantisation_scheme, really not clear for me.

Thank you!

Eric

Hi Eric – good to meet you!

The piano staff thing has come up, before. See:

It’s not a perfect solution, but should be pretty workable.

As for quantization_scheme, I’ll consider making a tutorial definitely. Did you see the one on generating notation?

It goes over a lot of the settings you can use, but admittedly doesn’t go into the building of quantization schemes directly. Is there anything in particular that you’re trying to do with the quantization?

Hi Marc! Thank you.
I see for the piano. But, for big chords, what to do? I have to write two different parts.
I see the tutorial and it’s ok, but I don’t understand how to work with the quantization_scheme. It’s a bit tricky.

I would like to quantize piano parts and ensemble parts and trying out to understand the program better.

I’m waiting! Thank you! and congrats for the program

Eric

Ah, good point. I guess for chords you could do something like this:

def play_piano_chord(pitches, volume, length, properties=None):
    bass_pitches = [p for p in pitches if p < 60]
    treble_pitches = [p for p in pitches if p >= 60]
    if len(bass_pitches) > 0:
        piano_bass.play_chord(bass_pitches, volume, length, properties)
    if len(treble_pitches) > 0:
        piano_treble.play_chord(treble_pitches, volume, length, properties)

(There might be a typo, haven’t tried running it!)

By the way, I’m curious how you came to learn about SCAMP?

Hi Marc!

I’ve tried the function play_piano_chord, but the notes to be written on the upper stave are pushed forward on the time line.
What could be the reason for this strangeness?

here is the code:

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

def play_piano_chord(pitches, volume, length, properties=None):
    bass_pitches = [p for p in pitches if p < 60]
    treble_pitches = [p for p in pitches if p >= 60]
    if len(bass_pitches) > 0:
        piano_bass.play_chord(bass_pitches, volume, length, properties)
    if len(treble_pitches) > 0:
        piano_treble.play_chord(treble_pitches, volume, length, properties)

s.start_transcribing()
notes=[41,47,52,57,68, 73, 78]
play_piano_chord(notes, 1,1 )
perf=s.stop_transcribing()
perf.to_score().show()
exit()

chord.pdf (48.0 KB)

Ah! There’s a mistake. If your chord has both bass and treble notes, then the current code for play_piano_chord will play the bass first and then play the treble, since both piano_bass.play_chord(bass_pitches, volume, length, properties) and piano_treble.play_chord(treble_pitches, volume, length, properties) get called and both are blocking calls.

Let’s change the code to this:

def play_piano_chord(pitches, volume, length, properties=None):
    bass_pitches = [p for p in pitches if p < 60]
    treble_pitches = [p for p in pitches if p >= 60]
    if len(bass_pitches) > 0 and len(treble_pitches) > 0:
        # there are both bass and treble pitches
        piano_bass.play_chord(bass_pitches, volume, length, properties, blocking=False)
        piano_treble.play_chord(treble_pitches, volume, length, properties)
    elif len(bass_pitches) > 0:
        # only bass pitches
        piano_bass.play_chord(bass_pitches, volume, length, properties)
    elif len(treble_pitches) > 0:
        # only treble pitches
        piano_treble.play_chord(treble_pitches, volume, length, properties)

This way, when there are both bass and treble, we make the first call blocking=False so that it overlaps with the second call.

thanks a lot!
blocking option is quite useful also in other context

Definitely :slight_smile: It’s basically a mini fork just for one note.