} 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); }
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);
}
},
} 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,
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 self = this;
self.initAudio = function() {
- self.sample_buffers = Array(16);
- self.samples = Array(16);
- self.sample_start_times = Array(16);
+ self.sample_buffers = Array(NANOPAD_TOUCHS.length);
+ self.samples = Array(NANOPAD_TOUCHS.length);
+ self.sample_start_times = Array(NANOPAD_TOUCHS.length);
self.audioCtx = new window.AudioContext();
- self.touchGainNodes = Array(16);
+ self.touchGainNodes = Array(NANOPAD_TOUCHS.length);
self.masterGainNode = self.audioCtx.createGain();
- for (var i=0; i<16; i++) {
+ self.effectsGainNode = self.audioCtx.createGain();
+ for (var i=0; i<NANOPAD_TOUCHS.length; i++) {
self.touchGainNodes[i] = self.audioCtx.createGain();
self.touchGainNodes[i].connect(self.masterGainNode);
}
self.filter = self.audioCtx.createBiquadFilter();
self.filter.frequency.value = 1000;
+ self.effectsGainNode.connect(self.delay);
self.delay.connect(self.feedback);
self.feedback.connect(self.filter);
self.filter.connect(self.delay);
- self.masterGainNode.connect(self.delay);
+ self.filter.connect(self.masterGainNode);
}
self.initMIDI = function() {
self.initUI = function() {
var $nanopad = $('#nanopad');
var $nanotouch = $('.nanotouch');
- for (var i=0; i<16; i++) {
+ for (var i=0; i<NANOPAD_TOUCHS.length; i++) {
var $new_touch = $nanotouch.clone();
$new_touch.attr('data-touch', i);
$new_touch.appendTo($nanopad);
}
});
+ $('.effects input').on('change', function() {
+ var effects = $(this).prop('checked');
+ var i = parseInt($(this).parents('.nanotouch').data('touch'));
+ if (effects) {
+ self.touchGainNodes[i].connect(self.effectsGainNode);
+ } else {
+ self.touchGainNodes[i].disconnect(self.effectsGainNode);
+ }
+ });
+
$('#master-gain').on('change', function() {
var fraction = parseInt(this.value) / parseInt(127);
- self.masterGainNode.gain.value = fraction * fraction;
+ var now = self.audioCtx.currentTime;
+ self.masterGainNode.gain.exponentialRampToValueAtTime(fraction * fraction, now + 0.015);
});
$('#delay').on('change', function() {
if (value == 0) {
self.delay.disconnect();
} else {
- self.delay.delayTime.value = value;
+ var now = self.audioCtx.currentTime;
+ self.delay.delayTime.exponentialRampToValueAtTime(value, now + 0.015);
self.delay.connect(self.audioCtx.destination);
}
});
$('#feedback').on('change', function() {
- self.feedback.gain.value = this.value;
+ var now = self.audioCtx.currentTime;
+ self.feedback.gain.exponentialRampToValueAtTime(this.value, now + 0.015);
});
$('#filter').on('change', function() {
$('.touch-gain').on('change', function() {
var fraction = parseInt(this.value) / parseInt(127);
var touchIdx = parseInt($(this).parent().data('touch'));
- self.touchGainNodes[touchIdx].gain.value = fraction * fraction;
+ var now = self.audioCtx.currentTime;
+ self.touchGainNodes[touchIdx].gain.exponentialRampToValueAtTime(fraction * fraction, now + 0.015);
});
self.time_interval_id = setInterval(function() {
- for (var i=0; i<16; i++) {
+ for (var i=0; i<NANOPAD_TOUCHS.length; i++) {
var sample = self.samples[i];
if (sample !== undefined) {
var start_time = self.sample_start_times[i];