Discussion:
UGen as "start" argument of PulseDivider?
vividsnow
2014-09-13 13:34:46 UTC
Permalink
hi!

Looks like "start" argument of PulseDivider can be only a plain integer (not ar/kr ugen).
I wonder, is it hard to fix/implement ugen usage as "start" argument?

best regards

_______________________________________________
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/
myma
2014-09-13 19:24:55 UTC
Permalink
unsubscribe sc-users
Post by vividsnow
hi!
Looks like "start" argument of PulseDivider can be only a plain integer (not ar/kr ugen).
I wonder, is it hard to fix/implement ugen usage as "start" argument?
best regards
_______________________________________________
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/
Daniel Mayer
2014-09-13 21:09:32 UTC
Permalink
Hi,

one way to handle this would be an array of PulseDividers
with all possible offsets to choose from.

(
SynthDef(\offsetSwitcher, { |out = 0, offset = 3|
var p, a, b, div;
p = Impulse.ar(8);
div = Select.ar(offset, (0..3).collect { |i| PulseDivider.ar(p, 4, i) });
a = SinOsc.ar(1200, 0, Decay2.ar(p, 0.005, 0.1));
b = SinOsc.ar(600, 0, Decay2.ar(div, 0.005, 0.5));
Out.ar(0, [a, b] * 0.4 * EnvGate())
}).add;
)

// start and trigger different offsets

x = Synth(\offsetSwitcher)

x.set(\offset, 0)

x.set(\offset, 1)

x.set(\offset, 2)

x.set(\offset, 3)


x.release


Of course the offset switch might be defined within the SynthDef also.
In general the more refined trigger sequences you want the more
I'd go for a pattern solution, if this is feasible in your application.


Greetings

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------


_______________________________________________
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/
Daniel Mayer
2014-09-14 01:52:23 UTC
Permalink
Post by Daniel Mayer
Of course the offset switch might be defined within the SynthDef also.
To be exact, Select's 'which' arg can be a ugen and then does what
you want.

Here coupled pitch and offset, the more pitch changes the more
often the syncing is changed

(
SynthDef(\lfo_offsetSwitcher, { |out = 0, pulseFreq = 20, lfoFreq = 1|
var p, a, b, offset, div;
p = Impulse.ar(pulseFreq);
offset = LFDNoise3.ar(lfoFreq, 2, 3.5);
div = Select.ar(offset, (0..3).collect { |i| PulseDivider.ar(p, 4, i) });
a = SinOsc.ar(800 - (offset * 150), 0, Decay2.ar(p, 0.005, 0.1));
b = SinOsc.ar(500 + (offset * 150), 0, Decay2.ar(div, 0.005, 0.5));
Out.ar(0, [a, b] * 0.4 * EnvGate())
}).add;
)

// start and change lfoFreq

x = Synth(\lfo_offsetSwitcher)


x.set(\lfoFreq, 5)


x.release


Greetings

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------


_______________________________________________
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/
vividsnow
2014-09-14 10:11:02 UTC
Permalink
Hello, Daniel

Thanks for answer, but I'm looking for more general solution.

I came up to:

(PulseCount.kr(trig) + start % div).sign bitXor: 1 bitAnd: trig; // emulates PulseDivider.kr(trig, div, start) but with possible ugen in "start" argument

, but got different phase (randomly?) between original and emulated PulseDivider when changing "div" argument:

//
(x = { var freq = 8,
trig = Impulse.kr(freq),
div = MouseX.kr(1,4).round,
start = 0,
pd_orig = PulseDivider.kr(trig, div, start),
pd_emul = (PulseCount.kr(trig) + start % div).sign bitXor: 1 bitAnd: trig;
SinOsc.ar(90, 0, 4).tanh * Decay2.ar(T2A.ar([pd_orig, pd_emul]), 0.03, 1/freq) / 2
}.asSynthDef.name_("temp_divider").add.play)

x.free;
//

Looks like PulseDivider ugen uses different algorithm(?)
Post by Daniel Mayer
Hi,
one way to handle this would be an array of PulseDividers
with all possible offsets to choose from.
(
SynthDef(\offsetSwitcher, { |out = 0, offset = 3|
var p, a, b, div;
p = Impulse.ar(8);
div = Select.ar(offset, (0..3).collect { |i| PulseDivider.ar(p, 4, i) });
a = SinOsc.ar(1200, 0, Decay2.ar(p, 0.005, 0.1));
b = SinOsc.ar(600, 0, Decay2.ar(div, 0.005, 0.5));
Out.ar(0, [a, b] * 0.4 * EnvGate())
}).add;
)
// start and trigger different offsets
x = Synth(\offsetSwitcher)
x.set(\offset, 0)
x.set(\offset, 1)
x.set(\offset, 2)
x.set(\offset, 3)
x.release
Of course the offset switch might be defined within the SynthDef also.
In general the more refined trigger sequences you want the more
I'd go for a pattern solution, if this is feasible in your application.
Greetings
Daniel
-----------------------------
www.daniel-mayer.at
-----------------------------
_______________________________________________
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/
_______________________________________________
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/
Fredrik Olofsson
2014-09-14 13:16:04 UTC
Permalink
if pulsecount and pulsefivider give you a hard time, then perhaps try a more 'manual' approach. like this...

