load fewer audio files when the screen is smaller
helps speed up the mobile load time
This commit is contained in:
parent
00b55add86
commit
16ee3e84a1
@ -23,7 +23,15 @@ import {Sampler} from 'sound/Sampler'
|
|||||||
class Sound {
|
class Sound {
|
||||||
constructor(){
|
constructor(){
|
||||||
|
|
||||||
|
// 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._range = [24, 108]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this._piano = new Sampler('audio/Salamander/', this._range)
|
this._piano = new Sampler('audio/Salamander/', this._range)
|
||||||
|
|
||||||
@ -36,7 +44,6 @@ class Sound {
|
|||||||
}
|
}
|
||||||
|
|
||||||
keyDown(note, time=Tone.now(), ai=false){
|
keyDown(note, time=Tone.now(), ai=false){
|
||||||
|
|
||||||
if (note >= this._range[0] && note <= this._range[1]){
|
if (note >= this._range[0] && note <= this._range[1]){
|
||||||
this._piano.keyDown(note, time)
|
this._piano.keyDown(note, time)
|
||||||
if (ai){
|
if (ai){
|
||||||
|
Loading…
Reference in New Issue
Block a user