Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgraded to 1.2.1.3. Ported String funcs. Removed my File I/O stuff s…
…ince ChucK has that now.
- Loading branch information
Jim Menard
committed
Oct 5, 2009
1 parent
f16c8c9
commit 5d9256c
Showing
71 changed files
with
4,782 additions
and
728 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ current version of this document: | |
chuck home: | ||
|
||
http://chuck.cs.princeton.edu/ | ||
http://chuck.stanford.edu/ | ||
|
||
--- |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ ChucK Documentation + Tutorials: | |
|
||
ChucK home: | ||
http://chuck.cs.princeton.edu/ | ||
http://chuck.stanford.edu/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//-- | ||
// name: Smacking.ck | ||
// desc: class and process for tracking smack events from sudden motion sensor | ||
// only works with SMS-enabled laptops | ||
// | ||
// author: Rebecca Fiebrink + Ge Wang | ||
// date: 2007 | ||
//-- | ||
|
||
|
||
// public class | ||
public class Smacking | ||
{ | ||
static Event @ the_event; | ||
} | ||
|
||
// initialize separately (due to a bug) | ||
new Event @=> Smacking.the_event; | ||
|
||
// smack detection threshold (less -> more sensitive) | ||
15 => int threshold; | ||
// pol rate | ||
.01::second => dur poll_rate; | ||
// recover time (after smack detection) | ||
.10::second => dur recover_time; | ||
|
||
// instantiate a HidIn object | ||
HidIn hi; | ||
HidMsg msg; | ||
|
||
// open tilt sensor | ||
if( !hi.openTiltSensor() ) | ||
{ | ||
<<< "tilt sensor unavailable", "" >>>; | ||
me.exit(); | ||
} | ||
|
||
// "doh" | ||
<<< "hit me!", "" >>>; | ||
|
||
// remember | ||
HidMsg last; | ||
// initialize | ||
hi.read( 9, 0, last ); | ||
|
||
// infinite event loop | ||
while( true ) | ||
{ | ||
// poll the tilt sensor, expect to get back 3 element array of ints | ||
hi.read( 9, 0, msg ); | ||
|
||
// compute difference | ||
(Math.abs(msg.x - last.x) + Math.abs(msg.y - last.y) + Math.abs(msg.z - last.z)) => int diff; | ||
// check threshold | ||
if (diff > threshold) { | ||
// smack detected! | ||
// <<< "ouch!" >>>; | ||
// fire! | ||
Smacking.the_event.broadcast(); | ||
// go | ||
recover_time => now; | ||
} else { | ||
// uncomment the following to dynamically calibrate the smack sensor | ||
// msg.x => last.x; | ||
// msg.y => last.y; | ||
// msg.z => last.z; | ||
|
||
// advance | ||
poll_rate => now; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//-- | ||
// name: Tracking.ck | ||
// desc: class and process for tracking a peak and amplitutde via FFT | ||
// the Tracking class can be accessed from external shreds | ||
// | ||
// author: Ge Wang + Rebecca Fiebrink | ||
// date: 2007 | ||
//-- | ||
|
||
|
||
// public class | ||
public class Tracking | ||
{ | ||
static float the_freq; | ||
static float the_gain; | ||
static Event @ the_event; | ||
} | ||
|
||
// initialize separately (due to a bug) | ||
new Event @=> Tracking.the_event; | ||
|
||
// analysis | ||
adc => PoleZero dcblock => FFT fft => blackhole; | ||
|
||
// set to block DC | ||
.99 => dcblock.blockZero; | ||
// set FFT params | ||
2048 => fft.size; | ||
// window | ||
Windowing.hamming( fft.size() ) => fft.window; | ||
|
||
// go for it | ||
while( true ) | ||
{ | ||
// take fft | ||
fft.upchuck() @=> UAnaBlob blob; | ||
|
||
// find peak | ||
0 => float max; float where; | ||
for( int i; i < blob.fvals().cap()/8; i++ ) | ||
{ | ||
// compare | ||
if( blob.fvals()[i] > max ) | ||
{ | ||
// save | ||
blob.fvals()[i] => max; | ||
i => where; | ||
} | ||
} | ||
|
||
// set freq | ||
(where / fft.size() * (second / samp)) => Tracking.the_freq; | ||
// set gain | ||
(max / .5) => Tracking.the_gain; | ||
// clamp | ||
if( Tracking.the_gain > 1 ) | ||
1 => Tracking.the_gain; | ||
// fire! | ||
Tracking.the_event.broadcast(); | ||
|
||
// hop | ||
(fft.size()/4)::samp => now; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//-- | ||
// name: harm.ck | ||
// desc: using Tracking and Smacking to harmonize | ||
// | ||
// author: Rebecca Fiebrink + Ge Wang | ||
// date: 2007 | ||
//-- | ||
|
||
|
||
// synthesis | ||
BlitSaw s => JCRev r => dac; | ||
4 => s.harmonics; | ||
|
||
// set reverb mix | ||
.05 => r.mix; | ||
// possible hamonizing intervals | ||
[ 3-24, 4-12, 7, 9+12 ] @=> int harms[]; | ||
float the_harm; | ||
|
||
// interpolate | ||
float target_freq, curr_freq, target_gain, curr_gain; | ||
spork ~ ramp_stuff(); | ||
spork ~ smack_handler(); | ||
|
||
// go for it | ||
while( true ) | ||
{ | ||
// wait for analysis event | ||
Tracking.the_event => now; | ||
|
||
// set freq | ||
Tracking.the_freq * Math.pow(1.059, the_harm) => target_freq; | ||
// set gain | ||
Tracking.the_gain => target_gain; | ||
} | ||
|
||
// interpolation | ||
fun void ramp_stuff() | ||
{ | ||
// mysterious 'slew' | ||
0.025 => float slew; | ||
|
||
// infinite time loop | ||
while( true ) | ||
{ | ||
(target_freq - curr_freq) * 1 * slew + curr_freq => curr_freq => s.freq; | ||
(target_gain - curr_gain) * .25 * slew + curr_gain => curr_gain => s.gain; | ||
0.0025::second => now; | ||
} | ||
} | ||
|
||
// handles smack | ||
fun void smack_handler() | ||
{ | ||
// go | ||
while( true ) | ||
{ | ||
// wait | ||
Smacking.the_event => now; | ||
|
||
// choose random interval | ||
harms[Std.rand2(0,harms.cap()-1)] => the_harm; | ||
// set freq | ||
Tracking.the_freq * Math.pow(1.059, the_harm) => target_freq; | ||
<<< "new interval:", the_harm >>>; | ||
} | ||
} |
Oops, something went wrong.