Tidal Synth: how to assign a value to a variable?

Hi everyone! :wave:

I'm trying to assign a frequency list to a variable to simplify coding, but I can't get good results.

Here an example:

let f = [1108.73, 1318.51, 1661.22]

d1 $ s "supersaw" # freq "f*2 f [f [f f]] f"

what am I doing wrong? Help! :smiley:

I think you need special syntax to call a variable inside of a pattern. This discussion seems to be about that but I can't seem to get it working:

edit: also might want to pick a variable other than "f" for inside of a pattern since that can be an f note or a false statement - both of which can be in patterns.

1 Like

Do you want those three frequencies every time with the rhythm in your frequency pattern? Then you could do something like

d1 $ struct "t*2 t [t [t t]] t" $ freq "[1108.73, 1318.51, 1661.22]" # s "supersaw"
1 Like

Thank you @Squim & @bgold for your kind answers!

OP and Squim's reply tempted me into playing with state a bit this morning, so here are a few quick examples based on the above:

If looking to build arps, melodies, etc. from individual reusable values that can be changed and evaluated without having to re-evaluate everything referring to them:

setF "f1" 1108.73
setF "f2" 1318.51
setF "f3" 1661.22

d1 $ freq "[^f1]*2 ^f2 [^f3 [^f1 ^f2]] ^f3" # s "supersaw"

Try changing and re-evaluating just the setF "f1" ... line.

If looking to build chords in much the same way:

-- evaluate either
setF "f4" "[1108.73, 1318.51, 1661.22]"
setF "f4" "[554.37, 1318.51, 1661.22]"

d1 $ freq "[^f4]*2 ^f4 [^f4 [^f4 ^f4]] ^f4" # s "supersaw"

Not far from the arp example you can mess with freqTake (ala "tidal can count".) This example isn't quite doing what I want but I have to start work soon so it is a bit of an exercise for the reader :slight_smile:

d1 $ struct "t*2 t [t [t t]] t" $ freqTake "f0" [1108.73, 1318.51, 1661.22] # s "supersaw"

where freqTake is a convenience wrapper, such that you can build your own if you need one for something not included in tidal itself. It is effectively this:

d1 $ struct "t*2 t [t [t t]] t" $ pStateListF "freq" "f0" [1108.73, 1318.51, 1661.22] # s "supersaw"

Also interesting to explore are functions like bite, fit, ur, etc. though I don't have time this morning to add specific examples here.


Thanks for your examples! The setF keyword looks very useful!