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

presets - changing presets while chain playing #48

Open miguel-negrao opened 10 years ago

miguel-negrao commented 10 years ago

Currently changing presets while an uchain is playing is buggy: it leaves a synth playing which can only be stopped via cmd-. and doesn't apply the new changes to the playing synth. In case the new preset has the same units, it would be nice if the system would apply the values to the running synth, so that one could use it to quickly test different settings.

woutersnoei commented 10 years ago

yes that would be nice indeed. Main problem I think is (also when changing/adding/removing units from a chain in general) that while UMaps are "hot-pluggable", units are not. Ideally they would become so. It could be done I think, would probably require some clever tricks. Then it would become possible to change the contents of a UChain during playback, be it via presets or other means.

Another thing on this note I was thinking about a while ago is to have a second preset system that is based on Udefs; i.e. every Udef could have a set of different settings (perhaps some inluding UMaps) that could be chosen from and added to by the user. So instead of changing the whole chain in would only change the settings of one unit. And of course the change would be audible immediately. The presets could be stored in the Udef definition file, and perhaps via PresetManager it could be made possible to save user presets as well.

miguel-negrao commented 10 years ago

Yes, I think that implementation of presets would be at least as useful as the currents one. I think also it would be closer to what is usually called presets in other software, while what we have now I think is more like templates. I would be nice to add presets by just clicking a button (auto-naming) and then it would also be nice to cross-fade between presets.

In the mean time I've been using:

(
UChain.presetManager = PresetManager( UChain, [ \default, { UChain.default } ] )
.getFunc_({ |obj| obj.deepCopy })
.applyFunc_({ |object, preset|
    [object.units.postln, preset.units.postln].flopWith{ |a,b|
        var argsToSet = b.args.clump(2).select{ |xs| "u_.*".matchRegexp(xs[0].asString).not }.flatten;
        a.set(*argsToSet.postln)
    }
})
);