<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>
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) */
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() {