Author |
Message |
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Sat Mar 15, 2008 12:17 pm Post subject:
Using references to UGens Subject description: How do I do it? |
|
|
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
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Sat Mar 15, 2008 6:09 pm Post subject:
|
|
|
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 _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Sat Mar 15, 2008 6:49 pm Post subject:
|
|
|
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 |
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
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sun Mar 16, 2008 8:46 am Post subject:
|
|
|
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
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Mon Mar 17, 2008 1:06 am Post subject:
|
|
|
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
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Mon Mar 17, 2008 2:36 am Post subject:
|
|
|
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
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Mon Mar 17, 2008 4:31 am Post subject:
|
|
|
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
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Mon Mar 17, 2008 4:36 am Post subject:
|
|
|
_________________ Kassen |
|
Back to top
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Mon Mar 17, 2008 5:04 am Post subject:
|
|
|
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
|
|
|
Inventor
Stream Operator
Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Mon Mar 17, 2008 11:21 pm Post subject:
|
|
|
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
|
|
|
|