From c3a1faa97b66bd28f67806e1a86bbfbbc0d7f044 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 23 Nov 2017 17:07:28 +0100 Subject: [PATCH] also detect the pads with their Windows-assigned names --- nanofun.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/nanofun.js b/nanofun.js index b3b58ac..014ebb0 100644 --- a/nanofun.js +++ b/nanofun.js @@ -61,8 +61,8 @@ onMIDIAccessChange: function(e) { } 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); } @@ -70,8 +70,8 @@ onMIDIAccessChange: function(e) { 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); } }, @@ -90,17 +90,18 @@ registerPort: function(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 */ - 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, @@ -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]); - 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); -- 2.39.2