Created
December 19, 2013 22:43
-
-
Save inky/8047511 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| JCRev r => dac; | |
| 0.05 => r.mix; | |
| // https://lists.cs.princeton.edu/pipermail/chuck-users/2009-April/004150.html | |
| // $ chuck scales.ck:left.wav:right.wav | |
| if (me.args() > 1) { | |
| dac.chan(0) => Gain g0 => WvOut w0 => blackhole; | |
| dac.chan(1) => Gain g1 => WvOut w1 => blackhole; | |
| 0.8 => g0.gain; | |
| 0.8 => g1.gain; | |
| me.arg(0) => w0.wavFilename; | |
| me.arg(1) => w1.wavFilename; | |
| } | |
| else if (me.args() > 0) { | |
| dac => Gain g0 => WvOut w0 => blackhole; | |
| 0.8 => g0.gain; | |
| me.arg(0) => w0.wavFilename; | |
| } | |
| Clarinet c => r; | |
| 0.7 => c.gain; | |
| 0.5 => c.reed; | |
| 0.5 => c.noiseGain; | |
| 0.0 => c.vibratoFreq; | |
| 0.0 => c.vibratoGain; | |
| fun void note(float tonic, float cents, dur duration) | |
| { | |
| note(tonic, cents, duration, 0::ms); | |
| } | |
| fun void note(float tonic, float cents, dur duration, dur rest) | |
| { | |
| tonic * Math.pow(2, cents / 1200.0) => c.freq; | |
| 0.8 => c.pressure; | |
| duration => now; | |
| 0.0 => c.pressure; | |
| rest => now; | |
| } | |
| [ | |
| 100.0, | |
| 600.0, | |
| 300.0, | |
| 150.0, | |
| 75.0 | |
| ] @=> float scale_steps[]; | |
| [ | |
| "12-TET (12-Tone Equal Temperament)", | |
| "2-TET", | |
| "4-TET", | |
| "8-TET", | |
| "16-TET" | |
| ] @=> string scale_names[]; | |
| 261.626 => float middle_c; | |
| 195.998 => float lower_g; | |
| for (0 => int i; i < scale_steps.cap(); i++) { | |
| <<< scale_names[i] >>>; | |
| 0 => float cents; | |
| until (cents > 1200.0) { | |
| note(middle_c, cents, 300::ms, 200::ms); | |
| cents + scale_steps[i] => cents; | |
| } | |
| 3000::ms => now; | |
| } | |
| <<< "Perfect fifth vs 16-TET fifth (1/8 tone flatter)" >>>; | |
| note(middle_c, 0, 300::ms); | |
| note(middle_c, 700, 500::ms, 50::ms); | |
| note(middle_c, 0, 300::ms); | |
| note(middle_c, 700, 500::ms, 1500::ms); | |
| note(middle_c, 0, 300::ms); | |
| note(middle_c, 675, 500::ms, 50::ms); | |
| note(middle_c, 0, 300::ms); | |
| note(middle_c, 675, 500::ms, 3000::ms); | |
| <<< "Perfect fourth vs 16-TET fourth (1/8 tone sharper)" >>>; | |
| note(middle_c, 0, 300::ms, 0::ms); | |
| note(middle_c, 500, 500::ms, 50::ms); | |
| note(middle_c, 0, 300::ms, 0::ms); | |
| note(middle_c, 500, 500::ms, 1500::ms); | |
| note(middle_c, 0, 300::ms, 0::ms); | |
| note(middle_c, 525, 500::ms, 50::ms); | |
| note(middle_c, 0, 300::ms, 0::ms); | |
| note(middle_c, 525, 500::ms, 3000::ms); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment