From: Frédéric Péters Date: Thu, 9 Mar 2017 07:55:24 +0000 (+0100) Subject: use nanokontrol solo buttons for looping samples X-Git-Url: https://git.0d.be/?p=nanofun.git;a=commitdiff_plain;h=991e820d4b2a05846ff97a4c26b9118591650e00 use nanokontrol solo buttons for looping samples --- diff --git a/index.html b/index.html index fad9fb2..91e5690 100644 --- a/index.html +++ b/index.html @@ -14,6 +14,7 @@
+
diff --git a/nanofun.css b/nanofun.css index 3f09e58..846a388 100644 --- a/nanofun.css +++ b/nanofun.css @@ -59,6 +59,13 @@ div.nanotouch input[type=range] { margin: 0; } +div.nanotouch .loop { + position: absolute; + left: 0; + bottom: 2ex; + z-index: 10000; +} + div.nanotouch span.name { position: absolute; } diff --git a/nanofun.js b/nanofun.js index 9244d0b..b3b58ac 100644 --- a/nanofun.js +++ b/nanofun.js @@ -372,6 +372,19 @@ var nanofun = function() { midi.onControlChange = function(port, data, control, value) { if (control > 7 && control < 16) return; /* range between sliders and pots */ + if (control >= 32 && control < 40) { /* "S" buttons */ + var nanotouch = $('.nanotouch')[control-32]; + if (value == 127) { + var checked = $(nanotouch).find('.loop input').prop('checked'); + if (checked) { + $(nanotouch).find('.loop input').prop('checked', false); + device("nanoKONTROL2 MIDI 1").cc(control, 0); + } else { + $(nanotouch).find('.loop input').prop('checked', true); + device("nanoKONTROL2 MIDI 1").cc(control, 127); + } + } + } if (control > 23) return; /* after pots */ if (control < 8) { control += 8; /* sliders, control bottom pads (8-15) */ @@ -443,7 +456,7 @@ var nanofun = function() { var sample = self.audioCtx.createBufferSource(); var gainNode = self.touchGainNodes[sample_idx]; self.samples[sample_idx] = sample; - sample.loop = false; + sample.loop = ($(nanotouch).find('.loop input:checked').length == 1); sample.connect(gainNode); sample.buffer = sample_buffer; sample.onended = function() {