From 830c9eee4cb39bd65b7e24de633157f5b5fdd382 Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Mon, 13 Feb 2017 17:31:47 -0500 Subject: [PATCH] load fewer audio files when the screen is smaller helps speed up the mobile load time --- static/src/sound/Sound.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/static/src/sound/Sound.js b/static/src/sound/Sound.js index 8716145..a2c62c7 100644 --- a/static/src/sound/Sound.js +++ b/static/src/sound/Sound.js @@ -23,7 +23,15 @@ import {Sampler} from 'sound/Sampler' class Sound { constructor(){ - this._range = [24, 108] + // make the samples loaded based on the screen size + if (screen.availWidth < 750 && screen.availHeight < 750){ + this._range = [48, 72] + } else if (screen.availWidth < 1000 && screen.availHeight < 1000){ + this._range = [48, 84] + } else { + this._range = [24, 108] + } + this._piano = new Sampler('audio/Salamander/', this._range) @@ -36,7 +44,6 @@ class Sound { } keyDown(note, time=Tone.now(), ai=false){ - if (note >= this._range[0] && note <= this._range[1]){ this._piano.keyDown(note, time) if (ai){