Variable Help

Before I give up on Tidal, i figired I’d come here and ask for help and clarify whether what i want do do is possible or not within Tidal.

What i want to do is randomly choose a key and randomly choose a scale. I want to be able to update that random choice on the fly, but not constsntly.

I want this Tidal code to work, but it doesn’t.

d1 $ n (scale scaleVariable "0..7") # sound "superpiano" |+ note keyVariable

From what I’ve been able to surmise, my issues stem from Haskell being Haskell and seem unavoidable.

Setting keyVariable using Tidal’s randkmization results in irand being called every cycle and the key changing everytime, not when I want it to.

I found a way around this and can get a random number to set the key from Haskells System.Random. But, Tidal needs a pattern type for the octave shifter. Is there a simple Intrger to Patter function?

Even if there is a function that changes the key type, the scaleVariable I can’t get to work at all. I can get the variable set such that it prints in a way that I think it should work, but pluging it into the scale function causes a syntax/pattern error (if I remember correctly).

I think ultimately, Tidal and Haskell just aren’t the right tool for me (I’m more interested in algorithmic composition than live coding). I really like Tidal, but I think I gotta move on.

Thanks for any help in pointing out something I might be missing though!

Hi @evanforry ,

If you can share a full example that you’d like to work, then I’d be happy to have a look at fixing it. To turn a number into a pattern of numbers, you can use the pure function.

You could also search this forum for randomRIO to find some examples of using one-shot pseudorandom numbers in patterns.

key <- randomRIO (0,11)

colors = [ "major", "minor" ]
  
colorCode <- randomRIO (0,1)
  
colorMain = (colors!!fromInteger(colorCode))

d1 $ n (scale colorMain "0..7") # sound "superpiano" |+ note key

I import System.Random in BootTidal.hs.

This runs:

d1 $ n (scale "major" "0..7") # sound "superpiano" |+ note (fromInteger(key))

So, fromInteger seems to fix the key setting. However, I’m doing something wrong and the octave shifter is causing only one note to be played.

Replacing “major” with colorMain seems to work now. I guess I misread some error messages.

And now I just realized n and note can’t be used interchangeably.

This fully works now:

d1 $ note (scale colorMain "0..7") # sound "superpiano" |+ note (fromInteger(key))

I guess all I needed was to talk it through, lol. Thanks!

1 Like