gbal
1
Hi there -
I have made SynthDefs for both Mono and Stereo audio file playback.
I know I can use some kind of if Statement in SCLang to determine the buffer channel number and pick a synth based on that information.
I’m wondering if I could include something like that in the \instrument key of a Pbind - and how I might go about doing it.
Thank you for the help.
Given that \mono and \stereo are synthdefs and b is a buffer, you can do something like
Pdef(\test, Pbind(
\instrument, Pif(Pfunc{b.numChannels == 1}, \mono, \stereo).trace
)).play
3 Likes
gbal
3
Might there be a way to key in the buffer value from another part of the Pbind?
Something like this doesn’t seem to update the values accordingly:
Pdef(\test, Pbind(
\buf, b[10],
\instrument, Pif(Pfunc{Pkey(\buf).numChannels == 1}, \mono, \stereo).trace
)).play
I modified the example from before, still presuming \mono and \stereo are synthdefs and b a buffer.
Pdef(\test, Pbind(
\buf, b,
\instrument, Pfunc{|ev|if (ev.buf.numChannels == 1) {\mono} {\stereo}}.trace
)).play