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

voice.makeRests() fills in missing notes in tuplets incorrectly #1237

Closed
gregchapman-dev opened this issue Feb 27, 2022 · 11 comments
Closed

Comments

@gregchapman-dev
Copy link
Contributor

music21 version

7.2.1

Problem summary

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).

Steps to reproduce

from fractions import Fraction
import music21 as m21
restVoice = m21.stream.Voice()
secondNote = m21.note.Rest()
secondNote.duration = m21.duration.Duration(Fraction(1, 3))
restVoice.insert(Fraction(11, 3), secondNote)
restVoice.makeRests(inPlace=True, hideRests=True)
firstNote = restVoice.notesAndRests[0]
print('firstNote = ', firstNote)
print('firstNote tuplets = ', firstNote.duration.tuplets)
print('secondNote = ', secondNote)
print('secondNote tuplets = ', secondNote.duration.tuplets)

Expected vs. actual behavior

More information

@mscuthbert
Copy link
Member

What happens if you give a time signature?

@gregchapman-dev
Copy link
Contributor Author

gregchapman-dev commented Feb 27, 2022 via email

@gregchapman-dev
Copy link
Contributor Author

gregchapman-dev commented Feb 27, 2022 via email

@gregchapman-dev
Copy link
Contributor Author

gregchapman-dev commented Feb 27, 2022 via email

@jacobtylerwalls
Copy link
Member

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
Copy link
Contributor Author

gregchapman-dev commented Feb 27, 2022 via email

@jacobtylerwalls
Copy link
Member

Another very similar discussion at #572.

@gregchapman-dev
Copy link
Contributor Author

gregchapman-dev commented Feb 27, 2022 via email

@gregchapman-dev
Copy link
Contributor Author

gregchapman-dev commented Feb 27, 2022 via email

@gregchapman-dev
Copy link
Contributor Author

Here's my code for that use of TupletFixer:

from fractions import Fraction
import music21 as m21
print(m21.__version__)

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)
tf = m21.duration.TupletFixer(restVoice)
tupletGroups = tf.findTupletGroups()
for tg in tupletGroups:
    tf.fixBrokenTupletDuration(tg)

firstNote = restVoice.notesAndRests[0]
print('firstNote = ', firstNote)
print('firstNote tuplets = ', firstNote.duration.tuplets)
print('secondNote = ', secondNote)
print('secondNote tuplets = ', secondNote.duration.tuplets)

@jacobtylerwalls
Copy link
Member

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.

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

3 participants