electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
Live streaming at radio.electro-music.com

  host / artist show at your time

poster

Please visit the chat
 Forum index » DIY Hardware and Software » ChucK programming language
Dynamically adding UGens
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [7 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
sorenkj



Joined: Apr 27, 2014
Posts: 9
Location: Portugal

PostPosted: Tue Apr 29, 2014 6:39 am    Post subject: Dynamically adding UGens
Subject description: How..
Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Antimon



Joined: Jan 18, 2005
Posts: 4086
Location: Sweden
Audio files: 350
G2 patch files: 100

PostPosted: Tue Apr 29, 2014 11:05 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 22224
Location: The Netherlands, Enschede
Audio files: 208
G2 patch files: 319

PostPosted: Wed Apr 30, 2014 10:45 am    Post subject: Reply with quote  Mark this post and the followings unread

Hey, that is interesting .. with some front end you could make a modular out of that.
_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
Antimon



Joined: Jan 18, 2005
Posts: 4086
Location: Sweden
Audio files: 350
G2 patch files: 100

PostPosted: Wed Apr 30, 2014 3:16 pm    Post subject: Reply with quote  Mark this post and the followings unread

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. Smile

_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
sorenkj



Joined: Apr 27, 2014
Posts: 9
Location: Portugal

PostPosted: Thu May 01, 2014 8:40 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Antimon



Joined: Jan 18, 2005
Posts: 4086
Location: Sweden
Audio files: 350
G2 patch files: 100

PostPosted: Thu May 01, 2014 11:07 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
sorenkj



Joined: Apr 27, 2014
Posts: 9
Location: Portugal

PostPosted: Fri May 02, 2014 4:05 am    Post subject: Reply with quote  Mark this post and the followings unread

Ah.. I think I tried 'Ugen' and 'ugen' (as it's written in the documentation) but of course not 'UGen'... thanks:)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [7 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use