[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Newb question - creating subclass for audio signals



Since all unit generator classes are subclasses of UGen, that is the one to use. But you should use extension methods for your ops, not a subclass. There's no multiple inheritance in SC, so if you have MyThing which is a subclass of UGen, and SomeOtherUGen that is a subclass of UGen, SomeOtherUGen can't inherit methods from MyThing. But if you add methods to UGen, then all ugen classes inherit them.

See "External Method Files" in Writing-Classes help.

One reason why I'm skeptical of this approach, though, is a loss of runtime flexibility. Tuning synths is one of those activities that especially benefits from the ability to make changes on the fly. If you hardcode your filters into methods, the only way to change them is to edit the method and recompile the library, blowing away all the objects you were working on. My feeling is that this gets old really fast, so it's better to keep such things in a structure that you can tweak at runtime without recompiling the class lib.

hjh


On Dec 31, 2008, at 12:12 AM, David Etlinger wrote:


Thanks for the responses so far. James, I'm not seeing why using a dictionary
is better than just declaring ~filter1, ~filter2, etc.? Except for namespace
clutter. But really, my main goal is to be able to write simply:

signal.doTheFiltering()

Maybe not worth it/impossible to get that, but at least I'll learn from
trying (as I already have from this example). I thought about subclassing
the "In" Ugen, and sending all audio in from another synth? That's not too
intuitive though and probably won't work...?


James Harkins-2 wrote:

~filters = (
// see the Environment helpfile under "prototypes" for more about  
'self'
filter1: { |self, input ... args|
LPF.ar(input, *args)
},
filter2: { |self, input ... args|
HPF.ar(input, *args)
},
...
);

SynthDef( "Filtering", {
     var signal1, signal2;

     signal1 = PlayBuf.ar( 2, bufNum );
     signal2 = PinkNoise.ar(1.0);

     signal1 = ~filters.filter1(signal1);
     signal2 = ~filters.filter2(signal2);
} );

hjh


-- 
Sent from the Supercollider - User mailing list archive at Nabble.com.


_______________________________________________
sc-users mailing list



: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman