electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
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
timer class
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
moudi



Joined: Oct 07, 2006
Posts: 63
Location: Bern Switzerland

PostPosted: Fri Oct 13, 2006 12:46 pm    Post subject: timer class Reply with quote  Mark this post and the followings unread

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 Confused ) 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 Very Happy
Back to top
View user's profile Send private message Visit poster's website
spencer



Joined: Aug 16, 2006
Posts: 53
Location: northern california

PostPosted: Sun Oct 15, 2006 2:28 pm    Post subject: Reply with quote  Mark this post and the followings unread

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?
Code:
timer.wait
will always return the same thing, but
Code:
timer.wait()
should not...

moudi wrote:
by the way: ChucK RULES


no argument here!

hope this helps,
spencer
Back to top
View user's profile Send private message
moudi



Joined: Oct 07, 2006
Posts: 63
Location: Bern Switzerland

PostPosted: Mon Oct 16, 2006 2:11 pm    Post subject: Reply with quote  Mark this post and the followings unread

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.

spencer wrote:

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

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 Wink
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?
Code:
<<<timer>>>;

If you leave the parentheses out, then it is a function, but with the parentheses it will evaluate to a dur.

Gosh! Embarassed i forgot the parentheses! SILLY ME!
since i work with automatic completion in .net i never thought about this... Rolling Eyes

great to have you guys here
/moudi
Back to top
View user's profile Send private message Visit poster's website
spencer



Joined: Aug 16, 2006
Posts: 53
Location: northern california

PostPosted: Thu Oct 19, 2006 2:05 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 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