Doubts regarding irand, run and n

After watching the first video about mini notation I was experimenting a bit with n.

d1 $ n "0 1 2 3" # s "kick"

The above should be the same as using run

d1 $ n (run 4) # s "kick"

Then I tried to use irand and this is when I got lost:

d1 $ n (run (irand 4)) # s "kick"


I expected it to generate a random pattern. I got no errors and zero sound.

Then I try switching the patterns

d1 $ s "kick*4" # n (run 4) 

The above is identical to the first and second examples.

I try to introduce irand again

d1 $ s "kick*4" # n (irand 4)

and it worked.

In the last example "kick*4" (the most left of the patterns is the one defining the rests) defines the 4 steps and n is evaluated every time with a new irand value generating a pattern of one single step.

I’m not sure I understand what’s happening in this example: d1 $ n (run (irand 4)) # s "kick".
My reasoning is:

  1. irand 4 generates a random number between 0 and 3
  2. run (irand 4) generated a pattern from 0 to the generated number
  3. n (run (irand 4)) generated my control pattern.

Can anyone shed some light? what am I doing wrong?

1 Like

Hi @ohjimijimijimi,

When you combine patterns, the structure comes from the left. The problem is that irand 4 is a continuous, infinitely detailed stream of numbers, it doesn’t have any pattern. That leads to a run that is continuously changing. Currently when Tidal tries to schedule a continuously varying pattern, it gives up.

You could use segment to ‘sample and hold’ the pattern at a fixed rate, for example once per cycle:

d1 $ n (run (segment 1 $ irand 4)) # s "kick"



Super interesting. So what’s happening here (the comment shows the result of just a straight eval of the pattern):

d1 $ s "kick" # n (run (irand 4))
-- plays every once in a while

s "kick" # n (run (irand 4))
-- tidal>
-- [((1,1),(5,1))](0>⅓)-1|n: 0.0f, s: "kick"
-- [((1,1),(5,1))]0-(⅓>⅔)-1|n: 1.0f, s: "kick"
-- [((1,1),(5,1))]0-(⅔>1)|n: 2.0f, s: "kick"

Is it because the pattern comes from the sound function, and then the randomness is just silencing every once in a while?

This was the result of eval’ing ohjimi*3’s pattern that was just silent:

n (run (irand 4)) # s "kick"
-- tidal>
-- [((1,1),(5,1))]~0>⅓~|n: 0.0f, s: "kick"
-- [((1,1),(5,1))]~⅓>⅔~|n: 1.0f, s: "kick"
-- [((1,1),(5,1))]~⅔>1~|n: 2.0f, s: "kick"
1 Like

Does anyone know what's going on here?

    $ struct ("t*2 [t*2 ~] t(3,8) ~")
    $ n (irand 6) |+ (sine * 5)
      # s "[snare?0.2]"
--    # s "[dsynth?0.2]"   --you can check with another sound with the same results

I've write that piece of code using "snare" sound from Extra-samples folder. If you hush the pattern you can hear a kind of reverse sound that ends few seconds later. But there's no sample like this in any of used folders. What is reversing and repitching that? How n (irand 6) |+ (sine * 5) are working here?

Actually I think that's the point

struct ("t * 2 [t * 2 ~] **t(3,8)** ~")

But still don't understand what's going on and why that sound results

Hi @nuntxaku,

This part is the problem:

n (irand 6) |+ (sine * 5)

n (irand 6) is evaluated first, then |+ (sine * 5). Tidal sees the latter as a control pattern, but there is no function to turn the pattern of numbers into a pattern of synth controls.. So it guesses that it is a speed pattern.

So this should be the same (I just inserted the speed):

    $ struct ("t*2 [t*2 ~] t(3,8) ~")
    $ n (irand 6) |+ speed (sine * 5)
      # s "[snare?0.2]"

But it isn't!! Somehow in your pattern the sine goes from -1 to 1, but in the above it goes from 0 to 1. I'm trying to work out why.. Weird..

Anyway you can fix your pattern with parenthesis, so make sure the sine gets added to the irand before being passed to n.

    $ struct ("t*2 [t*2 ~] t(3,8) ~")
    $ n ((irand 6) |+ (sine * 5))
      # s "[snare?0.2]"
1 Like

Thank you very much!

1 Like