Score engraving: instrument name

Hello,

I am having trouble with the soundfont and the instrument name. I want the playback to use the piano sound, but I want the instrument names to appear in the score as “cp” for counterpoint and “cf” for cantus firmus.

I appreciate any help!

from scamp import *
from main import *
from datetime import *
from dicionario import *

def play(part, lista):
    for n in lista:
        if n in naturais:
            part.play_note(n, 0.5, 4)
        else:
            part.play_note(n, 0.5, 4, "#")



def run_play(cf, cp):
    global it
    global s
    it = main(cf, cp)
    print(f"|cantus firmus:{cf.modo}\n"
          f"|resolução:    {cp.notas}")
    print_prim_esp(cf, cp)

    s = Session(tempo=float(200))
    s.fast_forward_in_beats(len(cf.modo) * 4)

    if cp.reg == 2:
        res_part = s.new_part("piano", clef_preference=str(cp.voz["clave"]))
        cf_part = s.new_part("piano", clef_preference=str(cf.voz["clave"]))
    else:
        cf_part = s.new_part("piano", clef_preference=str(cf.voz["clave"]))
        res_part = s.new_part("piano", clef_preference=str(cp.voz["clave"]))

    s.start_transcribing()

    fork(play, args=[cf_part, cf.modo])
    play(res_part, cp.notas)

    dia = date.today().strftime("%m/%d/%y")
    hora = datetime.now().strftime("%H:%M:%S")

    s.stop_transcribing().to_score(title=f"{dia}, {hora}",
                                   composer="").show()
    wait(10)
    fork(play, args=[cf_part, cf.modo])
    play(res_part, cp.notas)

    return cf.modo, cp.notas

cf, cp = cf_auto()

cf_play, cp_play = run_play(cf, cp)

You can override the default name when you create the part:

res_part = s.new_part("cp",preset="piano",clef_preference=str(cp.voz["clave"]))
cf_part = s.new_part("cf",preset="piano",clef_preference=str(cf.voz["clave"]))
1 Like

Just to add, for clarity: the first argument is the name of the instrument, which is how it appears on the score. By default, this is also used to determine the soundfont preset, but you can instead explicitly ask to use a different preset than the instrument name would indicate.