]> git.0d.be Git - nanofun.git/commitdiff
use nanokontrol solo buttons for looping samples
authorFrédéric Péters <fpeters@0d.be>
Thu, 9 Mar 2017 07:55:24 +0000 (08:55 +0100)
committerFrédéric Péters <fpeters@0d.be>
Sat, 1 Apr 2017 10:37:19 +0000 (12:37 +0200)
index.html
nanofun.css
nanofun.js

index fad9fb295b8aa583f1dbf6670cefd6062eb54376..91e5690235992364882cc1a005c7690823c5a3bd 100644 (file)
@@ -14,6 +14,7 @@
    <div class="nanotouch">
      <span class="name"></span>
      <span class="duration"></span>
+     <label class="loop"><input type="checkbox">Loop</label><br>
      <input type="file" accept="audio/*" multiple>
      <input class="touch-gain" type="range" min="0" max="127" value="127">
    </div>
index 3f09e580881ceee488e358d41af24e2b6e15a86c..846a3885005b443289ccfdbb33fb562847ce98a8 100644 (file)
@@ -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;
 }
index 9244d0b11f54d4fb251016acf81df049ffb58a59..b3b58ac9faf9edbe385d55aa6a8af555d56f8412 100644 (file)
@@ -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() {