Author |
Message |
moudi
Joined: Oct 07, 2006 Posts: 63 Location: Bern Switzerland
|
Posted: Fri Oct 13, 2006 12:46 pm Post subject:
timer class |
 |
|
hi all
i just started with ChucK (i use it with miniAudicle) and tried to write a little timer class for the syncronisation.
I get some problems when i use it, so i would like to ask you some (probably stupid ) questions.
this is the class i wrote:
-----------------------------------------------
public class timer
{
int beats;
float bpm;
dur beat;
dur bar;
fun void set(int _beats, float _bpm)
{
_beats => beats;
_bpm => bpm;
(60 / bpm)::second => beat;
beats::beat => bar;
}
fun dur wait()
{
return (bar - (now % bar));
}
}
----------------------------------------------
1: is it possible to automatically load a class with the startup of the virtual machine?
I assume that i will have to compile ChucK myself with the new class included, but is it also somehow possible with miniAudicle? (i didn't found any sources, i assume miniAudicle is not open source?).
2: the function timer.wait should return a duration value, but is indicated as 'function' if i print it. therefore it's not possible to use it for timing (e.g. chucking to "now").
3: the timer.wait returns allways the same value. it looks like, that the keyword "now" stays as a fixed value (probably the time the class was loaded?).
many thx in advance for some replies
regards
/moudi
by the way: ChucK RULES  |
|
Back to top
|
|
 |
spencer

Joined: Aug 16, 2006 Posts: 53 Location: northern california
|
Posted: Sun Oct 15, 2006 2:28 pm Post subject:
|
 |
|
Hey there moudi,
moudi wrote: | 1: is it possible to automatically load a class with the startup of the virtual machine? |
Presently, this is not possible without changing the source code, although we could probably implement that feature if you think it would be a useful feature.
moudi wrote: | I assume that i will have to compile ChucK myself with the new class included, but is it also somehow possible with miniAudicle? (i didn't found any sources, i assume miniAudicle is not open source?). |
This approach is possible, but you would probably want to do it a special way. All of ChucK's built-in classes are implemented in C++, but it would probably be a lot easier in your case to automatically add shreds from hard coded ChucK source or filenames when ChucK/the VM is started.
miniAudicle is totally open source! but I guess we don't make that very clear. The only direct link to the source is on the Linux miniAudicle ("liniAudicle") page, but the source distribution includes sources for all 3 platforms. here it is:
http://audicle.cs.princeton.edu/mini/release/files/miniAudicle-0.1.3.6.tgz
moudi wrote: | 2: the function timer.wait should return a duration value, but is indicated as 'function' if i print it. therefore it's not possible to use it for timing (e.g. chucking to "now"). |
Hmm, how are you printing/calling the function? I tried running your code as you said, and timer.wait correctly returns a dur. Are you calling it like this?
Code: | <<< timer.wait() >>>; |
If you leave the parentheses out, then it is a function, but with the parentheses it will evaluate to a dur.
moudi wrote: | 3: the timer.wait returns allways the same value. it looks like, that the keyword "now" stays as a fixed value (probably the time the class was loaded?). |
Again, are you including parentheses in your function call? will always return the same thing, but should not...
moudi wrote: | by the way: ChucK RULES |
no argument here!
hope this helps,
spencer |
|
Back to top
|
|
 |
moudi
Joined: Oct 07, 2006 Posts: 63 Location: Bern Switzerland
|
Posted: Mon Oct 16, 2006 2:11 pm Post subject:
|
 |
|
Hi spencer
thank you for your answers. things get a lot clearer now..
spencer wrote: |
Presently, this is not possible without changing the source code, although we could probably implement that feature if you think it would be a useful feature.
This approach is possible, but you would probably want to do it a special way. All of ChucK's built-in classes are implemented in C++, but it would probably be a lot easier in your case to automatically add shreds from hard coded ChucK source or filenames when ChucK/the VM is started. |
For me it will be very useful. Are there already other existing wishes in this direction, or am i the only one? I mean, it makes no sense to implement something for only one person... but it would be definitely great.
cool. thx for this link. i will have a look at it in the near future.
atm i'm very busy with learning the basics in ChucK
it will become more important when i'm more familiar with it.
spencer wrote: |
Hmm, how are you printing/calling the function? I tried running your code as you said, and timer.wait correctly returns a dur. Are you calling it like this?
If you leave the parentheses out, then it is a function, but with the parentheses it will evaluate to a dur. |
Gosh! i forgot the parentheses! SILLY ME!
since i work with automatic completion in .net i never thought about this...
great to have you guys here
/moudi |
|
Back to top
|
|
 |
spencer

Joined: Aug 16, 2006 Posts: 53 Location: northern california
|
Posted: Thu Oct 19, 2006 2:05 pm Post subject:
|
 |
|
moudi wrote: | For me it will be very useful. Are there already other existing wishes in this direction, or am i the only one? I mean, it makes no sense to implement something for only one person... but it would be definitely great. |
I think you're the only one so far, but it's definitely a feature that makes a lot of sense, and has some precedence in command line chuck. Ill run the idea by some other folks, and maybe see about working that into an upcoming release.
thanks!
spencer |
|
Back to top
|
|
 |
|