(
x= {|t_start= 0, div= 8|
var pd;
var trg= Impulse.kr(10);//main trigger to be divided
var start= MouseX.kr(2, div).round;
var cnt= LocalIn.kr(1, start);
cnt.poll;
cnt= Select.kr(t_start, [cnt+trg, start]);
LocalOut.kr(cnt);
pd= cnt%div<1;//pulse divider
SinOsc.ar([400, 404], 0, Decay2.ar(T2A.ar(pd), 0.01, 0.02));
}.play(fadeTime: 0);
)
x.set(\t_start, 1)//move mouse full left - should restart at 2
x.set(\t_start, 1)//move mouse full right - should restart imideately (at 8 - highest possible div)

can only go down to div= 2 though. to trigger on each (div= 1) you'd have to change the pd part slightly.
_f
Post by vividsnow
Hello, Daniel
Thanks for answer, but I'm looking for more general solution.
(PulseCount.kr(trig) + start % div).sign bitXor: 1 bitAnd: trig; // emulates PulseDivider.kr(trig, div, start) but with possible ugen in "start" argument
//
(x = { var freq = 8,
trig = Impulse.kr(freq),
div = MouseX.kr(1,4).round,
start = 0,
pd_orig = PulseDivider.kr(trig, div, start),
pd_emul = (PulseCount.kr(trig) + start % div).sign bitXor: 1 bitAnd: trig;
SinOsc.ar(90, 0, 4).tanh * Decay2.ar(T2A.ar([pd_orig, pd_emul]), 0.03, 1/freq) / 2
}.asSynthDef.name_("temp_divider").add.play)
x.free;
//
Looks like PulseDivider ugen uses different algorithm(?)
#|
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/
vividsnow
2014-09-14 14:47:55 UTC
Permalink
Hi, Fredrik

Thank you for proposal. Actually, I don't want resets/restarts, since I'm working with server-side running
"beat grid" which requires precise positions of pulses. (rough prototype: http://sccode.org/1-4Wm)
Now, hopefully, I'm ok with my solution - it supports "div"=1 and ugens as arguments.
Just don't understand logic of PulseDivider when "div" argument is changed, looks like it resets someway.
Post by Fredrik Olofsson
if pulsecount and pulsefivider give you a hard time, then perhaps try a more 'manual' approach. like this...
(
x= {|t_start= 0, div= 8|
var pd;
var trg= Impulse.kr(10);//main trigger to be divided
var start= MouseX.kr(2, div).round;
var cnt= LocalIn.kr(1, start);
cnt.poll;
cnt= Select.kr(t_start, [cnt+trg, start]);
LocalOut.kr(cnt);
pd= cnt%div<1;//pulse divider
SinOsc.ar([400, 404], 0, Decay2.ar(T2A.ar(pd), 0.01, 0.02));
}.play(fadeTime: 0);
)
x.set(\t_start, 1)//move mouse full left - should restart at 2
x.set(\t_start, 1)//move mouse full right - should restart imideately (at 8 - highest possible div)
can only go down to div= 2 though. to trigger on each (div= 1) you'd have to change the pd part slightly.
_f
Post by vividsnow
Hello, Daniel
Thanks for answer, but I'm looking for more general solution.
(PulseCount.kr(trig) + start % div).sign bitXor: 1 bitAnd: trig; // emulates PulseDivider.kr(trig, div, start) but with possible ugen in "start" argument
//
(x = { var freq = 8,
trig = Impulse.kr(freq),
div = MouseX.kr(1,4).round,
start = 0,
pd_orig = PulseDivider.kr(trig, div, start),
pd_emul = (PulseCount.kr(trig) + start % div).sign bitXor: 1 bitAnd: trig;
SinOsc.ar(90, 0, 4).tanh * Decay2.ar(T2A.ar([pd_orig, pd_emul]), 0.03, 1/freq) / 2
}.asSynthDef.name_("temp_divider").add.play)
x.free;
//
Looks like PulseDivider ugen uses different algorithm(?)
#|
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/
_______________________________________________
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/
Daniel Mayer
2014-09-14 17:47:04 UTC
Permalink
Post by vividsnow
Hello, Daniel
Thanks for answer, but I'm looking for more general solution.
(PulseCount.kr(trig) + start % div).sign bitXor: 1 bitAnd: trig; // emulates PulseDivider.kr(trig, div, start) but with possible ugen in "start" argument
Elegant !
seems so - probably a different reset convention as you say.


Regards

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------


_______________________________________________
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/

Loading...