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
randomizing array lookup
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
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Mon Feb 05, 2007 6:49 am    Post subject: randomizing array lookup Reply with quote  Mark this post and the followings unread

Hi again,

I really do appreciate all of the help here on the forum, thanks.

anyway, I'm having yet another problem.

I'd like to randomize lookup of an array:

CODE:

SinOsc s1 => dac;

float tone[8];

130.81278265 => tone[0];
146.83238396 => tone[1];
164.81377846 => tone[2];
174.61411572 => tone[3];
195.99771799 => tone[4];
220.00000000 => tone[5];
246.94165063 => tone[6];
261.62556530 => tone[7];

.6 => s1.gain;


while (true)
{
tone[Std.rand2(0,7)] => s1.freq;

3::second => now;

}


is there some problem here? It seems the Std.rand2 should grab a random reference (0-7) and send the corresponding float to the SinOsc. This is probably a RTFM, but any help would be great.

who's down with OOP?

-jack
Back to top
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Mon Feb 05, 2007 12:02 pm    Post subject: Reply with quote  Mark this post and the followings unread

i'm running your code now.
it works just fine.
what do you want to extend it to? i'll check this out heheeh.

cool
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Tue Feb 06, 2007 8:39 am    Post subject: Reply with quote  Mark this post and the followings unread

shortly after I posted, I realized that I would need the explicit operator @=> (I think thats what that's called), to actually assign those freq values to any index of the array. When I made this revision, everything was fine.

Just wondering how you got my code to run, kijjaz? 'cause I'm pretty sure it isn't kosher.

jack
Back to top
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Wed Feb 07, 2007 1:11 pm    Post subject: Reply with quote  Mark this post and the followings unread

hmm it runs fine here.
and it chose frequency from the array correctly as it shoud be. ^_^
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
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