-
Notifications
You must be signed in to change notification settings - Fork 405
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
Romantext treatment of transposed roman numerals in copied measures #1433
Comments
Just when working through this problem know that Key creation is one of the slowest parts of music21, so any solution that involves "Create a new Key object for every RN" would need to be preceded by a PR of "Speed up Key creation 10x" -- actually the slowness of Key creation is not in KeySignature creation but Scale creation. There are some opportunities for speeding up Scale creation (special-casing major and minor scales is probably the optimal part of it, or sharing one IntervalNetwork object) but those would need to happen first. |
I hear what you're saying, but surely it's better for it to work slowly than for it to not work at all? Or if you don't want to implement Roman Numeral transposition, we could at least have it raise a NotImplementedError to save unsuspecting users such as myself the hassle of debugging why things are not working as expected? Moreover, I'm a bit confused because in #1413 when I suggested making a new key for every transposed RN you endorsed the idea. Also, roman text parsing already creates a new key object for every RomanNumeral it creates (e.g., here). The only change my PR makes to
In the current code, this seems to be the only situation where the romantext parser doesn't already create a new roman numeral. It seems like it might be possible to change the romantext parser so that romannumerals share keys. Then transposition could just transpose the key objects, and not the roman numerals themselves. But that would be a bigger change and I don't know what else it would potentially break. For my own work, I need transposition of roman numerals and romantext-parsed scores to work correctly and I thought that would potentially be useful to others as well, hence I made this quick PR. |
Currently RomanNumerals work properly for all use cases except transposition -- I take issue with saying that they don't work at all. Your proposal will slow down all other cases except yours. |
Hi Myke, I certainly didn't mean to suggest that roman numerals don't work in general and I'm sorry if it came off that way. That's why I suggested in the next sentence that roman numeral transposition raise a NotImplementedError, at least temporarily, if you prefer not to accept my PR. My PR creates new key objects in precisely two cases (in fact, in the latter case, to be precise, an existing key is copied with deepcopy, which may be faster than creating a new key from scratch):
In any case, to address your concerns, I wrote the following brief script to compare the speed on a sample of roman text files from the When-in-Rome corpus. (It relies on the sh library and the fd shell utility so it will need to be rewritten if people want to run it themselves and don't have either of those.)
The results (run 3 times on each branch) were as follows: Existing implementation: My rn-transpose branch: It doesn't seem that my branch has caused a meaningful slowdown. In fact it's not obvious that there is a meaningful difference between the two branches. |
sounds good -- sorry i misinterpreted. I think that this has been fixed now? Closing - but reopen if I dreamt that I merged a PR. |
Yes, you merged the PR. Thanks! |
music21 version
8.0.0a12
Problem summary
When measures are copied when parsing romantext files using the "m3=m2" syntax, roman numerals are created that share keys; this leads to funky behavior when transposing the file.
Steps to reproduce
Note "b minor" for the last roman numeral but a minor for all the others.
This might seem to be a good thing---at least this roman numeral is transposing, while the others are not. But when we implement roman numeral transposition, it will lead to such roman numerals being transposed twice, because first the key is transposed, and then the roman numeral will be transposed. E.g., we get
The solution appears to be to make a copy of 'kCurrent' whenever we create a new RN in
_copySingleMeasure
and_copyMultipleMeasures
inromanText/translate.py
. I updated my PR #1414 to address this, as well as updated Roman Numeral transposition based on the discussion in #1413.The text was updated successfully, but these errors were encountered: