You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
voice.makeRests() fills in missing notes in tuplets incorrectly #1237
If I put a single triplet eighth-note rest at the end of a 3-quarter-note voice (leaving a starting gap of 11 triplet eighth notes) and then call makeRests, it inserts a rest with duration.tuplets = (<music21.duration.Tuplet 12/11/16th>,) instead of what I would expect: duration.tuplets = (<music21.duration.Tuplet 3/2/eighth>,). The actual duration.quarterLength is correct (11/3ql), but I don't understand that weird tuplet choice (12 actual 16th notes in the space of 11 normal 16th notes).
On Feb 27, 2022, at 2:36 PM, Michael Scott Cuthbert ***@***.***> wrote:
What happens if you give a time signature?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
I take it back!
If I put a time signature in the Voice itself, this works correctly.
In the real case, the time signature occurred earlier in the score. But the Voice is not yet inserted when I do the makeRests(), so it doesn’t know. I will try putting it in the score first, to see if that helps.
Greg
On Feb 27, 2022, at 2:47 PM, Greg Chapman ***@***.***> wrote:
Same thing. (The real case has one)
> On Feb 27, 2022, at 2:36 PM, Michael Scott Cuthbert ***@***.***> wrote:
>
>
>
> What happens if you give a time signature?
>
> —
> Reply to this email directly, view it on GitHub <#1237 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AR6X47ERKW3MOFQYCBEPEEDU5KRNZANCNFSM5PPONFFQ>.
> You are receiving this because you authored the thread.
>
Ah. So it only works if the time signature is in the Voice itself. Having the voice inserted into the measure (which has an implied time signature from a previous measure) doesn’t help.
So I do need a fix here.
Greg
On Feb 27, 2022, at 2:55 PM, Greg Chapman ***@***.***> wrote:
I take it back!
If I put a time signature in the Voice itself, this works correctly.
In the real case, the time signature occurred earlier in the score. But the Voice is not yet inserted when I do the makeRests(), so it doesn’t know. I will try putting it in the score first, to see if that helps.
Greg
> On Feb 27, 2022, at 2:47 PM, Greg Chapman ***@***.*** ***@***.***>> wrote:
>
> Same thing. (The real case has one)
>
>> On Feb 27, 2022, at 2:36 PM, Michael Scott Cuthbert ***@***.*** ***@***.***>> wrote:
>>
>>
>>
>> What happens if you give a time signature?
>>
>> —
>> Reply to this email directly, view it on GitHub <#1237 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AR6X47ERKW3MOFQYCBEPEEDU5KRNZANCNFSM5PPONFFQ>.
>> You are receiving this because you authored the thread.
>>
When you say this works with a time signature (albeit not in a real world scenario), what is the result? A half rest, quarter rest, and two triplet eighths? If so, I would have thought #992 was needed for that (speaking of which, the procedure described there is probably your best workaround for now).
On Feb 27, 2022, at 3:02 PM, Greg Chapman ***@***.***> wrote:
Ah. So it only works if the time signature is in the Voice itself. Having the voice inserted into the measure (which has an implied time signature from a previous measure) doesn’t help.
So I do need a fix here.
Greg
> On Feb 27, 2022, at 2:55 PM, Greg Chapman ***@***.*** ***@***.***>> wrote:
>
> I take it back!
>
> If I put a time signature in the Voice itself, this works correctly.
>
> In the real case, the time signature occurred earlier in the score. But the Voice is not yet inserted when I do the makeRests(), so it doesn’t know. I will try putting it in the score first, to see if that helps.
>
> Greg
>
>> On Feb 27, 2022, at 2:47 PM, Greg Chapman ***@***.*** ***@***.***>> wrote:
>>
>> Same thing. (The real case has one)
>>
>>> On Feb 27, 2022, at 2:36 PM, Michael Scott Cuthbert ***@***.*** ***@***.***>> wrote:
>>>
>>>
>>>
>>> What happens if you give a time signature?
>>>
>>> —
>>> Reply to this email directly, view it on GitHub <#1237 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AR6X47ERKW3MOFQYCBEPEEDU5KRNZANCNFSM5PPONFFQ>.
>>> You are receiving this because you authored the thread.
>>>
>
I have tried a LOT of things now… Here’s the latest attempt, with everything but the kitchen sink thrown in.
The rest that makeRests creates is still that weird tuplet (12 notes in the space of 11).
Jacob, thanks for the pointer to #904. I’ll try that procedure described there as a workaround now.
restVoice = m21.stream.Voice()
timesig = m21.meter.TimeSignature('4/4')
restVoice.insert(0, timesig)
secondNote = m21.note.Rest()
secondNote.duration = m21.duration.Duration(Fraction(1, 3))
restVoice.insert(Fraction(11, 3), secondNote)
restVoice.makeRests(inPlace=True,
hideRests=True,
fillGaps=True,
timeRangeFromBarDuration=True,
refStreamOrTimeRange=timesig)
firstNote = restVoice.notesAndRests[0]
print('firstNote = ', firstNote)
print('firstNote tuplets = ', firstNote.duration.tuplets)
print('secondNote = ', secondNote)
print('secondNote tuplets = ', secondNote.duration.tuplets)
print('')
<stdout>
firstNote = <music21.note.Rest 11/3ql>
firstNote tuplets = (<music21.duration.Tuplet 12/11/16th>,)
secondNote = <music21.note.Rest 1/3ql>
secondNote tuplets = (<music21.duration.Tuplet 3/2/eighth>,)
OK, I tried using duration.TupletFixer, and it finds the right tupletGroup, but then fails to correct it, saying:
Crazy! 4.0 2.75 16/11
(once I uncommented that print, and fixed a typo in it)
I don’t blame it, I can’t get my head around what that first tuplet means, either.
Greg
I'll be closing as a duplicate of #572, but I went ahead and re-opened a PR to fix it (#1240), so I'm hoping you might test it out. It's not truly mergeable until we have a solution for #904, but I'll open something for that soon and figured this way testing/feedback could get going, if you have some. Thanks.
Activity
mscuthbert commentedon Feb 27, 2022
What happens if you give a time signature?
gregchapman-dev commentedon Feb 27, 2022
gregchapman-dev commentedon Feb 27, 2022
gregchapman-dev commentedon Feb 27, 2022
jacobtylerwalls commentedon Feb 27, 2022
Most likely another manifestation of #904.
When you say this works with a time signature (albeit not in a real world scenario), what is the result? A half rest, quarter rest, and two triplet eighths? If so, I would have thought #992 was needed for that (speaking of which, the procedure described there is probably your best workaround for now).
gregchapman-dev commentedon Feb 27, 2022
jacobtylerwalls commentedon Feb 27, 2022
Another very similar discussion at #572.
gregchapman-dev commentedon Feb 27, 2022
gregchapman-dev commentedon Feb 27, 2022
gregchapman-dev commentedon Feb 27, 2022
Here's my code for that use of TupletFixer:
jacobtylerwalls commentedon Mar 1, 2022
Thanks for looking into some workarounds.
I'll be closing as a duplicate of #572, but I went ahead and re-opened a PR to fix it (#1240), so I'm hoping you might test it out. It's not truly mergeable until we have a solution for #904, but I'll open something for that soon and figured this way testing/feedback could get going, if you have some. Thanks.