From b44453b8a851b22e88649dfbfc08414912de048b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 22 Feb 2017 13:15:13 +0100 Subject: [PATCH] add some knobs for effects --- index.html | 8 +++++++- nanofun.css | 9 +++++++++ nanofun.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 55897f2..039f0f3 100644 --- a/index.html +++ b/index.html @@ -21,9 +21,15 @@
+
-
+
+
+
+
+
+
Source code at https://git.0d.be/?p=nanofun.git
diff --git a/nanofun.css b/nanofun.css index 158fa7f..99c357e 100644 --- a/nanofun.css +++ b/nanofun.css @@ -75,3 +75,12 @@ div#gitclone { bottom: 1ex; right: 1ex; } + +form { + margin: 1em; +} + +form label { + display: inline-block; + width: 10em; +} diff --git a/nanofun.js b/nanofun.js index fd4dcbd..6b8ba95 100644 --- a/nanofun.js +++ b/nanofun.js @@ -303,6 +303,21 @@ var nanofun = function() { self.touchGainNodes[i].connect(self.masterGainNode); } self.masterGainNode.connect(self.audioCtx.destination); + + self.delay = self.audioCtx.createDelay(maxDelayTime=5); + self.delay.delayTime.value = 0.5; + + self.feedback = self.audioCtx.createGain(); + self.feedback.gain.value = 0.8; + + self.filter = self.audioCtx.createBiquadFilter(); + self.filter.frequency.value = 1000; + + self.delay.connect(self.feedback); + self.feedback.connect(self.filter); + self.filter.connect(self.delay); + + self.masterGainNode.connect(self.delay); } self.initMIDI = function() { @@ -374,6 +389,24 @@ var nanofun = function() { self.masterGainNode.gain.value = fraction * fraction; }); + $('#delay').on('change', function() { + var value = this.value; + if (value == 0) { + self.delay.disconnect(); + } else { + self.delay.delayTime.value = value; + self.delay.connect(self.audioCtx.destination); + } + }); + + $('#feedback').on('change', function() { + self.feedback.gain.value = this.value; + }); + + $('#filter').on('change', function() { + self.filter.frequency.value = this.value; + }); + $('.touch-gain').on('change', function() { var fraction = parseInt(this.value) / parseInt(127); var touchIdx = parseInt($(this).parent().data('touch')); -- 2.39.2