Using variables within patterns

Apologies if this has been answered elsewhere, had a search but couldn't quite find what I was looking for. I'm trying to figure out how to use a variable in place of one part of pattern. I know that you can define a whole pattern in a variable like this:

do
    let structPatt = "[t(< 2 1 3 1 >,4,< 0 2 1 >)]*4"
    d1 $ struct structPatt $ n "0 3 7 10" # s "superchip"

But what if you wanted to have just part of that pattern be a variable, so something like:

d1 $ struct "[t(< VARIABLE_HERE!!! >,4,< 0 2 1 >)]*4" $ n "0 3 7 10" # s "superchip"

How would you define and use that variable? I've tried a bunch of different ways and all lead to some kind of error.

Hi @DanD

There isn't a way to do this at the moment, unfortunately.

It's something we've looked at:

I don't think it's too difficult to implement, but it hasn't come to fruition just yet..

3 Likes

Ok I hacked something together, should be available in the next Tidal version later this week!

6 Likes

oh wow! excited to see this :pray:

1 Like

That's super awesome! I was happy with 'Sorry no can do' tbh :slight_smile: This could open up all sorts of interesting creative possibilities and make working with long complex patterns much easier. Thanks @yaxu

This is working:

setI "groove" $ iter 4 "0 3 [~ 2] 4"
setS "boop" $ chunk 4 (fast 2) "bd sd [~ bd sd]"

d1 $ n "^groove" # sound "cpu"
d2 $ s "^boop clap:4 ^boop bd*2"

-- + on-the-fly changes work:

setS "boop" $ slow 2 $ chunk 4 (fast 2) "gabba(3,8)"

I think this will open up some other unexpected possibilities too, including extra-easy MIDI input..

Should be able to get this released later!

6 Likes

Yeah Iā€™m really excited about the midi input possibilities.

Very nice :::slight_smile:

This does not seems to work for me:

setI "pulse" $ (cI 5 "21")

setI "step" $ (cI 16 "22")

d1 $ "bd(^pulse, ^step)" 

where 21 and 22 are two MIDI knobs on my controller.
Also, it works fine with :

 d1 $ sound "bd*16"
    # djf (cF 0.5 "21")

What I mean but does not work, it is taking the default value but values are not changing while moving the knobs

Hmm I can't remember how this works, but it might be difficult to fix.

Howabout this?

You could also do the mapping from numbers to names in supercollider.

Yeah, this one is the same except there is no default value so no sound at all.

I could doing the translation in SC, but I feel that this is no the problem, since the value are received correctly on tidal side, as long as it is not in mininotation.

For example, this works :

setI "drywet" $ (cI 5 "17")

 d1 $ sound "bd*16"
    # djf drywet