Making something happen IF something else does something

Hi,

Not sure if this is easy to do in Tidal or not as i've only just started learning it, but if i wanted say an event to fire only IF another condition has been met, how would i go about this?

e.g play this hihat pattern only when a random number choice is below 30... or something

thanks in advance :slight_smile:
Chris

I’m away from where I could test this, but you should be able to achieve that with something like:

mask ((< 30) <$> irand 100) "hh*16"

Noting, of course, that there may be a more dedicated function which streamlines this further.

thanks - its not quite doing what I hoped but it is cool (even though I don't know what <$> means...)

I was thinking more like the whole pattern will play or not play, at the moment only parts of the pattern are playing, not the whole thing.

You can replace that irand 100 pattern with whatever pattern you like. So if you want to have it randomly start or stop on a per cycle basis, you could do that. Or a four-cycle basis, or whatever you like. Or in combination with some external control. It really all depends on what exactly you are trying to achieve.

As for <$>, that’s the infix notation for the function called fmap. You can think of it as allowing you to apply a function to the values within a structure of some kind. In this case, we’re using it to apply a comparison function of (< 30) to each of the events within the pattern irand 100.

1 Like

You might be looking for fix

The example in the documentation goes like this

d1 $ slow 2 $ fix (# crush 3) (n "[1,4]") $ n "0 1 2 3 4 5 6" # sound "arpy"

I like doing things like this

d1
  $ fix (echo 16 0.125 (slow 4.3 $ saw)) (n "[1,3]")
  $ n (irand 8) >| s "arpy*8"
  # octave 4
1 Like