PDF output file path

I am needing to specify the file path for the produced PDF from:

s.start_transcribing()
...

performance = s.stop_transcribing()
performance.to_score(title="Title", composer="Me").show()
exit()

I see that you can specify file path for JSON, Lilypond (.ly), and XML but is there a way to specify the file path for the PDF or is this a limitation from abjad.show() ?

This is a good question, and there is a way of doing it in abjad, but I haven’t built it into scamp yet. And it’s also changing with abjad 3.2, which I need to update scamp to deal with. For now, with abjad 3.1, if you have you scamp Score object in the variable score, run:

import abjad
abjad.persist(score.to_abjad_lilypond_file()).as_pdf("path/to/pdf/file.pdf")

Hopefully that works!

Great!

For my future reference or for if anyone else has the same concern:

from scamp import *
import abjad

s = Session()

#insert whatever your music is
#s.tempo = 60
#goblin = s.new_part("goblin")
#goblin.play_note(72, 1, 1)

performance = s.stop_transcribing()
score = performance.to_score(title="Title", composer="Me")
abjad.persist(score.to_abjad_lilypond_file()).as_pdf("score.pdf")
exit()

Lol, “goblin” is always the best choice of instrument.

1 Like

To specify filepath and Lilypond settings:

s.wait_for_children_to_finish()
score = s.stop_transcribing().to_score()
abjad_score = score.to_abjad_lilypond_file()
abjad_score.items.pop(0)
abjad_score.items.insert(0,
                         """
                        \header{
                        title = "Etude"
                        } 
                         """)
abjad_score.items.pop(1)
abjad_score.items.insert(1,
                         """
                         \paper{
                         #(set-paper-size "letter")
                         """)

abjad.persist(abjad_score).as_pdf("etude.pdf")
exit()

Sounds great :slight_smile:

I’ve been working to update scamp to abjad 3.3, which changes how abjad’s LilyPondFile works a little, so I’ll try to remember to post an update here when I do!