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
How to put Ugen object to array?
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Phloxs



Joined: Jan 24, 2014
Posts: 17
Location: Russia

PostPosted: Thu Oct 01, 2015 5:57 am    Post subject: How to put Ugen object to array? Reply with quote  Mark this post and the followings unread

Hello.

I want to make some kind of array with links to objects (or objects) in order for I'll control Ugens by adress to this array's index.

How can I do it?

At example:

Code:
SinOsc sin => dac;
SawOsc saw => dac;

[sin, saw] @=> int instList[];

440 => int instList[0];
220 => int instList[1];


Of course I get an error "cannot assign '@=>' on types 'Osc[]' @=> 'int[]'"
Back to top
View user's profile Send private message
brkl



Joined: Aug 21, 2015
Posts: 8
Location: Finland

PostPosted: Fri Oct 02, 2015 2:53 am    Post subject: Reply with quote  Mark this post and the followings unread

I think you can have an array of a single type of object, not different ones. I mean, you can make an array of UGens and assign SinOsc to it, but it won't work. You won't be able to use any feature of SinOsc apart from the ones that are part of UGen.

Oh, I don't know, maybe you could try the Chubgraph feature and make a class that has a setting that determines what kind of UGen it is. I mean, you could give it a shot.
http://chuck.stanford.edu/extend/#chubgraphs
Back to top
View user's profile Send private message
Phloxs



Joined: Jan 24, 2014
Posts: 17
Location: Russia

PostPosted: Fri Jul 08, 2016 5:52 am    Post subject: Reply with quote  Mark this post and the followings unread

This solution work with StkInstrument class so I guess it should work with Ugens.

Code:

Mandolin m;
Sitar s;
Shakers sh;

[m, s, sh]@=> StkInstrument instruments[];

for (int i; i instruments.size(); i++)
{
    Math.random2(220, 440) => instruments[i].freq;
    1 => instruments[i].noteOn;
    .5::second => now;
    1 => instruments[i].noteOff;
}

Back to top
View user's profile Send private message
95



Joined: Nov 01, 2016
Posts: 1
Location: los angeles

PostPosted: Tue Nov 01, 2016 7:50 pm    Post subject: Reply with quote  Mark this post and the followings unread

brkl! your suggestion totally worked for me.
brkl wrote:

Oh, I don't know, maybe you could try the Chubgraph feature and make a class that has a setting that determines what kind of UGen it is. I mean, you could give it a shot.
http://chuck.stanford.edu/extend/#chubgraphs

i'm making a synth thing with different kinds of oscillators, and wanted to put them in an array. i had tried with a ugen array, but as mentioned, because ugen is so limited, it won't let you do things like change frequency.

BUT THIS IS GREAT

a little sample i made to test it out:
Code:

class Oski extends Chubgraph{

   ADSR e[4];

   SinOsc si => e[0] => dac;   
   SqrOsc sq => e[1] => dac;
   TriOsc tr => e[2] => dac;
   SawOsc sa => e[3] => dac;

   fun void freq(int voice, int value){

      if (voice == 0){value => si.freq;}
      if (voice == 1){value => sq.freq;}
      if (voice == 2){value => tr.freq;}
      if (voice == 3){value => sa.freq;}
   }

   fun void keyOn(int voice){
      
      e[voice].keyOn();
   }

   fun void keyOff(int voice){
      
      e[voice].keyOff();
   }

   fun void releaseTime(int voice, dur d){

      e[voice].releaseTime(d);
   }
}

Oski o => dac;

o.freq(0, 1000);

o.releaseTime(0, .2::second);

o.keyOn(0);

1::second => now;

o.keyOff(0);

1::second => now;

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 [4 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