Tidal icon indicating copy to clipboard operation
Tidal copied to clipboard

Trigger tidal statements with osc controls

Open thgrund opened this issue 3 years ago • 0 comments

We started a discussion on the club forum about this topic under https://club.tidalcycles.org/t/trigger-tidal-code-with-midi/2168

What we want to achieve is basically the exchange/replacement of patterns with patterns. And maybe this feature should be implemented directly in TidalCycles with a simple interface. I would like to discuss this here at this point.

My approach for this is:

import qualified Data.Vector as V

capply condpat pvector =  
      condpat >>= \ i -> pvector V.! (mod i (V.length pvector))

pattern1 = s "bd*4" 
pattern2 = s "cp*4"
pattern3 = s "808*4"
pattern4 = s "hh*4"

let pvector = V.fromList [pattern1, pattern2, pattern3, pattern4]

Of course for an implementation in TidalCycles something like fromList should be wrapped/hidden.

With this solution you could do something like this:

d1 $ capply "<0 1 2 3>" pvector 

And it is totally fine to control these with osc controls like:

d1 $ capply (cI 0 "test") pvector 

The problem with this solution is currently that we are not able to access the IO-function level. For this reason it is not possible to use transitions, but it is also not possible to use functions like trigger because the TidalCycles clock continues to run in the background while switching between patterns. I would prefer to stay in the pattern context to achieve such a behaviour and would avoid to build a custom osc controller to control IO functions.

I still came across this issue: https://github.com/tidalcycles/Tidal/issues/483 I can imagine that something like patternIO :: IO (Pattern (IO ()) -> IO ()) could be the trick for trigger such IO functions as patterns with patterns. But I guess this is actually planed for using IO actions like reading a file. But maybe this works for triggering a transition like xfade inside d1?

thgrund avatar Sep 20 '20 10:09 thgrund