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
  host / artist show at your time
today> Twyndyllyngs Live Chez Mosc
 Forum index » DIY Hardware and Software » ChucK programming language
Headers/Libraries in ChucK
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [7 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Plankhead



Joined: Apr 24, 2008
Posts: 14
Location: Long Island

PostPosted: Sat Jun 14, 2008 9:44 am    Post subject: Headers/Libraries in ChucK Reply with quote  Mark this post and the followings unread

I just coded up a simple controller for time signature and tempo that I'd like to include in most of my scripts. How is this usually done in ChucK? Is it possible to write "include timesig.ck" or something? Or is it more complex?
Back to top
View user's profile Send private message
Frostburn



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

PostPosted: Sat Jun 14, 2008 9:57 am    Post subject: Reply with quote  Mark this post and the followings unread

It's more complex.
First you have to write the thing as a public class in it's own file. Say:
Code:
public class MyThing{ ...

in "mything.ck"

In order to use this class in a "foo.ck" you need to write a mother file that adds the class to the global namespace, yields and then adds "foo.ck".
Code:
"mything.ck" => Machine.add;
me.yield();
"foo.ck" => Machine.add;

in "mother.ck"

If you try Machine.adding "mything.ck" inside "foo.ck" you'll see some colorful error messages.

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



Joined: Dec 16, 2007
Posts: 83
Location: Urbana, IL
Audio files: 5

PostPosted: Sat Jun 14, 2008 12:12 pm    Post subject: Reply with quote  Mark this post and the followings unread

Although, I should add that the use of includes is on the "to do" list. (I asked the same thing last December.)
Back to top
View user's profile Send private message
Plankhead



Joined: Apr 24, 2008
Posts: 14
Location: Long Island

PostPosted: Sat Jun 14, 2008 1:28 pm    Post subject: Reply with quote  Mark this post and the followings unread

Tried that. I ended up having to put the full path in before it would even find either file, though. I still got an error:

With:

Code:
"/Users/Zack/Documents/libMusic.ck" => Machine.add;
me.yield();
"/Users/Zack/Documents/scale.ck" => Machine.add


I got:

Code:
[chuck](VM): sporking incoming shred: 2 (mother.ck)...
[chuck](VM): sporking incoming shred: 3 (libMusic.ck)...
[scale.ck]:line(2): cannot access member 'Music.getNFreq' without object instance...


What exactly does that mean?
Back to top
View user's profile Send private message
rogan



Joined: Dec 16, 2007
Posts: 83
Location: Urbana, IL
Audio files: 5

PostPosted: Sat Jun 14, 2008 1:43 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hi Plankhead,

Did you instantiate the object before you used it?
ie.
Code:

MyClass myObject;

5 => myObject.function();
Back to top
View user's profile Send private message
Plankhead



Joined: Apr 24, 2008
Posts: 14
Location: Long Island

PostPosted: Sat Jun 14, 2008 1:46 pm    Post subject: Reply with quote  Mark this post and the followings unread

rogan wrote:
Hi Plankhead,

Did you instantiate the object before you used it?
ie.
Code:

MyClass myObject;

5 => myObject.function();


Figured that out just as you mentioned it. Thanks.
Back to top
View user's profile Send private message
Sweet Pablo



Joined: Nov 15, 2007
Posts: 3
Location: Illinois, US

PostPosted: Sat Jun 28, 2008 8:05 pm    Post subject: Include with CPP Reply with quote  Mark this post and the followings unread

It is possible to include files using the same way c does using c preprocessor, since chuck's syntax is basically the same as c's.

I wrote a bash script that should work for unix systems with cpp installed.
It is posted here: http://electro-music.com/forum/topic-24190.html
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 [7 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