{
   "description" : "In this code, I have a list of frequencies. \r\nWhen I am calling \\synthexample, I provide some parameters, the usual ones (amp, etc) and other like bb and threshold.\r\nThe bb parameter is taken into account and works.\r\nAnd the threshold parameter is passed to a function which goal is to pick a frequency on a list of frequencies that is greater or equal to the threshold value. \r\nThe problem is that the threshold value is not taken into account. It works only if I pass to the function a litteral value, such as 200.\r\nAlso passing \\threshold.ir(100) raises an exception at Command+Enter time.\r\n\r\nSo how to pass a parameter to a function called inside a SynthDef ?\r\n\r\nThank you !",
   "ancestor_list" : [],
   "name" : "[beginner question]  how to transmit parameter value to a function inside a SynthDef",
   "author" : "pictosonic",
   "code" : "~freqgold = List[ 29.034441847481, 58.068883694963, 116.13776738993, 232.27553477985, 464.5510695597, 929.1021391194, 1858.2042782388, 3716.4085564776, 7432.8171129552, 14865.63422591, 29731.268451821 ];\r\n\r\n\r\n~getFirstFreq = { | array = #[0], seuil = 0 |\r\n\tvar rfreq=0;\r\n\tvar i=0;\r\n\twhile({ (rfreq==0) && (i < array.size()) }, { if( array[i] >= seuil , { rfreq=array[i];  }, { } ); i = i+1 });\r\n\trfreq.postln;\r\n\tif( rfreq == 0,\r\n\t\t{ rfreq=array[array.size()-1] },\r\n\t\t{ rfreq }\r\n\t\t)\r\n};\r\n\r\n\r\nSynthDef(\\synthexample, { |out, sustain = 1, amp = 0.5, bb = 5, threshold = 500|\r\n\tvar env = Env.adsr(\\atk.ir(0.05), \\dec.ir(0.5), \\slev.ir(0.4), \\rel.ir (1) ).ar(Done.freeSelf, \\gate.kr (1));\r\n\tvar modHz = XLine.kr(1, bb, 10);\r\n\tvar mod = SinOsc.ar(modHz, mul: 3);\r\n\tvar f  = ~getFirstFreq.value(~freqgold, \\threshold);\r\n\tvar sig = SinOsc.ar([f, f+mod], mul: 0.2  ) * amp * env;\r\n    Out.ar(out, sig );\r\n}).add;\r\n\r\n\r\n(instrument: \\synthexample,  atk: 0.01, rel: 40, amp: 0.5, bb: 2, threshold: 500).play;",
   "id" : "1-5hJ",
   "is_private" : null,
   "labels" : [
      "parameter"
   ]
}
