diff --git a/src/DrumPlayer.js b/src/DrumPlayer.js index b020542..3d1aaf4 100644 --- a/src/DrumPlayer.js +++ b/src/DrumPlayer.js @@ -38,7 +38,7 @@ class DrumPlayer { // download and decode the drum sounds // @todo: use scratch-storage to manage these sound files - const url = baseUrl + fileNames[i] + '_22k.wav'; + const url = `${baseUrl}${fileNames[i]}_22k.wav`; const request = new XMLHttpRequest(); request.open('GET', url, true); request.responseType = 'arraybuffer'; diff --git a/src/InstrumentPlayer.js b/src/InstrumentPlayer.js index 627e910..bb3484d 100644 --- a/src/InstrumentPlayer.js +++ b/src/InstrumentPlayer.js @@ -9,7 +9,7 @@ class InstrumentPlayer { * play note or set instrument block runs, causing a delay of a few seconds. * Using this library we don't have a way to set the volume, sustain the note beyond the sample * duration, or run it through the sprite-specific audio effects. - * @param {AudioNode} outputNode - a webAudio node that the instrument will send its output to + * @param {AudioContext} context - a webAudio context * @constructor */ constructor (context) { diff --git a/src/effects/PitchEffect.js b/src/effects/PitchEffect.js index 7cebc44..3de5c5b 100644 --- a/src/effects/PitchEffect.js +++ b/src/effects/PitchEffect.js @@ -59,7 +59,7 @@ class PitchEffect { * @returns {number} a frequency ratio */ intervalToFrequencyRatio (interval) { - return Math.pow(2, (interval/12)); + return Math.pow(2, (interval / 12)); } /** diff --git a/src/index.js b/src/index.js index ea53ea7..ff638ba 100644 --- a/src/index.js +++ b/src/index.js @@ -149,7 +149,7 @@ class AudioPlayer { */ class AudioEngine { constructor () { - var AudioContext = window.AudioContext || window.webkitAudioContext; + const AudioContext = window.AudioContext || window.webkitAudioContext; this.context = new AudioContext(); this.input = this.context.createGain(); @@ -200,7 +200,7 @@ class AudioEngine { let loaderPromise = null; // Make a copy of the buffer because decoding detaches the original buffer - var bufferCopy = sound.data.buffer.slice(0); + const bufferCopy = sound.data.buffer.slice(0); switch (sound.format) { case '': @@ -296,13 +296,14 @@ class AudioEngine { // the microphone has not been set up, try to connect to it if (!this.mic && !this.connectingToMic) { this.connectingToMic = true; // prevent multiple connection attempts - navigator.mediaDevices.getUserMedia({audio : true}).then(stream => { + navigator.mediaDevices.getUserMedia({audio: true}).then(stream => { this.mic = this.context.createMediaStreamSource(stream); this.analyser = this.context.createAnalyser(); this.mic.connect(this.analyser); this.micDataArray = new Float32Array(this.analyser.fftSize); - }).catch(err => { - log.warn(err) + }) + .catch(err => { + log.warn(err); }); }