Unintuitive behavior of scale when mapping notes

Hi everyone,

while experimenting with the scale function I ran into some results that feel a bit confusing.

For example, the following patterns seem to produce equivalent outputs:

d1 $ note (scale "major" "c4") # sound "superpiano"
-- ≡
d1 $ note "e3" # sound "superpiano"
d1 $ note (scale "major" "c3") # sound "superpiano"
-- ≡
d1 $ note "g1" # sound "superpiano"
d1 $ note (scale "major" "c2") # sound "superpiano"
d1 $ note (scale "major" "c1") # sound "superpiano"
-- both ≡

d1 $ note "c0" # sound "superpiano"

Indeed, the notes returned by scale do belong to the major scale, but the mapping between the root note I provide to scale and the final result looks quite unintuitive.

Could someone explain how this mapping actually works under the hood?

Thanks in advance!

I'm afraid I've been a bit clumsy applying how the scale function works. Actually, the second argument of scale shouldn't correspond to notes, but rather to the degree of the scale in question, calculating the value modulo 7 I guess.

I was thinking of deleting this entry but I'll leave it in case it might provide some clarity to someone.

Actually, the second argument of the scale function does not work modulo 7. Instead, values greater than 7 are mapped to the corresponding degree in higher octaves. For example, scale "c major" 8 will not wrap back to the first degree, but rather give you the first degree an octave higher.