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
Question regarding cap() and other member functions
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [9 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
wppk



Joined: Jan 25, 2008
Posts: 31
Location: Los Angeles

PostPosted: Wed Feb 13, 2008 4:13 pm    Post subject:  Question regarding cap() and other member functions Reply with quote  Mark this post and the followings unread

What is the cap() function. What class is it a part of. Is there any documentation listing the various data and function members of the inherent classes in the CHUCK language?
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Thu Feb 14, 2008 7:25 am    Post subject: Reply with quote  Mark this post and the followings unread

.cap() is a member of the array object. If invoked for a given array it returns it's length. The only other functions of build-in classes I can think of right now are ".broadcast()" and ".signal()" for events.... Well and maybe ".send()" for MidiOut and the members of the various messages (HID, MIDI, etc) These should all be in the manual in the explanation of the classes they belong to, if they are not that would be cause for a little note on the "manual errata" wiki page.
Code:

//define a array of type integer and length 8;
int foo[8];

//verify the length;
<<<foo.cap()>>>;

//more complicated example for 2d arrays
//this can be seen as "a array of arrays"
float bar[4][5];

//check how many arrays we have
<<<bar.cap()>>>;
//check the length of the first one
<<<bar[0].cap()>>>;

//change it
[1.0, 2.1, 3.2] @=> bar[0];

//check the length of the (now changed) first one
<<<bar[0].cap()>>>;


Does that help?

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



Joined: Jan 25, 2008
Posts: 31
Location: Los Angeles

PostPosted: Thu Feb 14, 2008 1:51 pm    Post subject: Reply with quote  Mark this post and the followings unread

Yes thanks.

But if you look at the some of the examples, joy.ck for instance, there seem to be member functions for the Hid class that are not in the manual.

if( !hi.openJoystick( device ) ) me.exit();

if( msg.isAxisMotion() )

else if( msg.isButtonDown() )

Please forgive my ignorance but these functions don't seem to have been declared from within the file so I'm assuming that they are inherent to the Hid class. Am I correct?
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Thu Feb 14, 2008 4:17 pm    Post subject: Reply with quote  Mark this post and the followings unread

Oh, oops, yes. You are right.

Those are extra functions, mostly for convenience that got added to the HID after the HID had been put in the manual. They work like you'd expect them to; msg.isAxisMotion() returns 1 if the message is of that type. I should mention that these are not, strictly speaking, members of the "HID" object and instead are properties of the hid message received by the HID object.

".openJoystick( device )" would be the exception, that one is a member function of the hid object itself.

For these I'd say you are much better off with the examples then with the manual.

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



Joined: Jan 25, 2008
Posts: 31
Location: Los Angeles

PostPosted: Thu Feb 14, 2008 4:41 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thanks Kassen.

I just have one more question pertaining to this subject.

What is the .arg() function?
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Fri Feb 15, 2008 9:38 am    Post subject: Reply with quote  Mark this post and the followings unread

You're welcome!

But, erm, .arg()? Where did you find that? Sounds like one of the member functions of some Ugens that got carried over from the STK? Something to set a whole set of parameters in one swoop?

Typically I don't really use those and instead use the ones aimed more squarely at ChucK which I find more readable. Still, those are documented quite well in the Ugen docs, I think?

Could you point me to the exact source of your confusion? I think this process is quite valuable, BTW, it's great feedback about the docs, everybody knows those needs to be maintained but it's much harder to say exactly *what* should be in them, where and how. In my opinion; if somebody makes a real effort to look stuff up yet it's still unclear that means the docs are to blame.

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


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

PostPosted: Fri Feb 15, 2008 10:00 am    Post subject: Reply with quote  Mark this post and the followings unread

By the way, I just looked it up and the HidMsg functions you were after turn out to be quite well documented after all. Admittedly it's the final entry in the manual but it's there and quite clear.

I can't find .arg() at all in the whole manual and not in the online Ugen specifications either. "arg" does get used as a name for a argument relatively often, but that's only to indicate the purpose of that variable, it could be called "foo" just as well in those contexts.

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



Joined: Jan 25, 2008
Posts: 31
Location: Los Angeles

PostPosted: Fri Feb 15, 2008 1:24 pm    Post subject: Reply with quote  Mark this post and the followings unread

you're right. They are in the manual. I just never made it that far assuming that they would be elsewhere in the manual.

As far as .arg(), I've seen it everywhere and now i can't seem to find it anywhere. Sad

I'll post an example when I come across one.
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Fri Feb 15, 2008 2:25 pm    Post subject: Reply with quote  Mark this post and the followings unread

wppk wrote:
you're right. They are in the manual. I just never made it that far assuming that they would be elsewhere in the manual.


I understand. Once you get up to speed the final chapters of the manual are the best stuff; they are a great reference but indeed you need the earlier chapters to make use of them.

Quote:
As far as .arg(), I've seen it everywhere and now i can't seem to find it anywhere. Sad

I'll post an example when I come across one.


I think I remember it as well. For one thing; I do believe you will be fine without ever using it and when you need it it'll be clear because then you know the context and will run into it naturally. No need to know everything by heart, if .arg() were vitally important on a daily basis I'm sure it would've had a better name, even ".coefs()" (for filters and the "gen" tables) does.

:¬)

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [9 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