electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
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 
 Forum index » DIY Hardware and Software » ChucK programming language
Using references to UGens
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [10 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Sat Mar 15, 2008 12:17 pm    Post subject: Using references to UGens
Subject description: How do I do it?
Reply with quote  Mark this post and the followings unread

I would like to have some symbol "osc" that I can assign with SinOsc or SqrOsc alternatively. Then elsewhere in the program I would like to say osc.freq (1000) and get a 1kHz signal, be it sine or square depending on what the assignment was. Further, i would like to later change the assignment and get the desired response. I've been reading in the language reference about UGen and Object types, classes, references, etc., but nowhere do I find such an example. How would I accomplish this?
Back to top
View user's profile Send private message Send e-mail
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24079
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Sat Mar 15, 2008 6:09 pm    Post subject: Reply with quote  Mark this post and the followings unread

Can't you just have a variable of type UGEN or something?

If not, it also looks a bit like the class wrapper discussion that has been held here a while ago, for an outsider that is Wink

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Sat Mar 15, 2008 6:49 pm    Post subject: Reply with quote  Mark this post and the followings unread

Blue Hell wrote:
Can't you just have a variable of type UGEN or something?

If not, it also looks a bit like the class wrapper discussion that has been held here a while ago, for an outsider that is Wink


I tried that to no avail. I tried to make it a UGen, but when I assigned it it said "cannot reconcile Object with UGen", so I made it an Object, and then it wouldn't ChucK up to the next Gain block. Very strange, I'm confused.

I'll go look at old threads, thanks Blue Hell.
Back to top
View user's profile Send private message Send e-mail
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sun Mar 16, 2008 8:46 am    Post subject: Reply with quote  Mark this post and the followings unread

Yeah.... another issue with the OOP structures and how not everything will be a object.... Probably another thing to encapusulate in a class to fake it.

I asked Ge to give this situation some thought a while back. Interesting how we keep running into it lately.

-edit-
I added this as a feature request to the WiKi, linking to the various topics on this forum that relate to this and suggesting a discussion

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Mon Mar 17, 2008 1:06 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks for bringing this up in the Wiki, Kassen. Now I'm wondering what my work-around is. Well, for the sliders I can just set all of the instantiated objects, even if they are not in use. For the ChucKing and unChucKing I can use a bunch of if statements... OK, i'll try some work-around and see how it goes.
Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Mon Mar 17, 2008 2:36 am    Post subject: Reply with quote  Mark this post and the followings unread

The work-around worked. I only needed a simple set of if statements and a little trickiness with the ChucKing and unChucKing when switching ugens. Also I simply set the sliders on all related ugens, no problem. I can post the source code now, hurdle over (for now)...
Back to top
View user's profile Send private message Send e-mail
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Mon Mar 17, 2008 4:31 am    Post subject: Reply with quote  Mark this post and the followings unread

Did you consider a matrix of gains? That could be fun as well?

Code:

//size of matrix
4 => int foo;

SinOsc Ugens[foo];

Gain matrix[foo][foo];

for (0=> int n; n<foo; n++)
 {
 for (0=> int m; m<foo; m++)
  {
  //horizontal in
  Ugens[n] => matrix[n][m];
  //vertical out
  matrix[n][m] => Ugens[m];
  }
 }


From there on the matrix can be used to controll how much any one Ugens send to any other.... any point can be connected to the DAC as well. Just a idea.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Mon Mar 17, 2008 4:36 am    Post subject: Reply with quote  Mark this post and the followings unread

Posted Image, might have been reduced in size. Click Image to view fullscreen.
_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Mon Mar 17, 2008 5:04 am    Post subject: Reply with quote  Mark this post and the followings unread

Hmmm, a matrix of gains, OK. I'm a little unclear on how they get hooked up. Do we just want several gain blocks, or do we want them to form a mesh of some sort? I could just provide some gain blocks. Note that there are already gain blocks because each wire is a gain and I brought that out on a view panel. For each wire you can slide the gain, do gain boost of x1, x10, x100, x1000, and x10000, plus select if its inputs get added, subtracted, multiplied, or divided.

Still, it would be nice to have a block of gains because they would have input/output sliders and you could just create a gain from any node to any other. Yet it makes sense to me to create a linear array of gains instead of a matrix of gains, unless there is some underlying reason we want it to be a matrix.

I don' t know, I'm still a bit unclear on this one, could you elaborate a bit, Kassen?
Back to top
View user's profile Send private message Send e-mail
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Mon Mar 17, 2008 11:21 pm    Post subject: Reply with quote  Mark this post and the followings unread

I added a linear array of gains complete with boost and .op() settings. This can be sized with a control variable at the beginning of the program, and it can be connected as a matrix if desired.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [10 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


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