[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] how to tell when n_set messages have been executed
I think this might be my first interesting (to anyone but me) post on the list in about 4 years.
Ok - I agree about the obsolete n_get messages, so I think I've done away with them here but I still get several waits on n_set, which is what I'd expect, considering there are loads of messages going backwards and forwards.
~synth = {arg freq=440; SinOsc.ar(freq:freq)}.play;
{
~n_set_wait = true;
~n_get_wait = true;
100.do{
~new_freq = rrand(400, 600);
~synth.set("freq", ~new_freq);
("waiting for freq "++~new_freq).postln;
while({~n_set_wait}, {
~synth.get(\freq, { arg value; (~n_get_wait = false; "freq is "++value).postln;
// now wait for the n_get to return
while({~n_get_wait}, {
"waiting for the n_GET... ".postln;
0.0001.wait;
});
~n_get_wait = true;
// has the synth been updated?
if (value == ~new_freq, {~n_set_wait = false;"Synth control updated!".postln}, {"waiting for n_SET ".postln});
});
0.0001.wait;
});
~n_set_wait = true;
};
}.fork;
cheers
Matthew
On Wed, 29 Jul 2009 21:00:13 +0200
Sciss <contact@xxxxxxxx> wrote:
> i solved the riddle, it's really just a stupidity. compare:
>
> ~synth = SynthDef( \test, {arg frequ=440; Out.ar( 0, SinOsc.ar
> (freq:frequ))}).play;
> (
> ~bndlTime = 0.2;
> Routine({ var resp;
> resp = OSCpathResponder( s.addr, [ '/n_set', ~synth.nodeID ],
> { arg time, resp, msg; var value = msg[ 3 ];
> ("freq is "++value).postln;
> if (value == ~new_freq, {
> ~wait = false;
> "Synth control updated!".postln;
> }, {
> "Value is still %, continueing waiting...\n".postf( value );
> });
> }).add;
> 100.do{ var bndl;
> ~new_freq = rrand(400, 600);
> ~wait = true;
> s.sendBundle( ~bndlTime, ~synth.setMsg("frequ", ~new_freq) );
> while({~wait}, {
> s.sendBundle( ~bndlTime, ~synth.getMsg( \frequ ));
> 0.05.wait;
> });
> };
> resp.remove;
> }).play( SystemClock );
> )
>
> .... with:
>
> (
> ~bndlTime = 0.2;
> Routine({ var resp, cond;
> cond = Condition.new;
> resp = OSCpathResponder( s.addr, [ '/n_set', ~synth.nodeID ],
> { arg time, resp, msg; var value = msg[ 3 ];
> ("freq is "++value).postln;
> if (value == ~new_freq, {
> ~wait = false;
> "Synth control updated!".postln;
> }, {
> "Value is still %, continueing waiting...\n".postf( value );
> });
> cond.test = true; cond.signal;
> }).add;
> 100.do{ var bndl;
> ~new_freq = rrand(400, 600);
> ~wait = true;
> s.sendBundle( ~bndlTime, ~synth.setMsg("frequ", ~new_freq) );
> while({~wait}, {
> s.sendBundle( ~bndlTime, ~synth.getMsg( \frequ ));
> cond.test = false; cond.wait;
> });
> };
> resp.remove;
> }).play( SystemClock );
> )
>
> the mistake in the first version is: you are sending several s_get
> messages out for every new value of ~new_freq; hence although the
> algorithm is stepping forward, there are always a lot of obsolete
> queries coming back that are comparing the previously correct value
> to the now wrong value.
>
> i was right, the new value is _immediately_ set:
>
> ~synth = SynthDef( \test, {arg frequ=440; Out.ar( 0, SinOsc.ar
> (freq:frequ))}).play;
> (
> ~bndlTime = 0.05;
> Routine({ var resp, cond;
> cond = Condition.new;
> resp = OSCpathResponder( s.addr, [ '/n_set', ~synth.nodeID ],
> { arg time, resp, msg; var value = msg[ 3 ];
> ("freq is "++value).postln;
> if (value == ~new_freq, {
> ~wait = false;
> "Synth control updated!".postln;
> }, {
> "Value is still %, WRONG!! ...\n".postf( value );
> });
> cond.test = true; cond.signal;
> }).add;
> 100.do{ var bndl;
> ~new_freq = rrand(400, 600);
> ~wait = true;
> "Next freq is %\n".postf( ~new_freq );
> s.sendBundle( ~bndlTime, ~synth.setMsg("frequ", ~new_freq),
> ~synth.getMsg( \frequ ) );
> cond.test = false; cond.wait;
> };
> resp.remove;
> }).play( SystemClock );
> )
>
>
> woooooop.....
>
> ciao, -sciss-
>
>
> Am 29.07.2009 um 20:42 schrieb Sciss:
>
> > ~synth = {arg frequ=440; SinOsc.ar(freq:frequ)}.play;
> >
> > (
> > ~bndlTime = 0.2;
> > Routine({
> > ~wait = true;
> > 100.do{
> > ~new_freq = rrand(400, 600);
> > s.makeBundle( ~bndlTime, { ~synth.set("frequ", ~new_freq) });
> > ("waiting for freq "++~new_freq).postln;
> > while({~wait}, {
> > (s.options.blockSize*2/s.sampleRate).wait;
> > s.makeBundle( ~bndlTime, { ~synth.get(\frequ, { arg value;
> > ("freq is "++value).postln;
> > // has the synth been updated?
> > if (value == ~new_freq, {~wait = false;"Synth control
> > updated!".postln}, {"waiting... ".postln});
> > })});
> > // 0.0001.wait;
> > });
> > ~wait = true;
> > };
> > }).play( SystemClock );
> > )
> >
> > Am 29.07.2009 um 20:20 schrieb James Harkins:
> >
> >> Since you're not timestamping your OSC messages, probably the
> >> actual execution time of the n_get is wrong.
> >> hjh
> >>
> >>
> >> On Wed, Jul 29, 2009 at 1:23 PM, Sciss <contact@xxxxxxxx> wrote:
> >> totally strange. even if you initially wait _two_ control blocks,
> >> the reported value might still not have been updated:
> >>
> >>
> >> ~synth = {arg freq=440; SinOsc.ar(freq:freq)}.play;
> >>
> >> (
> >> Routine({
> >>
> >> ~wait = true;
> >> 100.do{
> >> ~new_freq = rrand(400, 600);
> >> ~synth.set("freq", ~new_freq);
> >> ("waiting for freq "++~new_freq).postln;
> >> while({~wait}, {
> >> (s.options.blockSize*2/s.sampleRate).wait;
> >>
> >> ~synth.get(\freq, { arg value; ("freq is "++value).postln;
> >> // has the synth been updated?
> >> if (value == ~new_freq, {~wait = false;"Synth
> >> control updated!".postln}, {"waiting... ".postln});
> >> });
> >> // 0.0001.wait;
> >> });
> >> ~wait = true;
> >> };
> >> }).play( SystemClock );
> >> )
> >>
> >> i.e. i still get "waiting..." here a lot. something with the
> >> server scheduling must be definitely be broken, i assume?
> >>
> >> ciao, -sciss-
> >>
> >>
> >>
> >> --
> >> James Harkins /// dewdrop world
> >> jamshark70@xxxxxxxxxxxxxxxxx
> >> http://www.dewdrop-world.net
> >>
> >> "Come said the Muse,
> >> Sing me a song no poet has yet chanted,
> >> Sing me the universal." -- Whitman
> >
> >
> > _______________________________________________
> > sc-users mailing list
> >
> > info (subscription, etc.): http://www.beast.bham.ac.uk/research/
> > sc_mailing_lists.shtml
> > archive: https://listarc.bham.ac.uk/marchives/sc-users/
> > search: https://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: https://listarc.bham.ac.uk/marchives/sc-users/
> search: https://listarc.bham.ac.uk/lists/sc-users/search/
>
--
<lists@xxxxxxxxxxx>
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/