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

UEnvGen can hang server #37

Closed miguel-negrao closed 10 years ago

miguel-negrao commented 10 years ago

After a couple of hours trying to debug this I'm still clueless why, but this hangs the server every time:

(

Udef(\expPulses,{ arg minAmp=1, maxAmp=1,amp=1,morphFactor=1;

    var ampEnv = UEnvGen.kr(\ampEnv,\unipolar);
    var minTrigFreq = UEnvGen.kr(\minTrigFreq,[0.01,2000,\exp]);
    var maxTrigFreq = UEnvGen.kr(\maxTrigFreq,[0.01,2000,\exp]);
    var minFreq = UEnvGen.kr(\minFreq,[50,17000,\exp]);
    var maxFreq = UEnvGen.kr(\maxFreq,[50,17000,\exp]);
    var minAttT = UEnvGen.kr(\minAttT,[0.001,1,2]);
    var maxAttT = UEnvGen.kr(\maxAttT,[0.001,1,2]);
    var minDecT = UEnvGen.kr(\minDecT,[0.001,1,2]);
    var maxDecT = UEnvGen.kr(\maxDecT,[0.001,1,2]);

});
)

//hangs server...

(

x = UChain(0, 0, 30, [ 'expPulses', [ 'minTrigFreq', EnvM([ 500.0, 500.0 ], [ 1 ], 0), 'maxTrigFreq', EnvM([ 500, 500 ], [ 1 ], 0), 'minFreq', EnvM([ 500, 500 ], [ 1 ], 5), 'maxFreq', EnvM([ 500, 500 ], [ 1 ], 5)

] ]);
x.prepareAndStart

)
woutersnoei commented 10 years ago

As each UEnvGen adds 128 control inputs (32 nodes of 4 values each) , I suppose some maximum of control inputs is exceeded here.

\expPulses.asUdef.synthDef.controls.size; // -> 1157

I would guess the maximum is 1024 or something around that. Why do you hard-code all envs into the def? You could easily use \envelope UMaps in this case, which would be much more flexible, and probably run without problems.

miguel-negrao commented 10 years ago

It wasn't my code (I got other people to start using Unit Lib in SARC in order to use ImmLib, my phd library :-) ), but yeah you're right I can suggest to switch to UMaps. In any case I don't think the server should go into 100%cpu, it should give an error (already reported on list). Also, if it's really just because of the synthdef and the number of control inputs, isn't it strange that that

(

x = UChain(0, 0, 30, [ 'expPulses']);
x.prepareAndStart

)

doesn't hang the server ? It seems it only happens with values set to those controls...

miguel-negrao commented 10 years ago

Number of controls per se doesn't seem to be issue here. This Udef with 2561 controls doesn't hang the server. It's really a combination of the number of controls and the actual values you pass to it...

(
Udef(\test,{ 
    20.collect{ |i| UEnvGen.kr(("a"++i).asSymbol,[50,17000,\exp]) };
});
)
Udef.
\test.asUdef.synthDef.controls.size
(
UChain([\test, 
    20.collect{ |i| [("a"++i).asSymbol,EnvM([100,100],[1]) ] }.flatten
]);
)
miguel-negrao commented 10 years ago

It was a nasty (and stupid !) bug in the class library !!! This commit will fixit once it's merged into supercollider's main git repo https://github.com/miguel-negrao/supercollider/commit/282967196fd047ce62c3f5524c656534df7d9709