]> git.0d.be Git - nanofun.git/commitdiff
also detect the pads with their Windows-assigned names
authorFrédéric Péters <fpeters@0d.be>
Thu, 23 Nov 2017 16:07:28 +0000 (17:07 +0100)
committerFrédéric Péters <fpeters@0d.be>
Thu, 23 Nov 2017 17:01:29 +0000 (18:01 +0100)
nanofun.js

index b3b58ac9faf9edbe385d55aa6a8af555d56f8412..014ebb026423ed5fbc5790ab613d812a8d9c8f9c 100644 (file)
@@ -61,8 +61,8 @@ onMIDIAccessChange: function(e) {
       } else {
         this.outputs[port.name] = undefined;
       }
       } else {
         this.outputs[port.name] = undefined;
       }
-      if (port.name == 'nanoPAD2 MIDI 1') { $('#devices .nanopad').removeClass('on'); }
-      if (port.name == 'nanoKONTROL2 MIDI 1') { $('#devices .nanokontrol').removeClass('on'); }
+      if (port.name == 'nanoPAD2 MIDI 1' || port.name == 'nanoPAD2 2 PAD') { $('#devices .nanopad').removeClass('on'); }
+      if (port.name == 'nanoKONTROL2 MIDI 1' || port.name == 'nanoKONTROL2 2 SLIDER/KNOB') { $('#devices .nanokontrol').removeClass('on'); }
     } else {
       if (port.type == "input") {
         if (this.inputs[port.name] === undefined) { this.registerPort(port); }
     } else {
       if (port.type == "input") {
         if (this.inputs[port.name] === undefined) { this.registerPort(port); }
@@ -70,8 +70,8 @@ onMIDIAccessChange: function(e) {
         if (this.outputs[port.name] === undefined) { this.registerPort(port); }
       }
             console.log('hello:', port.name);
         if (this.outputs[port.name] === undefined) { this.registerPort(port); }
       }
             console.log('hello:', port.name);
-      if (port.name == 'nanoPAD2 MIDI 1') { $('#devices .nanopad').addClass('on'); }
-      if (port.name == 'nanoKONTROL2 MIDI 1') { $('#devices .nanokontrol').addClass('on'); }
+      if (port.name == 'nanoPAD2 MIDI 1' || port.name == 'nanoPAD2 2 PAD') { $('#devices .nanopad').addClass('on'); }
+      if (port.name == 'nanoKONTROL2 MIDI 1' || port.name == 'nanoKONTROL2 2 SLIDER/KNOB') { $('#devices .nanokontrol').addClass('on'); }
       this.renderPort(port);
     }
 },
       this.renderPort(port);
     }
 },
@@ -90,17 +90,18 @@ registerPort: function(port) {
     } else {
         this.outputs[port.name] = port;
 
     } else {
         this.outputs[port.name] = port;
 
-        if (port.name == 'nanoKONTROL2 MIDI 1') {
+        if (port.name == 'nanoKONTROL2 MIDI 1' || port.name == 'nanoKONTROL2 2 SLIDER/KNOB') {
+          var port_name = port.name;
           /* turn "external leds" mode on.
            *
            * The sysex dump has been recorded from the official Korg kontrol
            * editor by the Overtone project, original code at:
            * https://github.com/overtone/overtone/blob/master/src/overtone/device/midi/nanoKONTROL2.clj */
           /* turn "external leds" mode on.
            *
            * The sysex dump has been recorded from the official Korg kontrol
            * editor by the Overtone project, original code at:
            * https://github.com/overtone/overtone/blob/master/src/overtone/device/midi/nanoKONTROL2.clj */
-          device("nanoKONTROL2 MIDI 1").raw([240, 126, 127, 6, 1, 247]);
-          device("nanoKONTROL2 MIDI 1").raw([240, 66, 64, 0, 1, 19, 0, 31, 18, 0, 247]);
-          device("nanoKONTROL2 MIDI 1").raw([240, 126, 127, 6, 1, 247]);
+          device(port_name).raw([240, 126, 127, 6, 1, 247]);
+          device(port_name).raw([240, 66, 64, 0, 1, 19, 0, 31, 18, 0, 247]);
+          device(port_name).raw([240, 126, 127, 6, 1, 247]);
 
 
-          device("nanoKONTROL2 MIDI 1").raw([ 240, 66, 64, 0, 1, 19, 0, 127, 127,
+          device(port_name).raw([ 240, 66, 64, 0, 1, 19, 0, 127, 127,
                 2, 3, 5, 64, 0, 0, 0, 1, 16, 1, 0, 0, 0, 0, 127, 0, 1, 0, 16,
                 0, 0, 127, 0, 1, 0, 32, 0, 127, 0, 0, 1, 0, 48, 0, 127, 0, 0,
                 1, 0, 64, 0, 127, 0, 16, 0, 1, 0, 1, 0, 127, 0, 1, 0, 0, 17, 0,
                 2, 3, 5, 64, 0, 0, 0, 1, 16, 1, 0, 0, 0, 0, 127, 0, 1, 0, 16,
                 0, 0, 127, 0, 1, 0, 32, 0, 127, 0, 0, 1, 0, 48, 0, 127, 0, 0,
                 1, 0, 64, 0, 127, 0, 16, 0, 1, 0, 1, 0, 127, 0, 1, 0, 0, 17, 0,
@@ -124,11 +125,11 @@ registerPort: function(port) {
                 127, 0, 127, 127, 127, 127, 0, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                 0, 0, 0, 0, 0, 0, 0, 0, 0, 247]);
 
                 127, 0, 127, 127, 127, 127, 0, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                 0, 0, 0, 0, 0, 0, 0, 0, 0, 247]);
 
-          device("nanoKONTROL2 MIDI 1").raw([240, 126, 127, 6, 1, 247]);
-          device("nanoKONTROL2 MIDI 1").raw([240, 66, 64, 0, 1, 19, 0, 31, 17, 0, 247]);
+          device(port_name).raw([240, 126, 127, 6, 1, 247]);
+          device(port_name).raw([240, 66, 64, 0, 1, 19, 0, 31, 17, 0, 247]);
 
 
-          function on(note) { device("nanoKONTROL2 MIDI 1").cc(note, 127); }
-          function off(note) { device("nanoKONTROL2 MIDI 1").cc(note, 0); }
+          function on(note) { device(port_name).cc(note, 127); }
+          function off(note) { device(port_name).cc(note, 0); }
           var leds = Array(43, 44, 42, 41, 45);
           for (var i=0; i<8; i++) {
             leds.push(64+i);
           var leds = Array(43, 44, 42, 41, 45);
           for (var i=0; i<8; i++) {
             leds.push(64+i);