Hi all, I have this pattern here that I like quite a bit (some absolutely demented Ferneyhough musicality), but it tends to build up a lot of synths very quickly (usually in the hundreds after 15 seconds or so, which is absolutely unnecessary). Since I’d ultimately like to run this kind of stuff with more complicated SynthDefs and maybe for longer, I’m wondering what I can do to keep that from happening. I’m using the default synth for now, which has a doneAction: FreeSelf.
Tried:
\sendGate, true, (but this is the default already, right?)
\callback, {|event| event[\addToCleanup] = {event.free} }
and rewriting the outer, phrase-type pattern as a Routine.
No real difference for all I can tell. (I might try to do a less random MWE to be able to check this more systematically…).
Anyway, the inner pattern is this:
Pdef(\inner, { | amplo = 0.7, amphi = 1.1, durlo = 0.7, durhi = 1.2, midilo = -1, midihi = 2 |
Pbind(
\instrument, \default,
\midinote, Pseries(start: 60 + 12.rand, step: Pbrown(midilo, midihi, 1), length: 1 + 22.rand).loop,
\amp, Pgeom(start: 0.1, grow: Pbrown(amplo, amphi, 0.1), length: 1 + 22.rand).loop,
\dur, Pgeom(start: 0.1, grow: Pbrown(durlo, durhi, 0.1), length: 1 + 22.rand).loop, //max possible dur of individual note here is 4.6 seconds (highly unlikely)
)
});
//This is relatively well behaved on its own if I call stop periodically on the Pdef:
fork { loop {s.numSynths.postln; Pdef(\inner).play; {exprand(1,3)}.wait; Pdef(\inner).stop}};
//However, I'd like to schedule this through an outer, phrase-type pattern:
(
Pbind(
\type, \phrase,
\instrument, \inner,
\dur, Pexprand(1, 3, inf),
\amplo, Pseq([0.7, 1.05, 0.9, 1.1], inf),
\amphi, Pfunc { |ev| ev.amplo + 0.2.rand}, // already edited as suggested by PitchTrebler
\durlo, Pseq([0.7, 0.6, 0.9, 0.8], inf),
\durhi, Pfunc { |ev| ev.durlo + 0.3.rand},
\midilo, Pseq([-1, 0, -2, -3], inf),
\midihi, Pseq([2, 3, 0, 1, 1], inf),
).play;
fork { loop {s.numSynths.postln; 1.wait}};
)
I’m not quite sure what’s going on here, and whether I’m using this more or less as intended.
I did a bit of poking around and the phrase type events have an internal Pfindur, which calls an EventStreamCleanup, maybe there’s something not being cleaned up there that should be?