Open arseniiv opened 5 months ago
So what Scala seems to do when mapping size is not 0 (because that’s a case which (a) works perfectly and doesn’t use neither mapping pattern nor formal octave and (b) doesn’t mathematically fit with all the other cases):
Let S be the scale size from SCL, M be mapping size from KBM and P be formal octave from KBM.
First for KBM taken alone, it takes KBM’s pattern placed to start on the scale start note, thus mapping M = 4 notes:
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
x x x x x x x x 0 2 4 5 x x x x x x x x
Then it repeats the pattern up and down, each time adding or subtracting P = 7:
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
-14-12-10 -9 -7 -5 -3 -2 0 2 4 5 7 9 11 12 14 16 18 19
\_________/ \_________/ \_________/ \_________/ \_________/
-14 -7 0 +7 +14
And only now it finally consults SCL data about which degree is what interval (incidentally using S for that, which didn’t get used before), and also being able to calculate exact frequencies because now it can know the interval for the reference note, so it can calculate the frequency for degree 0 of the scale (which of course may even not appear here in the mapping).
P. S. This should also be applicable to cases when P is larger than S or is negative or zero, really, so probably KBM with P > S might now get accepted!
Thank you - this is exactly the detail I needed
For our book-keeping (or mine; I’m taking another look at the code and maybe I’ll be brave enough to mess with it!), what in the library code corresponds to which of my variables here.
Scale.count
KeyboardMapping.count
KeyboardMapping.octaveDegrees
, should not be restricted to be only positiveI also have my own Python implementation but it’s quite noisy because I intended for it to also be universal, plus there’s code to convert (SCL, KBM) pairs into “simplified” (SCL, KBM) pairs where SCL bears all the interval logic and KBM is only used to set up frequencies and nothing more. If you feel interested, I’ll upload it as a Gist though I better just write relevant pseudocode with nothing else, if I won’t end up touching this code here myself.
Addition 2024-07-12: also seeing Tuning.allowTuningCenterOnUnmapped
; — my algorithm doesn’t work if the tuning center is unmapped (at least if there’s no filling the blanks but that should depend on having frequencies already which makes a cyclical dependency).
Also I wonder why (-)256
is left as a magic constant when there’s N
. Though I don’t immediately have a good suggestion for the name: something like M
is too cryptic; N0
means something else, START
or BIAS
are both too vague and probably already too long…
Using 12edo and a KBM file of the form
makes Scala render these frequencies and quick info about the mapping:
but Surge XT 1.3.0.20a8e16 seems to deviate from those.
Very nice that there’s HTML export, I attached it here: surge_info.zip. Indeed I see degrees of notes in the mapping go
... 7 2 4 5 7 2 4 5 0 2 4 5 7 2 4 5 7 ...
which is quite peculiar. In Scala output, degrees (mod 12) are... .3. 5 7 8 .10. 0 2 3 .5. 7 9 10 .0. 2 4 5 .7. 9 11 0 .2. 4 6 7 .9. ...
where periods of the mapping are marked with dots.I have a theory about what exactly does Scala do, which so far is consistent with what I tested. I’ll add it in another post later.