[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



On Wed, 29 Jul 2009 17:38:45 +0100
lists@xxxxxxxxxxx wrote:

> Dear sc-users,
> 
> I would like to know if there is some way to tell when an n_set message has been received and executed by the server, e.g.:
> 
> ~synth = {arg freq=440; SinOsc.ar(freq:freq)}.play;
> 
> ~synth.set("freq", 220);
> 
> // I'd like something like
> ~synth.whenControlsUpdated({"controls updated".postln});
> 
> I've checked out NodeWatchers, but they don't seem to deal with the state of Synth controls.
> _


Hmmm - this seems to work but is clunky:


~synth = {arg freq=440; SinOsc.ar(freq:freq)}.play;

{
  ~wait = true;
  100.do{
	~new_freq = rrand(400, 600);
	~synth.set("freq", ~new_freq);
	("waiting for freq "++~new_freq).postln;
	while({~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;
  };
}.fork;

cheers

- matthew

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