Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

abjad.persist.as_midi outputting PDF

9 views
Skip to first unread message

Andrew Rickards

unread,
Sep 14, 2024, 2:44:19 AM9/14/24
to abjad-user
I'm sure I'm making some newbie mistake but I can't figure out how to get the persist.as_midi() function to work. The persist.as_png() work just as I need it to but as_midi seems to want to save as PDF instead of a midi file.

I've tried searching the docs and this forum but I couldn't seem to find anything - at least, nothing that worked the way I need it to. None of the AI chat bots seem to be any help either.

I managed to save a midi file using show() but it saved it in the abjad's hidden output folder. I want to program I'm working on to be able to save midi files in specific locations on my computer.

Any help would be greatly appreciated.

Davi Raubach

unread,
Sep 16, 2024, 8:01:52 AM9/16/24
to abjad...@googlegroups.com

You need a midi block in your score.

import abjad

score = abjad.Score()
staff = abjad.Staff(r"c'4 d'4 e'4")
score.append(staff)
midi_block = abjad.Block("midi")
score_block = abjad.Block("score", items=[score, midi_block])
lilypond_file = abjad.LilyPondFile(
    items=[score_block],
)
abjad.persist.as_midi(lilypond_file, "file.midi")

Best regards,

Davi

Andrew Rickards <ricka...@gmail.com> writes:

I'm sure I'm making some newbie mistake but I can't figure out how to get the persist.asmidi() function to work. The persist.aspng() work just as I need it to but asmidi seems to want to save as PDF instead of a midi file.

Andrew Rickards

unread,
Sep 18, 2024, 8:17:54 PM9/18/24
to abjad-user
Thank you so much. I did try something similar to this at one point but I must have missed a step.
Much appreciated.

Reply all
Reply to author
Forward
0 new messages