Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multimeasure rests #25

Open
nagymusic opened this issue Dec 12, 2019 · 8 comments
Open

multimeasure rests #25

nagymusic opened this issue Dec 12, 2019 · 8 comments
Assignees

Comments

@nagymusic
Copy link

What indicator has replaced use_multimeasure_rests=True in the updated version of rmakers?

stack = rmakers.stack(
  rmakers.note(),
  rmakers.force_rest(abjad.select().leaves().get([1, -1])),
  #use_multimeasure_rests=True,
  )

Thanks!
-Zvony

@trevorbaca
Copy link
Member

Hey Zvony (@nagymusic), I kinda demoted multimeasure rests in the updated rmakers, largely because my own use of multimeasure rests always seemed to be in the creation of duration-multiplied mm rests. So there's a new rmakers.multipied_duration() factory function that can take abjad.MultimeasureRest as its first argument and produce multimeasure rests with a duration multipliers.

The rmakers.mutliplied_duration() function is implemented in the makers.py module. The function is just a wrapper around the rmakers.MultipliedDurationRhythmMaker class (also implemented in makers.py). So take a look at the rmakers.MultipiledDurationRhythmMaker docstring. There's an example showing multimeasure rest creation. See if maybe that will get you what you want.

The usage is super simple and looks like this:

            >>> rhythm_maker = rmakers.multiplied_duration(
            ...     abjad.MultimeasureRest
            ... )
            >>> divisions = [(1, 4), (3, 16), (5, 8), (1, 3)]
            >>> selections = rhythm_maker(divisions)

@nagymusic
Copy link
Author

Thanks, Trevor. This makes sense. I just have a quick follow up question.

Is it possible to wrap rmakers.multipled_duration(abjad.MultimeasureRest) in the stack so that it automatically generates whole measure rests for the silenced divisions. I tried something like that in the example below. I love the updated rmakers - thank you once again!

stack = rmakers.stack(
    rmakers.note(),
    rmakers.force_rest(
        abjad.select().logical_ties().get([0], 2)[1:-1],
    ),
    rmakers.multiplied_duration(abjad.MultimeasureRest(?))
)

divisions = [(4, 8), (3, 8), (4, 8), (3, 8), (2, 8)]

selection = stack(divisions)
lilypond_file = abjad.LilyPondFile.rhythm(
    selection, divisions
)

@trevorbaca
Copy link
Member

Hey Zvony I guess it's not possible to selectively replace ("force" in the language of the updated package) in the way you're looking for.

That'll be really easy for me to add into the package in a bit. For now you can postprocess the output of your stack: use selectors to select the components you want to replace with multimeasure rests; then use abjad.mutate().replace().

@nagymusic
Copy link
Author

Hey Trevor,
I see. The use_multimeasure_rests=True was a time saver in the earlier version of rmakers when I used it in a few instances, mainly with incised and/or silenced divisions. Thank you for considering to add it into the package.

As you suggested, I'm trying to replace the output of my stack by replacing the middle (third) measure in 4/8 with a new whole-measure rest measure using rmakers.multiplied_duration(abjad.MultimeasureRest()) and abjad.mutate().replace(). But it doesn't seem to be working. Any ideas?

Thank you!
Zvony

import abjad
from abjadext import rmakers

stack = rmakers.stack(
    rmakers.note(),
    rmakers.force_rest(
        abjad.select().logical_ties().get([0], 2)[1:-1],
    ),
)

divisions = [(4, 8), (3, 8), (4, 8), (3, 8), (2, 8)]
selection = stack(divisions)

######################

multimeasure_rests = rmakers.multiplied_duration(abjad.MultimeasureRest)

new_divisions = [(4, 8)]
new_selections = multimeasure_rests(new_divisions)

select_measures = abjad.select(selection).group_by_measure()
abjad.mutate(select_measures[2:3]).replace(new_selections)

lilypond_file = abjad.LilyPondFile.rhythm(
    selection, divisions
)

abjad.show(lilypond_file)

@nagymusic
Copy link
Author

Trevor,
I had a chance to work on the application of selected multi-measure rests within rmakers. Per your suggestion, I also reviewed the rmakers.mutliplied_duration() function as it is implemented in the makers.py module.

I understand if you may not be able to answer this, but is it possible to apply the same (or similar) variables to rmakers.multiplied_duration(abjad.MultimeasureRest) like it's done to rmakers.force_rest() below? I ask this because in this way one may be able to apply the same selections of measures tomultiplied_duration as it is currently used with force_rests.

stack = rmakers.stack(
    rmakers.accelerando(
        [(1, 8), (1, 20), (1, 16)],
        ),
    rmakers.force_rest(abjad.select().tuplets().get([1], 2)),
    #rmakers.multiplied_duration(abjad.MultimeasureRest), => (abjad.select().tuplets().get([1], 2))?
    rmakers.rewrite_rest_filled(),
    rmakers.feather_beam(beam_rests=True, stemlet_length=0.75,),
    rmakers.duration_bracket(),
    rmakers.extract_trivial(),
    )

divisions = [(4, 8), (3, 8), (4, 8), (3, 8)]
selection = stack(divisions)

lilypond_file = abjad.LilyPondFile.rhythm(selection, divisions)
abjad.show(lilypond_file)

Many thanks,
Zvony

@trevorbaca
Copy link
Member

trevorbaca commented Apr 30, 2020 via email

@nagymusic
Copy link
Author

Thanks, Trevor. That's correct - Multimeasure rests instead of vanilla
rests in measures 2 and 4.

@trevorbaca
Copy link
Member

trevorbaca commented Apr 30, 2020 via email

@trevorbaca trevorbaca self-assigned this Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants