]> git.0d.be Git - nanofun.git/blobdiff - nanofun.js
add control of effects via M buttons
[nanofun.git] / nanofun.js
index fe8102e141aa6129abe5c61fa769daf0e3d4ef6d..13813a124f7b979bedd07e4dac9d7eb19cd94f5b 100644 (file)
@@ -375,7 +375,7 @@ 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 */
+      if (control >= 32 && control < 40) { /* "S" buttons -> loop */
           var nanotouch = $('.nanotouch')[control-32];
           if (value == 127) {
             var checked = $(nanotouch).find('.loop input').prop('checked');
@@ -389,6 +389,21 @@ var nanofun = function() {
             $(nanotouch).find('.loop input').trigger('change');
           }
       }
+      if (control >= 48 && control < 55) { /* "M" buttons -> effects */
+          var nanotouch = $('.nanotouch')[control-48];
+          if (value == 127) {
+            var checked = $(nanotouch).find('.effects input').prop('checked');
+            if (checked) {
+              $(nanotouch).find('.effects input').prop('checked', false);
+              device("nanoKONTROL2 MIDI 1").cc(control, 0);
+            } else {
+              $(nanotouch).find('.effects input').prop('checked', true);
+              device("nanoKONTROL2 MIDI 1").cc(control, 127);
+            }
+            $(nanotouch).find('.effects input').trigger('change');
+          }
+
+      }
       if (control > 23) return; /* after pots */
       if (control < 8) {
         control += 8; /* sliders, control bottom pads (8-15) */