| Author |
Message |
Plankhead
Joined: Apr 24, 2008 Posts: 14 Location: Long Island
|
Posted: Sat Jun 14, 2008 9:44 am Post subject:
Headers/Libraries in ChucK |
 |
|
| 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
|
|
 |
Frostburn

Joined: Dec 12, 2007 Posts: 255 Location: Finland
Audio files: 9
|
Posted: Sat Jun 14, 2008 9:57 am Post subject:
|
 |
|
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
|
|
 |
rogan

Joined: Dec 16, 2007 Posts: 83 Location: Urbana, IL
Audio files: 5
|
Posted: Sat Jun 14, 2008 12:12 pm Post subject:
|
 |
|
| 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
|
|
 |
Plankhead
Joined: Apr 24, 2008 Posts: 14 Location: Long Island
|
Posted: Sat Jun 14, 2008 1:28 pm Post subject:
|
 |
|
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
|
|
 |
rogan

Joined: Dec 16, 2007 Posts: 83 Location: Urbana, IL
Audio files: 5
|
Posted: Sat Jun 14, 2008 1:43 pm Post subject:
|
 |
|
Hi Plankhead,
Did you instantiate the object before you used it?
ie.
| Code: |
MyClass myObject;
5 => myObject.function();
|
|
|
|
Back to top
|
|
 |
Plankhead
Joined: Apr 24, 2008 Posts: 14 Location: Long Island
|
Posted: Sat Jun 14, 2008 1:46 pm Post subject:
|
 |
|
| 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
|
|
 |
Sweet Pablo
Joined: Nov 15, 2007 Posts: 3 Location: Illinois, US
|
Posted: Sat Jun 28, 2008 8:05 pm Post subject:
Include with CPP |
 |
|
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
|
|
 |
|