I want to set Pfunc with arg.
What is the problem is this ??
First, can I suggest that you post code excerpts between triple backticks?
```
your code
```
When you post screenshots of code, then the only way people can try your code is by typing it manually. Copy/paste is much faster. (So, the screenshot means fewer people will be willing to help you, if they don’t have time to retype.)
Second… the problem here is:
- Pwhite is a pattern.
-
<
is a math operator which, applied to a pattern, is itself a pattern (Pbinop). -
asInteger
is not a math operator, and patterns don’t know what to do with it.
The solution is to perform asInteger
on the resulting values, not the pattern itself.
~ptrig_maker = { |thre| (Pwhite(0.0, 1.0, inf) < thre).collect { |value| value.asInteger } };
It happens that we already have a unary operator for this function, though:
~ptrig_maker = { |thre| Pn(thre, inf).coin };
Also, ~ptrig_maker returns a function – so there is no need to wrap it in another layer of Pfunc.
\ptrig, ~ptrig_maker.(0.1), // NO Pfunc here!
hjh
Thank you suggestion , i’ll do it.
and thank you detail explanation.
it worked !!
Finally , i tried setting argument .
~eqC[1] is changing value , so i set ~ptrig_maker in Pfunc.
Is this something misunderstood ?
(
Pbindef(\pdef_hiNoise,
\instrument, "hiNoise",
\sustain, Prand([ 1/4 , 1/4 ],inf) ,
\pan , Pwhite(0,0,inf) ,
\dur, ~pp ,
\ptrig , 1 ,
\effectfreq , 20000,
\amp, 1,
\update, Pfunc( { |e| e.amp= ~amps[1];
e.effectfreq= ~eqA[1];
e.ptrig = ~ptrig_maker.( ~eqC[1] ) ;
})
);
);
The result is that the event contains the trigger pattern, but it needs to contain the trigger value.
The reason why the first case with Pfunc worked is because the ~variable being accessed contained the value that you wanted.
But now the ~thing is making a pattern – so the scenario is not the same, and the same solution (wrap the whole thing in Pfunc) is not valid for the new scenario.
Using your original formulation, you’re looking for Pwhite(0.0, 1.0, inf) < thre
where thre
is taken from ~eqC[1]
.
And you know how to “patternize” a variable/array access by wrapping in Pfunc.
So one solution is to wrap only the access in Pfunc, and embed that in the expression: Pwhite(0.0, 1.0, inf) < Pfunc { ~eqC[1] }
.
Or, as noted, “coin” covers the comparison so you could reduce that to Pfunc { ~eqC[1] }.coin
.
You’ve accidentally found one of the bad points about patterns: while many operations can be automatically folded into patterns, some can’t, and the boundary isn’t always clear… so don’t feel bad. This is not at all clear to figure out on your own.
hjh
Oh , pattern or pattern value … I became a little bit clear about this.
Thank you for kindly helping . I keep learn .
Thank you every time , amshark70 !!
Finally , went well.
~ptrig_maker = { |thre| ( Pwhite(0.0, 1.0, inf) < thre ).collect { |value| value.asInteger }; };
//synth 1
(
Pbindef(\pdef_hiNoise,
\instrument, "hiNoise",
\sustain, Prand([ 1/4 , 1/4 ],inf) ,
\pan , Pwhite(0,0,inf) ,
\dur, ~pp ,
\ptrig , ~ptrig_maker.( Pfunc{~eqC[1]} ) , //( Pwhite(0.0, 1.0, inf) < Pfunc { ~eqC[1] } ).asInteger ,
\effectfreq , 20000,
\amp, 1,
\update, Pfunc( { |e| e.amp= ~amps[1];
e.effectfreq= ~eqA[1];
//e.ptrig = (Pwhite(0.0, 1.0, inf) < ~eqC[1] ).collect { |value| value.asInteger } ;
[ " "+e.ptrig].postln ;
})
);
);