Author |
Message |
sorenkj
Joined: Apr 27, 2014 Posts: 9 Location: Portugal
|
Posted: Tue Apr 29, 2014 6:39 am Post subject:
Dynamically adding UGens Subject description: How.. |
|
|
Does anyone know how you can dynamically build a 'signal path', say I have this very simple path:
SqrOsc osc => outlet;
and depending on some user input I want to insert various modulations in between osc and outlet - could be first the user wants to insert a reverb and then later he wants to also add a low pass filter in between the reverb and the outlet. |
|
Back to top
|
|
|
Antimon
Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 371
G2 patch files: 100
|
Posted: Tue Apr 29, 2014 11:05 pm Post subject:
|
|
|
You can unhook and hook up UGens dynamically, and I think you can create new ones in a function. Here's something I just tried, seems to work:
Code: | SinOsc s => dac;
fun void hookInReverb() {
s =< dac;
s => JCRev r => dac;
}
500 => s.freq;
hookInReverb();
1::second => now;
|
_________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Wed Apr 30, 2014 10:45 am Post subject:
|
|
|
Hey, that is interesting .. with some front end you could make a modular out of that. _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
Antimon
Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 371
G2 patch files: 100
|
Posted: Wed Apr 30, 2014 3:16 pm Post subject:
|
|
|
Blue Hell wrote: | Hey, that is interesting .. with some front end you could make a modular out of that. |
I actually fiddled with a web front end with exactly that in mind for a day or two a while ago. _________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|
Back to top
|
|
|
sorenkj
Joined: Apr 27, 2014 Posts: 9 Location: Portugal
|
Posted: Thu May 01, 2014 8:40 am Post subject:
|
|
|
Thanks for the tip Antimon:) I just wonder then what to do if subsequentially another ugen needs to be inserted after the reverb. I would need to store a reference to the last inserted ugen, but what will be the type of the variable.. it would be easy if we could declare a variable of the superclass 'ugen', but that I think is not possible - suppose I would have to wrap each type of ugen in it's own class inheriting from Chubgraph.. |
|
Back to top
|
|
|
Antimon
Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 371
G2 patch files: 100
|
Posted: Thu May 01, 2014 11:07 pm Post subject:
|
|
|
sorenkj wrote: | Thanks for the tip Antimon:) I just wonder then what to do if subsequentially another ugen needs to be inserted after the reverb. I would need to store a reference to the last inserted ugen, but what will be the type of the variable.. it would be easy if we could declare a variable of the superclass 'ugen', but that I think is not possible - suppose I would have to wrap each type of ugen in it's own class inheriting from Chubgraph.. |
Hmm good point. I felt I had to try this out and check if there was such a thing as a superclass. Turns out there is!
Code: | SinOsc s => dac;
fun void hookInReverb() {
JCRev r @=> UGen newUgen;
s =< dac;
s => newUgen => dac;
}
500 => s.freq;
hookInReverb();
1::second => now; |
You need to use the reference assignment operator @=> here, since otherwise you'd just try to connect the output of r to the input of newUgen.
Sometimes it pays to just try things out. :) _________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|
Back to top
|
|
|
sorenkj
Joined: Apr 27, 2014 Posts: 9 Location: Portugal
|
Posted: Fri May 02, 2014 4:05 am Post subject:
|
|
|
Ah.. I think I tried 'Ugen' and 'ugen' (as it's written in the documentation) but of course not 'UGen'... thanks:) |
|
Back to top
|
|
|
|