SuperCollider Forum
May 21, 2013, 06:22:33 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: The SuperCollider forum is currently experiencing a rash of spambot registrations. New user requests may not be approved quickly as a result -- and if your email address looks like spam, it might not be approved at all. We are working to improve the security of the registration process, and to provide alternate means to contact the administrators to get a new account. Thanks for your patience.
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Unwanted synth buildup: Problem with FreeSelf routine?  (Read 2260 times)
0 Members and 1 Guest are viewing this topic.
bitbutter
Newbie
*

Karma: 0
Posts: 20


View Profile
« on: September 18, 2008, 06:14:18 AM »

I've been trying to create a synth that will ultimately control the playback of audio from a wave file. The synth is currently called quantizedbleep (it just plays a random sine tone).

With James' help I've managed to get play/stop commands to this voice time-quantized to the tick of a second 'metronome' synth.

I want to only play one note at once, but have a tiny bit of overlap so i can have a tiny fade in/out on each note to avoid clicks.

So when I want to trigger a new 'note', i first send a set gate 0 command to the old instance of the synth, (which should ultimately result in that node being deallocated), and then i instantiate a new instance of the synth.

Triggering new notes this way works as expected if i just do this once between each metronome click: the synth count always settles at 2 (one metronome synth and one quantizedbleep synth).

But if i trigger notes this way several times between metronome pulses, unwanted synths get left behind on the server. I'm not sure why this is happening; i thought that the FreeSelf routine I have would keep unwanted synths from building up in the case of multiple notes being requested inbetween metronome pulses.

Apologies for the complexity of this example:

Code:
(
var metronome_bus;
s = Server.local;
s.reboot;
s.waitForBoot({

// A metronomic pulse
SynthDef("metronome", { arg hz,metronome_bus;
var im=Impulse.ar(hz, 0.0, 1);
OffsetOut.ar(metronome_bus,im);
Out.ar(0,im);
}).send(s);

// Beep note on/note offs should be carried out on the next metronome tick
SynthDef("quantisedbeep", { arg gate=1,metronome_bus;
var quantizedgate=SetResetFF.ar(
Trig.ar(gate,4)*(In.ar(metronome_bus)),
Trig.ar((gate-1).abs,4)*(In.ar(metronome_bus))
);
var env=Env.asr(0.005, 0.5, 0.005, 1, 'linear');
var env_gen=EnvGen.kr(env, gate: quantizedgate, doneAction: 2);
var sine = SinOsc.ar(Rand(800.0, 900.0),0,0.5);
var note = (sine)*(env_gen);
// Free the node if a gate off is received before quantizedgate is turned on
FreeSelf.kr(
((quantizedgate-1).abs)*((gate-1).abs);
);
Out.ar(0,note);
}).send(s);

SystemClock.sched(0.5,
{
m=Bus.audio(s);
t=Synth(\metronome,[\hz,0.25,\metronome_bus,m]);}
);

})
)

(
// Run this in one go. I expected the Synth count to settle on 2 (one metronome and one quantizedbleep). But instead, other unreferenced synths are accumulating left on the server.
x.set(\gate,0);
x=Synth("quantisedbeep",[\metronome_bus,m], s, \addToTail);
x.set(\gate,0);
x=Synth("quantisedbeep",[\metronome_bus,m], s, \addToTail);
x.set(\gate,0);
x=Synth("quantisedbeep",[\metronome_bus,m], s, \addToTail);
)

Can anyone see why the synths are building up here?
Logged
dewdrop_world
AdminGroup
Full Member
*

Karma: 9
Posts: 193



View Profile WWW
« Reply #1 on: September 22, 2008, 07:40:50 PM »

Hmm... The most likely explanation is that SetResetFF is probably receiving the set and reset triggers at the same time (in the same control cycle). I'm not sure exactly what happens in that case, but I would guess that the ugen never returns 1.0 and that probably causes FreeSelf not to fire.

Sorry I don't have time at the moment to work out a fix, but I'd start by looking at this aspect.

James
Logged

bitbutter
Newbie
*

Karma: 0
Posts: 20


View Profile
« Reply #2 on: September 23, 2008, 05:32:55 AM »

Thanks James. To test what you said i ran the same code but called the voice off/on command pairs seperately (not as part of the same code block), but still between metronome ticks. When I did it this was I got the expected result (synth count always settles at two), which seems to confirm that the problem is to do with the synth receiving the voice commands 'all at once' like you said.

I'll see if i can find a way to queue requests so that they don't all fire in the same control cycle. Thanks again!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!