Discussion:
Pif question
Roc
2014-10-21 10:47:23 UTC
Permalink
i have a Pif controlling a parameter of a synth based on duration, so
whenever \dur is above 0.3 it triggers the Pbrown:

Pif(Pbinop('>', Pkey(\dur), 0.3), Pbrown(0.25, 0.8, 0.05), 0.5);

but i'd like to make that more specific, so that whenever \dur is above say
0.5 it runs another pattern instead of the Pbrown above.

mmm?

Roc Jiménez de Cisneros
http://vivapunani.org
@_roc
Fredrik Olofsson
2014-10-21 10:57:26 UTC
Permalink
not 100% sure but do you mean like this?
Pbind(\dur, Pseries(0.1, 0.1, 10), \amp, Pswitch1([Pbrown(0.25, 0.8, 0.05), Pseq([0.1, 0.2, 0.3], inf)], Pkey(\dur)>0.5).trace).play;
when dur is less than 0.5, then use Pbrown for amp. when dur is above 0.5 use the Pseq.
Pswitch1 is very a useful class.
_f
Post by Roc
Pif(Pbinop('>', Pkey(\dur), 0.3), Pbrown(0.25, 0.8, 0.05), 0.5);
but i'd like to make that more specific, so that whenever \dur is above say 0.5 it runs another pattern instead of the Pbrown above.
mmm?
Roc Jiménez de Cisneros
http://vivapunani.org
@_roc
#|
fredrikolofsson.com musicalfieldsforever.com
|#


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Roc
2014-10-21 11:18:20 UTC
Permalink
not quite what i was after, cause i think that's equivalent to what i
already had.
what i want is (warning, pseudocode ahead):

if \dur > 0.3 -----> Pbrown(0.25, 0.8, 0.05)
if \dur < 0.3 -----> 0.5
*but then (this is the tricky bit):*
*if \dur > 0.5 -----> Pbrown(0.1, 0.3, 0.1)*

cheers, Fredrik


Roc Jiménez de Cisneros
http://vivapunani.org
@_roc
Post by Fredrik Olofsson
not 100% sure but do you mean like this?
Pbind(\dur, Pseries(0.1, 0.1, 10), \amp, Pswitch1([Pbrown(0.25, 0.8,
0.05), Pseq([0.1, 0.2, 0.3], inf)], Pkey(\dur)>0.5).trace).play;
when dur is less than 0.5, then use Pbrown for amp. when dur is above 0.5 use the Pseq.
Pswitch1 is very a useful class.
_f
Post by Roc
i have a Pif controlling a parameter of a synth based on duration, so
Pif(Pbinop('>', Pkey(\dur), 0.3), Pbrown(0.25, 0.8, 0.05), 0.5);
but i'd like to make that more specific, so that whenever \dur is above
say 0.5 it runs another pattern instead of the Pbrown above.
Post by Roc
mmm?
Roc Jiménez de Cisneros
http://vivapunani.org
@_roc
#|
fredrikolofsson.com musicalfieldsforever.com
|#
_______________________________________________
sc-users mailing list
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Fredrik Olofsson
2014-10-21 11:56:26 UTC
Permalink
aha, i see. yes, Pswitch1 and Pif are similar.
but then Pswitch1 with a Pfunc maybe...

Pbind(
\dur, Pseries(0.1, 0.05, 20),
\amp, Pswitch1([
0.5,
Pbrown(0.25, 0.8, 0.05), //between 0.3 and 0.5
Pbrown(0.1, 0.3, 0.1) //over 0.5
], Pfunc({|ev|
case
{ev.dur<=0.3} {0}
{ev.dur>0.3 and:{ev.dur<=0.5}} {1}
{ev.dur>0.5} {2};
})).trace
).play;

or shorter...
Pbind(
\dur, Pseries(0.1, 0.05, 20),
\amp, Pswitch1([
0.5,
Pbrown(0.25, 0.8, 0.05), //between 0.3 and 0.5
Pbrown(0.1, 0.3, 0.1) //over 0.5
], Pfunc({|ev| (ev.dur>0.3 and:{ev.dur<=0.5}).binaryValue+((ev.dur>0.5).binaryValue*2)})).trace
).play;

