From 1f4ef3fd195b5cc1b0fe3194258bb37792ef7b91 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Fri, 14 Oct 2016 10:26:08 -0400 Subject: [PATCH] loading all sounds on project load --- src/index.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index 13b3106..2c1c1b5 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ var Tone = require('tone'); var Soundfont = require('soundfont-player'); -function AudioEngine () { +function AudioEngine (sounds) { // tone setup @@ -25,8 +25,9 @@ function AudioEngine () { // sound urls - map each url to its tone.sampler this.soundSamplers = []; + this.loadSounds(sounds); - // soundfont setup + // soundfont setup // instrument names used by Musyng Kite soundfont, in order to // match scratch instruments @@ -42,6 +43,15 @@ function AudioEngine () { ); } +AudioEngine.prototype.loadSounds = function (sounds) { + for (var i=0; i