summaryrefslogtreecommitdiff
path: root/client/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/index.js')
-rw-r--r--client/index.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/client/index.js b/client/index.js
index 19cae7b..3c56825 100644
--- a/client/index.js
+++ b/client/index.js
@@ -17,6 +17,7 @@ import {
requestAudioContext,
choice,
roundFreq,
+ frequencyInRange,
mod,
} from "./lib/util";
import { PRIMES } from "./lib/primes";
@@ -73,10 +74,12 @@ function rebuild() {
}
function log() {
const seen = {};
+ console.log(notes);
for (let i = 0; i < 8; i++) {
for (let j = 0; j < 8; j++) {
- const rounded = roundFreq(notes[i][j].frequency);
- if (!seen[rounded] && 20 < rounded && rounded < 12000) {
+ const frequency = notes[i][j].frequency;
+ const rounded = roundFreq(frequency);
+ if (!seen[rounded] && frequencyInRange(frequency)) {
seen[rounded] = notes[i][j].frequency;
}
}
@@ -104,13 +107,15 @@ function play(freq) {
}
}
function trigger(freq) {
- if (20 && freq.frequency && freq.frequency < 15000) {
+ if (frequencyInRange(freq.frequency)) {
instrument.play(freq.frequency);
}
}
function trigger_index(index) {
const frequency = frequencies[index];
- instrument.play(frequency);
+ if (frequency) {
+ instrument.play(frequency);
+ }
}
function pause(freq) {
organ.pause(freq.frequency);