[chuck-users] assigning Gen7 coefs

Tom Lieber lieber at princeton.edu
Sun Mar 29 23:54:28 EDT 2009


On Sun, Mar 29, 2009 at 11:50 AM, Gregory Brown <gwbrown at uga.edu> wrote:
> I am trying to use Gen7 for the first time and I am running into trouble
> assigning the coefficients. The file shown in Example 2 works fine, but
> Example 1 generates no sound and the lookup gives only NaN. The difference
> between the two examples is in how I create the coefs array, although I
> don't see how this affects the outcome.
>
> Can someone help me understand what the difference is and why one might work
> while the other does not?
>
> Thanks,
>
>  - Greg
>
>
> //+_+_+_+_+_+_+_+_+_+_+_+_+_++_++_+++_+_+
>
> //              Example 1
>
> //+_+_+_+_+_+_+_+_+_+_+_+_+_++_++_+++_+_+
>
> // setup
> Phasor driver => Gen7 g7 => dac;
> 220 => driver.freq;
>
> // declare array for coefs
> 5 => float num_values;
> float coefs[ ((num_values$int)*2) - 1];
>
> // insert random values into every even index
> for ( 0 => int i; i < num_values ; i++ )
> {
>        Std.rand2f(0,1) => coefs[i*2];
> }
>
> // insert time values into every odd index
> for ( 1 => int i; i < num_values ; i++ )
> {
>        1 / num_values => coefs[(i*2)-1];
> }
>
> // print it out
> for ( 0 => int i; i < coefs.cap() ; i++ )
> {
>        <<< "coefs[",i,"]: ", coefs[i] >>>;
> }
>
> // assign the table
> coefs => g7.coefs;
>
> // do a lookup
> <<< g7.lookup(.5) >>>;
>
> // loop
> while (true)
> {
>        100::ms => now;
> }
>
> // +_+_+_+_+_+_+_+_+_+_+_+_+_++_++_+++_+_+
>
> //      Example 2
>
> //+_+_+_+_+_+_+_+_+_+_+_+_+_++_++_+++_+_+
>
>
> // setup
> Phasor driver => Gen7 g7 => dac;
> 220 => driver.freq;
>
> // declare array for coefs
> 5 => float num_values;
> float coefs[ ((num_values$int)*2) - 1];
>
> // directly assign floats to array
> [0.709912 , 0.200000 , 0.496574 , 0.200000 , 0.911184 , 0.200000 , 0.270048
> , 0.200000 , 0.701863] @=> coefs;
>
> // print it out
> for ( 0 => int i; i < coefs.cap() ; i++ )
> {
>        <<< "coefs[",i,"]: ", coefs[i] >>>;
> }
>
> // assign the table
> coefs => g7.coefs;
>
> // do a lookup
> <<< g7.lookup(.5) >>>;
>
> // loop
> while (true)
> {
>        100::ms => now;
> }

Both work for me.. (miniAudicle, OS X, ChucK 1.2.1.2)

-- 
Tom Lieber
http://AllTom.com/


More information about the chuck-users mailing list