Working with Tidal state values - Tidal can count!

Here's a quick explanation of the new state stuff in Tidal 1.7.2 . It's still in flux and might change a bit in the next version.

First here my slides from the tidal meetups, it might not make perfect sense on its own, but questions welcome:

and here's the demo file. Not too musical but with a nice percussive set this gets wild pretty quickly!


-- So what's the problem?
-- It's tricky to get events to line up, lets say you wanted to
-- pattern the structure independently from the notes (isorhythm?):
d1 $ slow 2 $ sound "alphabet(5,8)" # n "0 .. 4"

-- There are ways to fix this (e.g. with the 'fix' function), but they are not too satisfying/easy.

-- But now you can...

-- Use a state value called "susan" to take values from a (circular) list

d1 $ sound "alphabet(5,8)" # nTake "susan" [0 .. 4]

-- If you change it on-the-fly then you have to wait for the list to
-- empty before it changes:
d1 $ sound "alphabet(5,8)" # nTake "susan" [7]

-- It can cope with infinite lists, but then the list will never empty.
d1 $ sound "alphabet(5,8)" # nTake "susan" [0 ..]

-- You can stop it:

-- And it will always start from where it left off:
d1 $ sound "alphabet(5,8)" # nTake "susan" [0 ..]

-- You can also just count without a list:
d1 $ sound "alphabet(5,8)" # nCount "harold"

-- This is the same named state as used by setF and for reading from
-- OSC/MIDI. So you can reset the counter like this:
setF "harold" 0

-- Or have another pattern use it:
d2 $ sound "newnotes*16" # n "^harold" # gain 1

-- There is also 'nCountTo' to counting to a modulo:
d1 $ struct "t(7,12,3)" $
  sound "gretsch"
  # nCountTo "rachael" 5

-- You can pattern that.. It starts behaving in ways you wouldn't
-- expect from a Tidal perspective though.. Because the counter runs
-- independently from the pattern:
d1 $ struct "t(7,12,3)" $
  sound "gretsch"
  # nCountTo "rachael" "<4 8>"

-- Likewise, 'rev' won't reverse the counter:

-- notes go up
d1 $ sound "newnotes(5,8)" # nCount "harold"

-- the structure is reversed, but the notes still go up
d1 $ rev $ sound "newnotes(5,8)" # nCount "harold"

-- you should be able to add 'Take' to any control, and Count /
-- CountTo to any numerical control. 

-- This feature is unstable, so these names might change.
20 Likes

Yaaaay! Thank you for the writeup @yaxu.

1 Like

@kit-christopher and I were wondering, many numerical effect controls use the 0-1 range, is there a way to control these if the new counting functions are counting integers?

This is all super new but I think panCountTo "panc" 8 |/ pan 7 would go from 0 .. 1 in eight steps.

Please do post 'how do I do this' questions about state as it really helps think through how to develop the interface for this..

1 Like

A post was split to a new topic: Dealing with envelopes

Is there a way to log the value of "i" in the following code?

It's hard for me to keep track of "i" in cases like:

d2 $ every 2 (+ nCount "i") $ s "sn*3"

I guess by log you mean that you want to see the current value of i?

there is this issue about showing state:

So you could just use the following in your case:

import Control.Concurrent.MVar

import Data.Map as Map

fmap (Map.lookup "i") (readMVar $ sStateMV tidal)

That's really exciting! Maybe it would even be possible to "stream" a pattern, if that makes sense?