Skip to content

Commit

Permalink
Updated and rearanged the scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Remy Porter committed Jun 9, 2015
1 parent 0bd6bd5 commit 0db03b5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a simple beat detector. ```beatTap.ck``` contains a class ```BeatDetector``` that exposes an event method. ```BeatDetector``` measures the time between subsequent calls to event and takes a windowed average of the last *n* events.
There are a few useful beat detection files in here.

```BeatTapper``` ties the detector to a keyboard, but *any* source of events could be used to drive the Detector.
Running ```chuck rundetect.ck``` will launch a ChucK program that plays a sample WAV file and "clicks" (and prints) where it detects a beat in that input. It works okay, but could probably use some tuning. The code for beat detection lives in ```beatDetect.ck```

```taponbeat.ck``` is little more than a driver for simple synthesis to prove the detector/tapper works.
Running ```chuck runtap.ck``` launches a program that listens for keystrokes, and averages the time between strokes to find a beat. The main logic for that lives in ```beatTap.ck```.
11 changes: 10 additions & 1 deletion beatDetect.ck
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ListenForBeat {
64 => int bands;
fun int numBands() { return bands; }
fun int numBands(int bnds) { if (!running) bnds => bands; return bands;}
16 => int bandThreshold;
40 => int bandThreshold;
0.000005 => float threshold;
2048 => int size;
3 => int cooldown;
Expand All @@ -21,6 +21,15 @@ public class ListenForBeat {
RMS rmses[256];
float runningMeans[256];

/*
Breaks the input signal up into bands using a BPF, then
connects each band into an FFT, so that we can find the power
on that band.
In the listen function, we'll grab the RMSes and find the ones
that are higher than their average power. If enough bands are "high"
at the same time, we'll call that a beat.
*/
fun void build() {
(high - low) / bands => step;
for (0 => int i; i < bands; i++) {
Expand Down
2 changes: 0 additions & 2 deletions initialize.ck → rundetect.ck
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
Machine.add(me.dir() + "/beatTap.ck");
Machine.add(me.dir() + "/beatDetect.ck");
//Machine.add(me.dir() + "/taponbeat.ck");
Machine.add(me.dir() + "/beatDetectTester.ck");
2 changes: 2 additions & 0 deletions runtap.ck
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Machine.add(me.dir() + "/beatTap.ck");
Machine.add(me.dir() + "/tapTester.ck");
File renamed without changes.

0 comments on commit 0db03b5

Please sign in to comment.