Tidal icon indicating copy to clipboard operation
Tidal copied to clipboard

Contiguous euclid

Open yaxu opened this issue 4 years ago • 11 comments

In response to a @kindohm question, a contiguous version of euclid, e.g. euclidGapless 3 8 gives the equivalent of "1@3 1@3 1@2" rather than 1 0 0 1 0 0 1 0:

import Sound.Tidal.Bjorklund

euclidGapless :: Int -> Int -> Pattern Bool
euclidGapless n x = timeCat $ map (\d -> (toRational d,pure True)) $ iois 0 $ bjorklund (n,x)
  where iois :: Int -> [Bool] -> [Int]
        iois 0 [] = []
        iois i [] = (i:[])
        iois 0 (True:xs) = iois 1 xs
        iois i (True:xs) = i:(iois 1 xs)
        iois i (False:xs) = iois (i+1) xs

Would be nice to add this to tidal, and think about mininotation shorthand for it.. The best I could think of was double parens: "t((3,8))"

yaxu avatar Jan 16 '21 20:01 yaxu

Any chance we could also support a third parameter for the rotation?

d1 $ euclidGapless "3" "8" "<0 3>" $ s "bd"

d1 $ s "bd((3,8,<0 3>))"

kindohm avatar Jan 16 '21 23:01 kindohm

Would be nice to add this to tidal, and think about mininotation shorthand for it.. The best I could think of was double parens: "t((3,8))"

Thinking into the future, I wonder if it would be useful to have a more extendable notation convention? There are not many kinds of brackets left :)

telephon avatar Jan 17 '21 09:01 telephon

Yes what are the options? Regex uses a question mark and another character for different groupings like (?! ) for negative lookahead iirc. They look a bit like emoticons so are quite easy to remember but look like line noise for the uninitiated..

yaxu avatar Jan 17 '21 09:01 yaxu

Not sure. So currently, the schema is a nested ABXB', where A is some expression like an instrument name, B…B' is a pair of matching parentheses, and X is some arbitrary term? (well, not arbitrary, but depends on A, I suppose).

telephon avatar Jan 17 '21 09:01 telephon

Another approach would be to embed named function names into the mini notation like {% euclidGapless 3 8 %}.. Or make the mini notation redundant by making the native haskell side as expressive

yaxu avatar Jan 17 '21 09:01 yaxu

Or make the mini notation redundant by making the native haskell side as expressive

That sounds like a good idea to me.

telephon avatar Jan 17 '21 09:01 telephon

So currently, the schema is a nested ABXB', where A is some expression like an instrument name, B…B' is a pair of matching parentheses, and X is some arbitrary term? (well, not arbitrary, but depends on A, I suppose).

Well there's a(3,8) for euclid but also [a,a,...] and {a,a,...} for subpatterns / layering

The latter is based on BP2 polymetric expressions https://bolprocessor.org/misc/docs/bp2-Polymet.html

It seems Bernard has _rest for an 'undetermined rest. We could do something similar with _euclidGapless(3,8)` in the mininotation.

But it does feel like it's shoehorning things into the mininotation.

You could also do

setF "x" $ euclidGapLess 3 8 

and then use that as ^x in mininotation.

yaxu avatar Jan 17 '21 21:01 yaxu

What about an underscore before the parenthesis? bd_(3,8)

ndr-brt avatar Jan 17 '21 21:01 ndr-brt

Can we get the euclid values patternable on this? Even a quick hack? This function should be added to tidal, it's great for sequencing legato.

ovitus avatar Mar 17 '21 04:03 ovitus

maybe a haskell function that coalesces rests in any pattern into the note event immediately previous to them?

capogreco avatar Jan 07 '22 20:01 capogreco

Ah, somehow I missed this and was recently thinking of something similar. Coalescing rests is actually rather tricky since patterns have all sorts of overlapping things going on.

As for the mininotation, bd_(3,8) seems intuitive but I'm wondering if bd(_3,8) might parse more easily. And in some sense, it's only the "3" that gets modified, so maybe that makes a weird kind of sense?

import GHC.Exts ( IsString(..) )

import Sound.Tidal.Bjorklund (bjorklund)

import Data.Bool (bool)

_euclidEBool :: Int -> Int -> Pattern Bool
_euclidEBool n k = fromString . concatMap (bool "_ " "t ") $ bjorklund (n,k)

_euclidEOffBool _ 0 _ _ = silence
_euclidEOffBool n k s p = rotL (fromIntegral s % fromIntegral k) $ (\a b -> if b then a else not a) <$> _euclidEBool n k <*> p

euclidEOffBool = tParam3 _euclidEOffBool
euclidEBool n k p = euclidEOffBool n k 0 p

bgold-cosmos avatar Jan 07 '22 20:01 bgold-cosmos