[chuck] Some Problems

Rasmus Kaj kaj at kth.se
Wed May 11 15:31:46 EDT 2005


>>>>> "GW" == Ge Wang <gewang at CS.Princeton.EDU> writes:

 >> 2) With many programs from
 >> http://wiki.cs.princeton.edu/index.php/ChucK_Programs
 >> I got errors like
 >> [hihat.ck]:line(38): cannot cast to type 'int' from 'dur'...

 GW> I got the same error on hihat.ck.  This is due to a recent change in
 GW> the sndbuf API (sorry) where length is a 'dur' and no longer a 'int'.
 GW> I think the way to fix this is by dividing the duration by the
 GW> appropriate unit (samp, the duration of a sample in this case).
 GW> (Gary, please let me know if my changes are incorrect.)

 GW>    (int)(open.length/1::samp) => int tlen;

Yes.  But there should be no need for a temporary variable at all,
here's what's in http://www.stacken.kth.se/~kaj/2005/chuck12.en which
it came from:

    "data/hihat-open.wav" => open.read;
    (int)(open.length/1::samp) => open.pos;

... apparently, I'd written that with a (yet unreleased) development
version.  :-)


Also, as you, Ge, says on the Wiki, you can set 0.0 => open.rate, but
then you will have to both reset the position and the rate when
(re)starting the sample, I found those two operations rather than one
to clobber the source ...


-- 
Rasmus Kaj --+-- rasmus at kaj.se --+-- http://www.stacken.kth.se/~kaj/
I do not fear computers.  I fear the lack of them.  -Isaac Asimov


More information about the chuck mailing list