Using UGen as a function arg
Hey everyone, I just found out that you could use more specific classes as function arguments (I know, a little slow). So, I've got: fun void modulator (UGen a, DelayL b) ... while(1) { a.last()::ms => b.delay; 1::samp => now; } and it totally works! Here's the catch: is there a way to make something like this that will work for more general classes? I mean, why don't DelayL and DelayA and Delay all inherit from some more general class that uses a dummy "delay" and "max" argument, so that we can build some awesome functions that have universal applications? There could be an oscillator class to encompass everything with a freq, phase, and sync attribute, and so many others that would make modulating so much easier. I expect there to be a totally reasonable answer, because I don't really know much about programming at all, but this seems like it would make sense. Or, is there a way to do what I want to do (build more general modulation functions) within the existing framework? I'd ideally like something that can spork a shred to modulate a random parameter, then fade out at the end, so that it's like the signal is receiving random interference that makes it ring mod or something. I can probably figure out how to do it with millions of lines of code, but the more work it is the less likely it is that I'll finish it. Thanks everyone. Andrew
Hello Andrew,
Or, is there a way to do what I want to do (build more general modulation functions) within the existing framework?
if you don't mind writing some more code you might want to try the following:
(I haven't tested it but it might work)
class BaseDelay
{
fun dur delay()
{
}
fun dur delay( dur _delay )
{
}
// the same for max
}
class MyDelay extends BaseDelay
{
Delay aDelay;
fun dur delay()
{
return aDelay.delay();
}
fun dur delay( dur _delay )
{
_delay => aDelay.delay;
}
// the same for max
}
// the same for DelayL and DelayA
fun void modulator( UGen a, BaseDelay b )
{
...
while( 1 )
{
a.last()::ms => b.delay;
1::samp => now;
}
}
Dimitris
--- Στις Δευτ., 31/08/09, ο/η Andrew C. Smith
participants (2)
-
Andrew C. Smith
-
Bozelos Dimitris