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 
go to the radio page Live at electro-music.com radio 1 Please visit the chat
poster
 Forum index » DIY Hardware and Software » ChucK programming language
array as function parameter
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [5 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Sun May 25, 2008 5:40 am    Post subject: array as function parameter Reply with quote  Mark this post and the followings unread

hi guys... short question: is it somehow possible to pass a complex[] array to a function?

thx4help
Back to top
View user's profile Send private message
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Sun May 25, 2008 7:08 am    Post subject: Reply with quote  Mark this post and the followings unread

How about this:
Code:
fun void print(complex c[]){
    for(0 => int i; i < c.cap(); i++){
        <<<c[i]>>>;
    }
}

[#(0.0,1.0),#(pi,0.0),#(0.5,0.6)] @=> complex myArray[];

print(myArray);

//output:
//#(0.0000,1.0000) :(complex)
//#(3.1416,0.0000) :(complex)
//#(0.5000,0.6000) :(complex)

_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Sun May 25, 2008 7:39 am    Post subject: Reply with quote  Mark this post and the followings unread

omg...

idiot => me;

i forgot the square brackets Óò

well... 6h of chucK are indeed a little confusing Smile

thx
Back to top
View user's profile Send private message
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Wed May 28, 2008 12:42 am    Post subject: Reply with quote  Mark this post and the followings unread

hi there... little stuck again...

Code:

//----------------------------------------------------------//
// MORPH
//----------------------------------------------------------//

fun complex[] morph(complex s[], complex s1[], grad){
   
    s  @=> complex m1[s.size()];
    s1 @=> complex m2[s.size()];
    complex m3[s.size()];
   
    polar p1[s.size()];
    polar p2[s.size()];
    polar p3[s.size()];
   
    for(0 => int a; a <m1> grad;       
       //lfo3.last() %=> grad;
       
       m1[a] $ polar @=> p1[a];
       m2[a] $ polar @=> p2[a];
       
       grad * (p1[a].mag - p2[a].mag) + p2[a].mag @=> p3[a].mag;
       grad * (p1[a].phase - p2[a].phase) + p2[a].phase @=> p3[a].phase;
       
       
       p3[a] $ complex @=> m3[a];
       
    }
    return m3;
}



why do i get a parse error in line 1, char 52:
Code:
fun complex[] morph(complex s[], complex s1[], grad){
?

thx
Back to top
View user's profile Send private message
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Wed May 28, 2008 2:49 am    Post subject: Reply with quote  Mark this post and the followings unread

fraukefroehlich wrote:

Code:
fun complex[] morph(complex s[], complex s1[], grad){


fixed!

Code:
fun complex[] morph(complex s[], complex s1[], int grad){


-.-
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 [5 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