# [chuck-users] Help.

J Alexander Diaz jalexander at diazsounds.com
Mon Jun 8 00:26:01 EDT 2015

```Hi Folks!

I'm needing help understanding what the code for the frequency down below
in bold text is doing.

Context: I'm trying to build a code that will randomly pick frequencies and
rhythms within a given range. As time passes my goal is to write a code
that will also allow the frequencies and rhythms to change. I know I'm not
ready to understand how to code this yet as I am teaching myself at my own
pace. But I would like some help if maybe someone could talk me through
what the frequency portion of this code is doing. I took the frame of most
of my code from a ChucK example and am changing it for a composition of
mine.

I don't understand the relationship between the scale part and the freuency
part.

I don't understand the Math.pow.

I do understand math.random2, int, and freq.

Thank you much!!

// Sitar

Sitar sit => JCRev r => Echo a => dac;

// gain

.56 => r.gain;

// reverb mix

1.12 => r.mix;

// max delay for echo

1120::ms => a.max;

// set delay for echo

112::ms => a.delay;

// initial effect mix

0.0 => a.mix;

*// scale*

*[ 15 ] @=> int scale[];*

*// freq*

*    scale[Math.random2(0,scale.cap()-1)] => int freq;*

*    220.0 * Math.pow( 1.05946, (Math.random2(0,2)*12) + freq ) =>
sit.freq;*

// loop

while( true ){

//pluck

Math.random2f( 0.1, 0.9 ) => sit.noteOn;

//time

Math.random2f( .01, 1000 )::ms => now;

}

--
J. Alexander Diaz
www.diazsounds.com
MFA Student - Music Composition
jalexander at diazsounds.com

[image: VCFA] <http://vcfa.edu/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20150607/3f544dfe/attachment.html>
```