-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from ccrma/dev
WebChucK IDE 2.1.4
- Loading branch information
Showing
51 changed files
with
877 additions
and
299 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//------------------------------------------------------------------------------ | ||
// name: accelDemo.ck | ||
// desc: Accel-erometer WebChucK Demo (mobile only) | ||
// SHAKE! mobile accelerometer to control sound synthesis | ||
// note: enable accelerometer in sensor settings | ||
// | ||
// Accel WebChucK Docs: | ||
// https://chuck.stanford.edu/webchuck/docs/classes/Accel.html | ||
// | ||
// author: Mike Mulshine | ||
//------------------------------------------------------------------------------ | ||
|
||
Accel ac; | ||
AccelMsg msg; | ||
|
||
0 => int device; | ||
|
||
// open accel | ||
if( !ac.openAccel( device ) ) me.exit(); | ||
<<< "accel '" + ac.name() + "' ready", "" >>>; | ||
|
||
<<< "only on mobile" >>>; | ||
|
||
SinOsc osc => Envelope gain => dac; | ||
Noise noise => LPF filter => gain; | ||
|
||
100 => float rootOscFreq; | ||
rootOscFreq => osc.freq; | ||
|
||
500 => float rootFilterFreq; | ||
rootFilterFreq => filter.freq; | ||
|
||
0.5 => filter.gain; | ||
|
||
10::ms => gain.duration; | ||
1.0 => gain.target; | ||
|
||
// infinite event loop | ||
while( true ) | ||
{ | ||
// wait on accel event | ||
ac => now; | ||
|
||
// get one or more messages | ||
while( ac.recv( msg ) ) | ||
{ | ||
// print accel values | ||
<<< msg.getAccelX() + " " + msg.getAccelY() + " " + msg.getAccelZ() >>>; | ||
// compute average acceleration | ||
(Math.fabs(msg.getAccelX()) + | ||
Math.fabs(msg.getAccelY()) + | ||
Math.fabs(msg.getAccelZ())) * 0.3333 => float avgAccel; | ||
|
||
// control synthesis/filter freq | ||
avgAccel * 10.0 => float dFreq; | ||
rootOscFreq + dFreq => osc.freq; | ||
rootFilterFreq + dFreq * 2.0 => filter.freq; | ||
// control gain | ||
avgAccel / 150.0 => float newGain; | ||
newGain => gain.target; | ||
} | ||
|
||
10::ms => now; | ||
} |
Oops, something went wrong.