From b5bfa95297fbfb901bda739b402d994db3ab9f39 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 22 Feb 2017 12:01:22 +0100 Subject: [PATCH] allow selection of multiple files --- index.html | 2 +- nanofun.js | 34 ++++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index d4cd50f..55897f2 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@
- +
diff --git a/nanofun.js b/nanofun.js index 2a2a5df..a1c14b1 100644 --- a/nanofun.js +++ b/nanofun.js @@ -324,21 +324,27 @@ var nanofun = function() { } $('.nanotouch input[type=file]').on('change', function(ev) { - var nanotouch = $(this).parent(); - var sample_idx = $nanopad.children().index(nanotouch); - var reader = new FileReader(); - reader.onload = function(e) { - self.audioCtx.decodeAudioData(this.result, function(buffer) { - sample_buffers[sample_idx] = buffer; - $(nanotouch).find('span.duration').text(parseInt(buffer.duration) + 's'); - $(nanotouch).removeClass('error').addClass('loaded'); - }, function(e) { - $(nanotouch).find('span').text(''); - $(nanotouch).removeClass('loaded').addClass('error'); - }); + var sample_idx = parseInt($(this).parent().data('touch')); + for (var i=0; i