Add offsets as fractions when building timespans (AI) - #2046
Conversation
listOfTreesByClass added an element's offset to its measure's offset as
they came. A measure at 25.0 is a float and a triplet at 8/3 inside it is
a Fraction, so the sum was a float, and adding the triplet's length to
that float ended it a hair after the next note began. The F#3 triplet
at 27 2/3 in schoenberg/opus19/movement6 then still sounded when the
E-3 after it started at 28 1/3, and iterateAllVoiceLeadingQuartets
paired its voice with itself there:
<music21.voiceLeading.VoiceLeadingQuartet v1n1=F#3, v1n2=E-3,
v2n1=F#3, v2n2=F#3>
Pass the offsets and end times through common.opFrac, as
recurseGetTreeByClass already did for its offsets.
|
Thank you! Out of curiosity-- what kind of project are you working on that made this error be surfaced? |
|
as you may or may not have seen, I've been re-implementing music21 in rust, and running it against the python test suite and doctest for verification. there was a discrepancy between music21s iterateAllVoiceLeadingQuartets and my ports iterate_all_voice_leading_quartets. |
Ah! I didn't know that, but it makes sense why the typing concerns would be paramount. When music21 began we really took duck-typing to an extreme -- there was no typed Python and there didn't seem to be much of a problem with "returns a string if it's an odd numbered month and an int if even" :-D. But now of course things are very different. I would definitely not try to reconstruct every odd-ball case of duck typing today in a strongly typed language, or one that really needs Liskov to be followed to the letter. Good luck! |
In case there are places where you need to deviate, here's my list of advice on mistakes I made in music21: https://music21.org/music21docs/developerReference/startingOver.html |
|
thank you, i saw that list when i started working on this ~2-3 years ago. it's a useful document i wish more projects had something like this. my main motivation for all of this was having the music21 chord naming algorithm running in a browser, since all the chord naming algorithms were so bad, so initially i just ported the chord module by hand. llms are so good now that porting the rest and just testing it against the music21 test suite for verification has been easy enough. i have some useful tools built on music21(-rs) running locally in the browser here. |
|
i have more bugs/changes that claude found/did but they are larger changes, and I don't really do python and i'm not super familiar with music21 outside of the chord, note, and pitch modules so it will take me a bit to understand if they are truly correct changes to try and get upstream. |
listOfTreesByClassadded a measure's float offset to a triplet'sFractionoffset and got a float, so the triplet's end landed a bit past where the next note began. In schoenberg/opus19/movement6 the F#3 at 27 2/3 was still sounding when the E-3 at 28 1/3 started, anditerateAllVoiceLeadingQuartetspaired that voice with itself:Offsets and end times now go through
common.opFrac, asrecurseGetTreeByClassalready did.