supercollider-quarks / Influx

Lose Control, Gain Influence.
9 stars 5 forks source link

Use global or default specs as possible specs to avoid lack of specs when attaching object #5

Closed madskjeldgaard closed 10 months ago

madskjeldgaard commented 4 years ago

Fixes #4 by adding some extra possiblities for specs: If object does not have specs in itself, look for the specs in the global ControlSpec.specs dict, and if that doesn't work, use the generic default spec defined in the InfluxBase classvar baseSpec.

madskjeldgaard commented 4 years ago

added fix for #2 which was caused by the fact that the InfluxSpread class which is a subclass of InfluxBase relied on the .init method to init the destination dict, but it is never called in InfluxBase.

madskjeldgaard commented 4 years ago

These changes should be reflected in the docs as well but I will wait on the maintainer(s) opinion on these until I do anything about that.

capital-G commented 10 months ago

I also ran today into this problem - thx for the proposed fix @madskjeldgaard , but there are some merge conflicts now.

Is there a way to get this merged @adcxyz ? If mads is not interested anymore, I would be willing to update the PR, but I was wondering if there is something non-obvious which would hinder a merge?

There were also some changes regarding the pickup of specs, see https://github.com/supercollider/supercollider/issues/5515 (just bumped my old 3.11 installation to 3.13 b/c of this)

For example, even when setting the specs explicitly this fails

(
Ndef(\foo, {
    PMOsc.ar(
        carfreq: \carfreq.kr(200.0, spec: \freq),
        modfreq: \modfreq.kr(200.0, spec: \freq),
        pmindex: \pmindex.kr(0.0, spec: ControlSpec(-20, 20)),
        modphase: \modindex.kr(0.0, spec: ControlSpec(-2pi, 2pi)),
    ) * -10.dbamp ! 2;
}).play;
)

~influx = Influx(2, 5);
~influx.attachMapped(Ndef(\foo));
InfluxKtlGui(~influx);
adcxyz commented 10 months ago

thanks mads! and apologies I did not register these requests ...

capital-G commented 10 months ago

Thanks for merging @adcxyz ! Yet I believe it doesn't fix everything yet, as my example above does not return an error now, but also does not pick up the specs but instead uses the range [0, 1].

I think this would fix it, but I am unsure if it would break something else b/c I don't understand every aspect of the spec "responsibility"

diff --git a/Classes/Influx.sc b/Classes/Influx.sc
index e52547d..eee55ab 100644
--- a/Classes/Influx.sc
+++ b/Classes/Influx.sc
@@ -454,7 +454,7 @@ Influx :InfluxBase {
                var offDict = ();

                // Look for specs: Passed in via param, local specs in the object or global specs defined in ControlSpec.specs
-               specs = specs ?? {object.getSpec} ? ControlSpec.specs;
+               specs = specs ?? {object.specs} ? ControlSpec.specs;
                funcName = funcName ?? { object.key };
                paramNames = paramNames
                ?? { object.getHalo(\orderedNames); }

iiuc getSpec without a given string would always return nil?

edit: .getSpec is actually an extension to Object, so in order to support arbitrary objects it would be good to verify the object via respondsTo before calling in order to not restrict objects here?