Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Splitting long containers (and notes within them)

6 views
Skip to first unread message

Pedro Faria

unread,
Oct 3, 2024, 12:39:41 PM10/3/24
to abjad-user
I'm working on some process music, and I'm generating long containers. I would like split them into manageble chunks, while still splitting notes into logical ties if possible so not to get a "bar check fail" in Lilypond; Is there a known way of doing so?

Davi Raubach Tuchtenhagen

unread,
Oct 15, 2024, 2:14:21 PM10/15/24
to abjad...@googlegroups.com

Hi Pedro,

You might want to explore selection functions here: Abjad Selection Functions. These allow you to select specific parts of a container in various ways, which can be really useful when you need to attach something to a particular leaf. For instance, you can select by the number of logical ties, or by duration, and even separate chunks into different variables. If you're working with time signatures, you can select the container by measure. Also, check out the split() function: Abjad Mutate Split.

I've created a fit_in_duration() function that is somewhat related:

def fit_in_duration(container, duration: abjad.Duration, final=False):
    if duration < abjad.get.duration(container):
        shards = abjad.mutate.split(container, [duration])
        n = 0
        if final is True:
            n = -1
        copy = abjad.mutate.copy(shards[n])
        del container[:]
        container.append(copy[0])
    else:
        difference = duration - abjad.get.duration(container)
        if difference:
            rests = rest_maker([difference]) # other function
            rests = abjad.Container(rests, name="fit in duration")
            container.extend(rests)

To have more "manageable" components or scores, I'd recommend looking into the Best Practices page: Abjad Best Practices. Specifically:

  1. Limit score segments to 2–4 pages of music. This makes performance and debugging easier, though it does mean you’ll have more work managing clefs, key signatures, and other indicators across segments. But overall, the tradeoff is worth it.

I understand you're working with process music, and I face similar challenges. It would be nice if we could consider both a larger and smaller scope when structuring pieces. Personally, I haven’t fully solved this yet, but I've been opting for smaller sections and trying to concatenate them so that the overall process sounds like a single one.

Best regards,

Davi


Em qui., 3 de out. de 2024 às 13:39, Pedro Faria <pedrofa...@gmail.com> escreveu:
I'm working on some process music, and I'm generating long containers. I would like split them into manageble chunks, while still splitting notes into logical ties if possible so not to get a "bar check fail" in Lilypond; Is there a known way of doing so?

--
You received this message because you are subscribed to the Google Groups "abjad-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to abjad-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/abjad-user/3d93c6ba-b503-4d1e-b356-69fee0244ccbn%40googlegroups.com.

Gilberto Agostinho

unread,
Oct 15, 2024, 2:14:33 PM10/15/24
to abjad...@googlegroups.com
Hi there Pedro,

I did something similar to what you are looking for in my library called Auxjad. See for instance this class which takes a long input container and then outputs slices of it given a certain head position and total length of output. The trick was to split the container at certain spots given by the head and head + desired output length, remove the generated ties from those notes if needed, then use rewrite_meter() to rewrite the rhythm of the output. You can take a look at the methods _slice_contents() and _notate_music() in particular.

Two important caveats: 1) the code is a bit complex because I wanted to automatically handle dynamics and other indicators (e.g. find the active dynamic of a given note, handle hairpins and slurs automatically, etc.); and perhaps most importantly 2) it was written for Abjad 3.4, which is quite outdated now and had a very different syntax. But it could give you an idea on how to accomplish what you are trying to do.

Best wishes!
Gilberto


On 03/10/2024 17:39, Pedro Faria wrote:
I'm working on some process music, and I'm generating long containers. I would like split them into manageble chunks, while still splitting notes into logical ties if possible so not to get a "bar check fail" in Lilypond; Is there a known way of doing so? --
Reply all
Reply to author
Forward
0 new messages