Transitioning Back

Hello people,
I'm new to tidal and this is my first question:

Right now I'm using tidal with midi and I want to know if there is a way to transition back from a pattern to another.

$ n "1*16?" |-| 24
# s "dt" 
# midichan 1

xfade 2 
$ n "1*8" |-| 24
# s "dt" 
# midichan 1

Using this piece of code you can move from what d2 is playing to what is under the xfade command.

What happens when you want to move back to the place you were before?

I reckon that you could do something like (please forgive my total ignorance of haskel)

let "pat1" = $ n "1*16?" |-| 24 # s "dt" # midichan 1 
let "pat2" = $ n "1*8" |-| 24 # s "dt" # midichan 1 

and then do something like

xfade "pat1" $ "pat2"

But I couldn't find any example of this (I don't know if such a thing is possible in tidal).

Can anyone point me to the right direction on how to find a way to transition back and forth?

Thank you!

1 Like

You could just re-evaluate the first pattern (possibly prefixing it with xfade 2), but maybe this is too obvious to be what you're looking for.

You could indeed define a shorthand for your patterns to make it easier to manipulate them, but the syntax would then be

let pat1 = n "1*16?" |-| 24 # s "dt" # midichan 1 
let pat2 = n "1*8" |-| 24 # s "dt" # midichan 1 

without quotes around pat1 and pat2 (since you want them to be Haskell identifiers and not strings), and without the $ operator at the beginning (it would be technically possible to leave it there if you surround everything with parentheses, but I think it makes more sense without it. I can elaborate if you're interested).

xfade "pat1" $ "pat2" won't work, since the argument of xfade has to be a channel number (like 2 in your first example) and not a pattern.

You could define pat1 and pat2 as above and just alternate between evaluating xfade 2 $ pat1 and xfade 2 $ pat2 as you see fit.

I hope this helps and makes it clearer for you!


Thank you! What you showed me did the trick (and opened a can of worms for all the things I could do with that). :slight_smile:

Of course I'm interested!

OK, let's have a try.
Basically, the $ operator takes whatever is on the right side and feeds it to what is on the left side (which thus has to be a function). When you do ($ something), what actually happens is that you take the value something and makes a function out of it that takes another function as an argument and feeds something to the function. With patterns, you would then have to do something like ($ myPattern) d1, which is technically correct but not very idiomatic.
On the other hand, d1 $ myPattern looks much more like natural Tidal.


Makes total sense!

Yeah th4 is absolutely right. Also if it helps to write it equationally, which I personally like, the definition of f $ x is literally just f x but the idea is that it's both right-associative and has lower precedence than every other operator including function application so that

f $ g $ h x = f (g (h x))

so that it's easy to visually see what's up

1 Like