Custom parameters

Hi,

I’m trying to understand how to implement effects with my own parameters so that I could eventually write something like

d1 $ somepattern # myeffects # myparam 123

My current attempt which runs but ignore my param is as follows (this calls effects on pattern and then tries to apply params):

let effects p = p # cutoff (cF 400 "mycutoff") # resonance (cF 0.2 "myresonance")
d1 $ effects riff # pF "mycutoff" 100

Inspecting the Arc I can see that mycutoff is set as I ask, but that cutoff has already been bound to the default 400:

(0>⅛)|cutoff: 400.0f, mycutoff: 100.0f, note: 0.0n (c5), resonance: 0.2f

Is there a correct way to delay evaluation of the effects body until after the right-most pF “mycutoff” 100 has been evaluated? Alternatively is there an entirely different implementation pattern that I should be following?

Thank you!

i think you might be confusing the cF and pF functions, the ‘c’ standing for control and the ‘p’ for parameter. cF is only used to get a value from outside of the pattern into it (via streamSet or similar). if i understand correctly what you want to do, try this:

let mycutoff = pF “mycutoff”
myresonance = pF "myresonance"
d1 $ riff # mycutoff 100 # myresonance 0.2

Thank you for your suggestion and yes, I’m not surprised if I’m confusing the behavior of various functions.

However, I’m a bit unclear about the expectations of your suggestion. Isn’t

let mycutoff = pF “mycutoff”
    myresonance = pF "myresonance"
d1 $ riff # mycutoff 100 # myresonance 0.2

equivalent to

d1 $ riff # pF "mycutoff" 100 # pF "myresonance" 0.2

which is what I already had?

Also, these expressions also don’t include my effects, so I’m not sure how to use your suggestion to configure effects.

Stepping back, maybe an alternative, hopefully clearer way of restating my main question is: How do I define my own custom parametrized effects function in Tidal? I want these parameters to have defaults, and also to be able to set/update them later.

I want to do this in Tidal, but as way of analogy in SuperCollider you can define

SynthDef(\testSynth, { |out, freq=440|
	Out.ar(out, SinOsc.ar(freq));
}).add;

and then update freq later:

a = Synth(\testSynth);
a.set(\freq, 880); // Update freq for a from the default 440 to 880

(and yes I understand this is Synth rather than an effects/processor but hopefully you see what I mean).

I want to write something similar in Tidal (this is invalid, but providing as an illustration of what I’m hoping to do):

let effects p mycutoff=400 myresonance=0.2 = p # cutoff mycutoff # resonance myresonance

and I want to use this like this:

d1 $ somepattern # effects # mycutoff 123

and ultimately use mininotation for the parameters, e.g. something like:

d1 $ somepattern # effects # mycutoff "[123 456]*4"

Thank you again for your feedback and please let me know if I’m not explaining myself well.

yes i was thinking that you probably really want the defaults. that is kindof tricky, since haskell itself doesn’t really support defaults for defined functions. would the following work for you?

let effects = pF “mycutoff” 400 # pF “myresonance” 0.2 --define the defaults
mycutoff = pF “mycutoff”
myresonance = pF "myresonance"
d1 $ riff # effects # mycutoff 100 -- should have default resonance with cutoff of 100