Hello Community,
I have a Question of Possibility in SuperCollider
I working of a greater Complex Application in Supercollider
There will been a System of Processes,
each of this Process is started by another of this Processes and will Start self other of this Processes.
So each Process has a Speed / Tuning and a Duration.
So each Process starts and finished in Time.
The Problem is to Manage the just Running Processes.
And this is in the Beginning easy.
I have a Global Dictionary who each Process check in by his Start
The Problem is Step 2:
And this is each Process should checkout by his Finish.
So I think what I need is a Function which automatically will be called by the Done-Action of each Synth which represents the Processes.
So I hope there will been an Angle which tells me the right way to do this
Ok,
I was happy too early
The next / The reminder Problem is this:
The x.onFree calls at the End of the Synth the as Paramater to him given Function. But I knownât not the Circumstances of this Execution.
So the Problem is, I can only delete the Right Position in the Dictionary, when I know the Name of the Responded Synth.
So the Question is, is there any way to customize this Function automticaly for each started Synth. At least can it have any Parameter who tells him his connected Synt Names.
In because of there can been any Number Synths between 1 and 120 paralel tp 12000 in a whole Performance, it is important to do this Automatically.
In fact, it does have access to that. This is unfortunately not documented in the help file, but the onFree function receives the Node (Synth or Group) object as argument:
Alternately, the onFree function could use variables outside of its own scope â just make sure the variable is defined within the loop, e.g.:
// the good way
(
r = fork {
20.do { |i|
var freq = (i+1) * 100; // **this** variable
"Starting synth with frequency %\n".postf(freq);
Synth(\beep, [freq: freq, time: 1]).onFree({
// 'freq' here refers to the i*100.
// because it's declared within the loop,
// it's bound to the current cycle,
// no matter how much time passed before release.
"\tSynth with frequency % was just released\n".postf(freq);
});
0.2.wait;
};
};
)
// the bad way
(
r = fork {
var freq; // nope, don't do this
20.do { |i|
freq = (i+1) * 100;
"Starting synth with frequency %\n".postf(freq);
Synth(\beep, [freq: freq, time: 1]).onFree({
// now 'freq' is declared outside the loop,
// so it only refers to the last played frequency.
// the link between this synth and its frequency is broken
"\tSynth with frequency % was just released\n".postf(freq);
});
0.2.wait;
};
};
)
Here Iâm back,
And Juston We have a Problem.
I have tryed all,
but the freq is only received from the Loop in Which it was definied
But My Synth must have a little bit Garbage Collection.
The Problem is,
he must remove his Values from a Table.
And when this is going on, the freq Value in the Loop has nothing to do with
The Freq once the Synth Instance was created.
So my Problem is the self as before.
Are there any Technique to pass the DoneAction to Send a Message to the IDE that this and only this Instance of the Synth was died
x = Synth(âZerro-Processingâ, [âdurâ, 11, âspeedâ, 1, âtempoâ, 11, âmasterAmpâ, 1, âcenterâ, 1, âquestionâ, index ]).onFree({question.postln});
You see I need the Parameter Question to see which Instance of the Synth-Type Zerro-Processing is over.
I tryed it in two Ways:
First was question-postln which says that question was not found.
.onFree({ question.postln});
ERROR: Variable âquestionâ not defined.
.onFree({ index.postln});
Which gives only the Index of the last Synth-Instance but no way back to the Instances before. But I must remove - as an Example - The first Entry with Name Question when two other Instances are started
Why/from where do you want to delete the synth?
When itâs ended, itâs automatically deleted from the server.
Iâm guessing now, but maybe you wanted to remember the synths you started, maybe in an array, and then delete them from the array when they are ended?
Then you could do something like this:
(
~myRememberedSynths = ~myRememberedSynths.add(
Synth(\beep, [freq: 44.rand + 40, time: 4.0.rand + 0.2])
.onFree({ |synth|
var index = ~myRememberedSynths.indexOf(synth);
~myRememberedSynths.removeAt(index);
"// removed synth at index % because it ended. ".postf(index);
"there are now % synths left in ~myRememberedSynths.\n".postf(~myRememberedSynths.size);
}
)
)
)
Yes nearly this is.
I have a little Directory
with 3 Elements.
1.) A Reference to the synth // X = synth(/beep)
2âŚ) Two Reference Places
I need a Way to remove this Entry when the Synth Instance freed
One of my Problems is to Store a Reference to the Synth in this Directory
In special must the Entry refresched in little Time-Cycles,
and there I become Problems to Work with the above x for Synth
and the Put and at Methods
You can apply the same principle to a dictionary, as i have demonstrated with an array above.
The trick is to do the removal inside the onFree function, then you donât have to manage any âlittle time cyclesâ â the cleanup happens automatically and almost instantaneously.