From 066daf44cc6ca810c831e4db1e96ce19c6caade8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 20 Jan 2021 11:20:52 +0100 Subject: [PATCH] make faders control effects when cycle is pressed --- nanofun.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nanofun.js b/nanofun.js index bf32ff3..fff1ea0 100644 --- a/nanofun.js +++ b/nanofun.js @@ -296,6 +296,7 @@ var nanofun = function() { self.initAudio = function() { self.focused_pad = undefined; + self.cycle_being_pressed = false; self.sample_buffers = Array(NANOPAD_TOUCHS.length); self.samples = Array(NANOPAD_TOUCHS.length); self.sample_start_times = Array(NANOPAD_TOUCHS.length); @@ -376,6 +377,12 @@ var nanofun = function() { midi.onControlChange = function(port, data, control, value) { if (control > 7 && control < 16) return; /* range between sliders and pots */ + if (control == 46) { + /* cycle -> alternate mode, make faders control effects when pressed + * (moving faders when cycle is pressed) */ + self.cycle_being_pressed = (value != 0); + return; + } if (control >= 32 && control < 40) { /* "S" buttons -> loop */ var nanotouch = $('.nanotouch')[control-32]; if (value == 127) { @@ -431,6 +438,19 @@ var nanofun = function() { self.stopSample(self.focused_pad); } if (control > 23) return; /* after pots */ + if (self.cycle_being_pressed) { + /* 4 -> delay, 5 -> feedback, 6 -> filter, 7 -> master */ + if (control == 4) { + $('#delay').val(value / 127 * 5).trigger('change'); + } else if (control == 5) { + $('#feedback').val(value / 127 * 1).trigger('change'); + } else if (control == 6) { + $('#filter').val(value / 127 * 5000).trigger('change'); + } else if (control == 7) { + $('#master-gain').val(value).trigger('change'); + } + return; + } if (control < 8) { control += 8; /* sliders, control bottom pads (8-15) */ } else { -- 2.39.2