[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] OSCFunc oneShot is breakable because of careless FunctionList implementation

fork {
a = { |gate = 1| (SinOsc.ar(440) * Linen.kr(gate, 0.1, 1, 0.2, doneAction: 2)) ! 2 }.play;
	o = OSCFunc({ |msg| msg.postln; o.free }, '/n_end', s.addr);
	OSCFunc.allFuncProxies.debug("while playing");
	// a.release;

"o" never fires. It doesn't, because the dispatcher for '/n_end' contains a FunctionList of two entries. One of them is a oneShot OSCFunc, created by Function:play.

"oneShot" removes the OSCFunc after it fires.* This modifies FunctionList's array while iterating over it. And we all know what happens when we do that...

* The same would occur if Function:play stored its OSCFunc in a variable, and did "oscfunc.free" inside the OSCFunc. That is, this bug isn't to say that oneShot is a bad idea -- rather, that OSCFunc relies on FunctionList to do its job properly, but it doesn't.

"array.copy.do" would add some overhead to every FunctionList invocation. That's the safest fix, but I suppose it's worth considering the performance impact.

Apologies if there's a slightly cranky tone here. I was just trying to make a plot of some amplitude curves for a class presentation, and... 30 minutes gone to chase down a random problem. I'm getting tired of /debugging/ when I should be /using/. Let's get moving on SC4, and clean up this kind of nonsense?


sc-dev mailing list

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