GameOfLife / Unit-Lib

The Unit Library is a system that provides high level abstractions on top of the SuperCollider language.
25 stars 6 forks source link

recursive UGroups - first go at it #40

Closed miguel-negrao closed 10 years ago

miguel-negrao commented 10 years ago

I gave it a first go at implementing recursive ugroups. The difficult bit is how to maintain the syntax such that it's not needed to define the groups before hand. My current solution, which I'm not really happy with, is adding a parentUGroup variable to UChain, which sets the parent of the ugroup used. The first UChain to create a UGroup during prepare gets to decide the parent ugroup so it's not well defined what the parent UGroup will be. Also, once the parents of the UGroups are set, they are the same for the whole ULib session, unless the user changes them by manually UGroup.get(\a).parent(\b).
Another option is to define the ugroups explicitley, but in a way that they still get loaded from a uscore file. Perhaps something like myScore.groups
(UGroup(\a), UGroup(\b).parent(\a).addAction(a)) with easier syntax myScore.groups_(\a, [\b, \a, \addToTail])

So essentially it does work, but the interface to it is not the best yet. Do you have ideas on this ?

(
Udef(\in, {
    UOut.ar(0, In.ar(\bus.kr(100),1) );
});
Udef(\out, {
    Out.ar(\bus.kr(100), UIn.ar(0,1) );
});
)

(
x = UChain(\whiteNoise, [\out, [\bus, 90]]).ugroup_(\b).parentUGroup_(\a);
y = UChain([\in, [\bus, 90]], \lowPass ,[\out, [\bus, 90]]).ugroup_(\b).parentUGroup_(\a).addAction_(\addToTail);
r = UChain([\in, [\bus, 90]], \stereoOutput).ugroup_(\a).addAction_(\addToTail);
z = UScore(x,y, r);
z.prepareAndStart
)
miguel-negrao commented 10 years ago

Btw, this PR is just for discussion, not really ready for merging at this point.

I guess the main difference between UGroups as they are now and the the nested version, is that currently UGroups are global and are re-used by all scores, i.e. if a score is playing, a Group is created, if you start another score then it would reuse the same Group. With nested Groups you probably don't want this to happen since each Score would want a different topology for their UGroups (different parents and childs), so perhaps one way to solve that would be to make the UGroups not global but specific to each Score. This adds the restriction that the UGroup system wouldn't be available when playing UChains alone...

miguel-negrao commented 10 years ago

Another option could be to tie the group structure to the folder structure. So for instance UScore could have a flag "makeOwnGroup" which would create it's own group, then to make a nested structure of groups would would nest the folders. This would be quite intuitive.

Btw, I think the way DAWs deal with this is by just doing the equivalent of InFeedback on all busses and then compensating for the delay incurred in taking audio from previous block calculations by delaying tracks which don't go through the block delays. This off course increases latency.

miguel-negrao commented 10 years ago

opened new pr