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
why doesent this work ?
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
Diskette



Joined: Feb 29, 2008
Posts: 2
Location: england

PostPosted: Fri Feb 29, 2008 3:16 pm    Post subject: why doesent this work ?
Subject description: arrays are confusing :S
Reply with quote  Mark this post and the followings unread

hey guys great forum! iv been trying to get my head round chuck for a few weeks, been ploughing through the chuck manual picking up what i can but i have no previous coding experience so its a little difficult. Was hoping someone could tell me where im going wrong with arrays etc.

[100 => float bpm;
minute / bpm => dur beat;

SinOsc s => dac;

[0.0,2.0,4.0,7.0,9.0,11.0] @=> float scale[];



while (true);

{

scale [Math.rand2(0,6) ] => float freq;

Std.mtof(48 + (Std.rand2(0,3)*12 + freq) ) => s.freq;

.25::beat =>now;

}

]

at the moment i seem to be getting "cannot perform + on object references" alot anyway any help would be much appreciated!
Back to top
View user's profile Send private message
kijjaz



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

PostPosted: Fri Feb 29, 2008 4:18 pm    Post subject: Reply with quote  Mark this post and the followings unread

i did some code cleaning up here:

Code:
100.0 => float bpm;
minute / bpm => dur beat;

SinOsc s => dac;

[0.0, 2, 4, 7, 9, 11] @=> float scale[];

while(true)
{
   scale[Std.rand2(0, 5)] => float note;
   Std.mtof(48.0 + Std.rand2(0, 3) * 12 + note) => s.freq;
   .25::beat => now;
}


Things about your patch:
- i'm not sure where you encounter the problem..
i guess we have to make sure which name is a function, and try to use it as a function.. for example..
Std.mtof(...)
s.freq(...)
are functions.

- guessing from what you had back there,
what you'd like to add to the second line in the while loop is that..
you are dealing with note number, not frequency yet.
so i change it to 'note' not frequency, and see if you've got the result you wanted.

- scale[n] <-- the maximum value of n would be 5 because we can point to it using n = 0 .. 5
just to make sure that ArrayOutOfBounds wouldn't occur.

- after my clean up, it'd work like this:
choose a random note from the scale
play at a random octave
starts at note 48 = C an octave below middle C

i guess this might be the musical result you're trying to do in there?
- - -

cool! this is gonna be a useful stuff.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Kassen
Janitor
Janitor


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

PostPosted: Fri Feb 29, 2008 4:57 pm    Post subject: Re: why doesent this work ?
Subject description: arrays are confusing :S
Reply with quote  Mark this post and the followings unread

Welcome on board!

Diskette wrote:

while (true);


This line is one of the big problems. Because of the " ; " sign the "while" loop refers to a empty loop in which nothing happens.... which gets the whole VM stuck.

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



Joined: Feb 29, 2008
Posts: 2
Location: england

PostPosted: Sat Mar 01, 2008 5:48 pm    Post subject: Reply with quote  Mark this post and the followings unread

thanks guys this is much more on track now ill persevere and hopefully get somewhere !
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