there's probably a more elegant way though...
_f
not quite what i was after, cause i think that's equivalent to what i already had.
if \dur > 0.3 -----> Pbrown(0.25, 0.8, 0.05)
if \dur < 0.3 -----> 0.5
if \dur > 0.5 -----> Pbrown(0.1, 0.3, 0.1)
cheers, Fredrik
Roc Jiménez de Cisneros
http://vivapunani.org
@_roc
not 100% sure but do you mean like this?
Pbind(\dur, Pseries(0.1, 0.1, 10), \amp, Pswitch1([Pbrown(0.25, 0.8, 0.05), Pseq([0.1, 0.2, 0.3], inf)], Pkey(\dur)>0.5).trace).play;
when dur is less than 0.5, then use Pbrown for amp. when dur is above 0.5 use the Pseq.
Pswitch1 is very a useful class.
_f
Post by Roc
Pif(Pbinop('>', Pkey(\dur), 0.3), Pbrown(0.25, 0.8, 0.05), 0.5);
but i'd like to make that more specific, so that whenever \dur is above say 0.5 it runs another pattern instead of the Pbrown above.
mmm?
#|
fredrikolofsson.com musicalfieldsforever.com
|#


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Roc
2014-10-21 12:00:10 UTC
Permalink
aha! i can live without the elegance in this case
thanks, Fredrik!

Roc Jiménez de Cisneros
http://vivapunani.org
@_roc
Post by Fredrik Olofsson
aha, i see. yes, Pswitch1 and Pif are similar.
but then Pswitch1 with a Pfunc maybe...
Pbind(
\dur, Pseries(0.1, 0.05, 20),
\amp, Pswitch1([
0.5,
Pbrown(0.25, 0.8, 0.05), //between 0.3 and 0.5
Pbrown(0.1, 0.3, 0.1) //over 0.5
], Pfunc({|ev|
case
{ev.dur<=0.3} {0}
{ev.dur>0.3 and:{ev.dur<=0.5}} {1}
{ev.dur>0.5} {2};
})).trace
).play;
or shorter...
Pbind(
\dur, Pseries(0.1, 0.05, 20),
\amp, Pswitch1([
0.5,
Pbrown(0.25, 0.8, 0.05), //between 0.3 and 0.5
Pbrown(0.1, 0.3, 0.1) //over 0.5
], Pfunc({|ev| (ev.dur>0.3
and:{ev.dur<=0.5}).binaryValue+((ev.dur>0.5).binaryValue*2)})).trace
).play;
there's probably a more elegant way though...
_f
Post by Roc
not quite what i was after, cause i think that's equivalent to what i
already had.
Post by Roc
if \dur > 0.3 -----> Pbrown(0.25, 0.8, 0.05)
if \dur < 0.3 -----> 0.5
if \dur > 0.5 -----> Pbrown(0.1, 0.3, 0.1)
cheers, Fredrik
Roc Jiménez de Cisneros
http://vivapunani.org
@_roc
On Tue, Oct 21, 2014 at 12:57 PM, Fredrik Olofsson <
not 100% sure but do you mean like this?
Pbind(\dur, Pseries(0.1, 0.1, 10), \amp, Pswitch1([Pbrown(0.25, 0.8,
0.05), Pseq([0.1, 0.2, 0.3], inf)], Pkey(\dur)>0.5).trace).play;
Post by Roc
when dur is less than 0.5, then use Pbrown for amp. when dur is above
0.5 use the Pseq.
Post by Roc
Pswitch1 is very a useful class.
_f
Post by Roc
i have a Pif controlling a parameter of a synth based on duration, so
Pif(Pbinop('>', Pkey(\dur), 0.3), Pbrown(0.25, 0.8, 0.05), 0.5);
but i'd like to make that more specific, so that whenever \dur is
above say 0.5 it runs another pattern instead of the Pbrown above.
Post by Roc
Post by Roc
mmm?
#|
fredrikolofsson.com musicalfieldsforever.com
|#
_______________________________________________
sc-users mailing list
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
James Harkins
2014-10-21 14:13:59 UTC
Permalink
At Tue, 21 Oct 2014 14:00:10 +0200,
Post by Roc
aha! i can live without the elegance in this case
thanks, Fredrik!
For a small number of cases, you can nest Pif.

That is, if you can write:

if(dur < 0.3) {
branch1
} {
if(dur < 0.5) {
branch 2
} {
branch 3
}
}

Then there is no reason why you can't write:

Pif(Pkey(\dur) < 0.3,
branch 1,
Pif(Pkey(\dur) < 0.5,
branch 2,
branch 3
)
)

It may not be super-convenient for large numbers of conditions, but it does work.

hjh



_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Continue reading on narkive:
Loading...