Add retunable primes
clumma opened this issue · comments
A ratio like 5/4 can be understood to directly specify a pitch. But it can also be understood as specifying the just intonation identity of a note that may be tempered. Monzos are also used for the latter purpose, but they can be cumbersome to write.
I propose a command with the form {t Ac Bc Cc...} where the capital letters are tunings, in cents, of successive prime numbers.
For example, the command {t 1200c 1895c 2779c} tunes the 5-limit as in 19edo. All higher primes would be tuned normally.
The benefit is that an entire composition can be retuned with one command (if its pitches are given as ratios). Existing ways of retuning an entire piece, say by changing {12edo}{0 2 4 5 7 9 11} to {19edo}{0 3 6 8 11 14 17}, are not guaranteed to preserve the just intonation identities of notes and chords.
This should be straightforward to implement. Rational numbers would be converted to something like cents before playback. They would be factored, multiplied by the tuning, and the resulting terms would be summed. It may be advisable to escape rationals over a certain length and tune them normally, in case a user inputs ratios of large primes which could take a long time to factor.
Seconding this.
Hi! Sorry I didn't catch this earlier. This is an interesting idea. Can I get you to provide me with an example tune written with the syntax you'd like, and the same tune written using features that xenpaper currently supports? Just so I can fully grok why what we already have might not be adequate. Also what are your goals in using xenpaper when you find yourself in a situation where this seems like a desirable thing to have?
Also I'd better be open - this project hasn't been in active development for quite some time other than an occasional bug fix so I can't really guarantee that I'll get to this soon or even in months time if I'm being honest. PRs are welcome though.
Thirded. Would love to work on this, would need help navigating the codebase/building though.
proposed steps:
- syntax tokens grammar,
- update Context to contain primes tuning state
- update where scale frequencies are calculated & labels (they seem to be calculated in various places, will need help finding them)
- will need to import some prime factoring library
As for syntax, I'm guessing something like:
{t 1200c 1900c 2800c}
1/1 9/8 5/4
would be equivalent to: {12edo} 0 2 4
?
@dxinteractive the idea is just to be able to take a piece of music written in JI and temper it easily by changing the size of the primes. You change that one line and can easily render different tempered versions of the same tune.
@euwbah right. Maybe simpler would be to implement it as a simple search and replace, possibly using a regex or something, that just takes the JI ratios and maps them to cents values, as a preprocessing step. Then just send the result into xenpaper.
It would also be really nice to somehow be able to do this with tempered intervals. For instance if would be nice to specify something in porcupine and then vary the size of the octave and generator and so on. That would be a bit trickier though as it would require some kind of different notation to begin with. You would need a pair of 2D coordinates for an arbitrary interval in a rank 2 temperament.
@battaglia01 ah, regex might work, but I think there should be a way to just implement it internally - that way, animations and the pitch labels in the ruler view would still work as expected.
rank-n temperaments appear to be harder to implement since the current code doesn't parse anything remotely similar to vectors, so you would need to make a whole new syntax, maybe with angle brackets or something.
The syntax is slightly different than proposed (using setter notation since its a configuration parameter), but this should work nonetheless.
Changes look good. Is the new version being hosted for testing on github pages? What's the url?
Thanks @clumma, it's not hosted unfortunately, I had issues setting it up because ghpages serves the page not at the root directory, so the paths and imports got messed up. Though, you can clone the project and build & run it with the build instructions I provided in the PR. If the pr takes a while to get accepted I don't mind fixing the paths temporarily. :)