Tidal
Tidal copied to clipboard
Euclidean mininotation in curly braces
These two patterns should produce the same results:
drawLine "{x ~ ~ x ~ ~ x ~, y ~ ~ }"
drawLine "{x(3,8), y ~ ~}"
but the second line unexpectedly produces:
|x x x |x x x |x x x |x x x |x x x |x x x |x x x |x x x
|y------- |y------- |y-------
Is there an API function that does what { p_1, .. , p_n } is doing in the parser?
Probably not, because p_i is not Pattern a but TPat a which has extra size information? This info differs (8 vs. 1):
:set -XPartialTypeSignatures
Right (TPat_Seq [TPat_Polyrhythm Nothing qs]) = parseTPat "{x ~ ~ x ~ ~ x ~, y ~ ~ }" :: Either _ (TPat String)
map resolve_tpat qs
[(8 % 1,(0>⅛)|"x"
(⅜>½)|"x"
(¾>⅞)|"x"),(3 % 1,(0>⅓)|"y")]
Right (TPat_Seq [TPat_Polyrhythm Nothing ps]) = parseTPat "{x(3,8), y ~ ~}" :: Either _ (TPat String)
map resolve_tpat ps
[(1 % 1,(0>⅛)|"x"
(⅜>½)|"x"
(¾>⅞)|"x"),(3 % 1,(0>⅓)|"y")]
Then the resulting semantics also differs, since
toPat (TPat_Polyrhythm mSteprate ps) = stack $ map adjust_speed pats
where adjust_speed (sz, pat) = fast ((/sz) <$> steprate) pat
pats = map resolve_tpat ps
...
This is because "{x(3,8), y ~ ~}" is expanded to "{[x ~ ~ x ~ ~ x ~], y ~ ~}". The Euclidean stuff gets wrapped in an implicit []. Whether that's desired or not I dunno...
Ah that makes sense @bgold-cosmos, but doesn't correspond to the output of drawLine. I suspect that is a separate bug in drawLine, though - the lower line seems to be missing some |'s.
I'd say sometimes you want to treat x(3,8) as eight steps, and sometimes as one. You could express the latter case as [x(3,8)].
'fixing' this would count as a breaking change.
I think the "wrap euclid in [ ]" is fine. It's happening uniformly (inside any kind of parentheses)? E.g.,
"<0(3,8) 1>*2" :: Pattern Int
"<[0(3,8)] 1>*2" :: Pattern Int
(0>1/16)|0
(3/16>¼)|0
(⅜>7/16)|0
(½>1)|1
I would probably find it more confusing if the semantics of 0(3,8) would depend on the context. I mean, it's fine that (bending notation somewhat)
let p = 0(3,8) in <p 1>*2 is equivalent to < 0(3,8) 1>*2.