m-yac / xen-calc

A multi-purpose calculator for microtonal(/xenharmonic) music
9 stars 1 forks source link

`map` function #33

Open fredg999 opened 1 year ago

fredg999 commented 1 year ago

Hello!

I recently found myself wanting to check the patent val approximation of some JI interval in a given edo (e.g. 2048/2025 in 4edo). I know there's the approx function to check the direct approximation, but a map function that would show the regular mapping of some interval would be interesting. Since there's already a function to see the mapping for primes in a given edo, I suppose most of the underlying math is available in the utils.

Obviously the syntax should be map(interval, edo), like approx. For some reason I'm tempted to type (interval)\edo, similar to the ups and downs notation feature, but I think that would lead to ambiguous expressions for intervals written as integers (i.e. harmonics), and operator precedence wouldn't be clear either, so that's probably a bad idea. Although I'm open to ideas to make it work! ;)

The map function could be used, among other things, to check if an interval is tempered out by the given edo or not. For example, while approx(2048/2025, 4) would output 0¢, map(2048/2025, 4) would output 600¢, because that's the regular mapping. Someone could even calculate the mistuning by dividing the "map" of the interval by the original interval itself. That could be an example to give on the features page, maybe.

What do you think?