From c8418d327e9be85fc96933d6291b0b841db4a7b8 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 18 Oct 2021 21:27:30 +0000 Subject: [PATCH 1/4] chore(deps): update dependency eslint to v8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b5d8865..2cb339d 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "babel-eslint": "7.2.3", "babel-loader": "7.1.5", "babel-preset-env": "1.7.0", - "eslint": "3.19.0", + "eslint": "8.0.1", "eslint-config-scratch": "3.1.0", "tap": "12.7.0", "web-audio-test-api": "0.5.2", From 3e1238c4c7135c0c15eae143059fec4313b74d4c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:50:42 +0000 Subject: [PATCH 2/4] chore(deps): update dependency babel-eslint to v10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e94db85..e34b3f5 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "devDependencies": { "babel-core": "6.26.3", - "babel-eslint": "7.2.3", + "babel-eslint": "10.1.0", "babel-loader": "7.1.5", "babel-preset-env": "1.7.0", "eslint": "3.19.0", From bb19c1a76db56cf446a5496a2561526f7252a2a8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 15 Dec 2023 18:34:32 +0000 Subject: [PATCH 3/4] chore(deps): update dependency eslint-config-scratch to v9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e94db85..7a60f17 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "babel-loader": "7.1.5", "babel-preset-env": "1.7.0", "eslint": "3.19.0", - "eslint-config-scratch": "3.1.0", + "eslint-config-scratch": "9.0.3", "json": "9.0.6", "tap": "12.7.0", "web-audio-test-api": "0.5.2", From 068aca613604e39b2adbe785b17931cc43eec35f Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Fri, 15 Dec 2023 14:44:01 -0800 Subject: [PATCH 4/4] chore: lint fixes --- src/ADPCMSoundDecoder.js | 14 ++++---- src/ArrayBufferStream.js | 1 - src/AudioEngine.js | 2 +- src/Loudness.js | 6 ++-- src/SoundBank.js | 2 +- src/effects/Effect.js | 2 +- src/effects/PitchEffect.js | 2 +- test/SoundPlayer.js | 66 +++++++++++++++++++------------------- 8 files changed, 47 insertions(+), 48 deletions(-) diff --git a/src/ADPCMSoundDecoder.js b/src/ADPCMSoundDecoder.js index 82ee9be..5cf8926 100644 --- a/src/ADPCMSoundDecoder.js +++ b/src/ADPCMSoundDecoder.js @@ -89,7 +89,7 @@ class ADPCMSoundDecoder { * Decode an ADPCM sound stored in an ArrayBuffer and return a promise * with the decoded audio buffer. * @param {ArrayBuffer} audioData - containing ADPCM encoded wav audio - * @return {AudioBuffer} the decoded audio buffer + * @return {Promise.} the decoded audio buffer */ decode (audioData) { @@ -99,7 +99,7 @@ class ADPCMSoundDecoder { const riffStr = stream.readUint8String(4); if (riffStr !== 'RIFF') { log.warn('incorrect adpcm wav header'); - reject(); + reject(new Error('incorrect adpcm wav header')); } const lengthInHeader = stream.readInt32(); @@ -110,7 +110,7 @@ class ADPCMSoundDecoder { const wavStr = stream.readUint8String(4); if (wavStr !== 'WAVE') { log.warn('incorrect adpcm wav header'); - reject(); + reject(new Error('incorrect adpcm wav header')); } const formatChunk = this.extractChunk('fmt ', stream); @@ -120,7 +120,7 @@ class ADPCMSoundDecoder { this.bytesPerSecond = formatChunk.readUint32(); this.blockAlignment = formatChunk.readUint16(); this.bitsPerSample = formatChunk.readUint16(); - formatChunk.position += 2; // skip extra header byte count + formatChunk.position += 2; // skip extra header byte count this.samplesPerBlock = formatChunk.readUint16(); this.adpcmBlockSize = ((this.samplesPerBlock - 1) / 2) + 4; // block size in bytes @@ -168,7 +168,7 @@ class ADPCMSoundDecoder { const available = compressedData.getBytesAvailable(); const blocks = (available / blockSize) | 0; // Number of samples in full blocks. - const fullBlocks = blocks * (2 * (blockSize - 4)) + 1; + const fullBlocks = (blocks * (2 * (blockSize - 4))) + 1; // Number of samples in the last incomplete block. 0 if the last block // is full. const subBlock = Math.max((available % blockSize) - 4, 0) * 2; @@ -216,7 +216,7 @@ class ADPCMSoundDecoder { // read 4-bit code and compute delta from previous sample lastByte = compressedData.readUint8(); code = lastByte & 0xF; - delta = DELTA_TABLE[index * 16 + code]; + delta = DELTA_TABLE[(index * 16) + code]; // compute next index index += INDEX_TABLE[code]; if (index > 88) index = 88; @@ -230,7 +230,7 @@ class ADPCMSoundDecoder { // use 4-bit code from lastByte and compute delta from previous // sample code = (lastByte >> 4) & 0xF; - delta = DELTA_TABLE[index * 16 + code]; + delta = DELTA_TABLE[(index * 16) + code]; // compute next index index += INDEX_TABLE[code]; if (index > 88) index = 88; diff --git a/src/ArrayBufferStream.js b/src/ArrayBufferStream.js index 92a3e1a..ed75895 100644 --- a/src/ArrayBufferStream.js +++ b/src/ArrayBufferStream.js @@ -95,7 +95,6 @@ class ArrayBufferStream { */ set position (value) { this._position = value + this.start; - return value; } /** diff --git a/src/AudioEngine.js b/src/AudioEngine.js index 0340f50..89e1a94 100644 --- a/src/AudioEngine.js +++ b/src/AudioEngine.js @@ -218,7 +218,7 @@ class AudioEngine { */ decodeSoundPlayer (sound) { return this._decodeSound(sound) - .then(([id, buffer]) => new SoundPlayer(this, {id, buffer})); + .then(([id, buffer]) => new SoundPlayer(this, {id, buffer})); } /** diff --git a/src/Loudness.js b/src/Loudness.js index e459234..979ea79 100644 --- a/src/Loudness.js +++ b/src/Loudness.js @@ -44,9 +44,9 @@ class Loudness { this.mic.connect(this.analyser); this.micDataArray = new Float32Array(this.analyser.fftSize); }) - .catch(err => { - log.warn(err); - }); + .catch(err => { + log.warn(err); + }); } // If the microphone is set up and active, measure the loudness diff --git a/src/SoundBank.js b/src/SoundBank.js index 98ef0c4..bcee6b0 100644 --- a/src/SoundBank.js +++ b/src/SoundBank.js @@ -150,7 +150,7 @@ class SoundBank { this.soundEffects.forEach(effects => effects.dispose()); this.soundEffects.clear(); for (const soundId in this.soundPlayers) { - if (this.soundPlayers.hasOwnProperty(soundId)) { + if (Object.prototype.hasOwnProperty.call(this.soundPlayers, soundId)) { this.soundPlayers[soundId].dispose(); } } diff --git a/src/effects/Effect.js b/src/effects/Effect.js index c8e91ad..e9c0ae1 100644 --- a/src/effects/Effect.js +++ b/src/effects/Effect.js @@ -2,7 +2,7 @@ * An effect on an AudioPlayer and all its SoundPlayers. */ class Effect { - /** + /** * @param {AudioEngine} audioEngine - audio engine this runs with * @param {AudioPlayer} audioPlayer - audio player this affects * @param {Effect} lastEffect - effect in the chain before this one diff --git a/src/effects/PitchEffect.js b/src/effects/PitchEffect.js index 51d581d..78f78c5 100644 --- a/src/effects/PitchEffect.js +++ b/src/effects/PitchEffect.js @@ -118,7 +118,7 @@ class PitchEffect extends Effect { if (!players) return; for (const id in players) { - if (players.hasOwnProperty(id)) { + if (Object.prototype.hasOwnProperty.call(players, id)) { this.updatePlayer(players[id]); } } diff --git a/test/SoundPlayer.js b/test/SoundPlayer.js index 7931119..e582f68 100644 --- a/test/SoundPlayer.js +++ b/test/SoundPlayer.js @@ -157,51 +157,51 @@ tap.test('SoundPlayer', suite => { audioContext.$processTo(audioEngine.DECAY_DURATION); return Promise.resolve() - .then(() => { + .then(() => { - t.equal(soundPlayer.outputNode.$state, 'PLAYING'); + t.equal(soundPlayer.outputNode.$state, 'PLAYING'); - soundPlayer.play(); - soundPlayer.finished().then(() => log.push('play 2 finished')); + soundPlayer.play(); + soundPlayer.finished().then(() => log.push('play 2 finished')); - // wait for a micro-task loop to fire our previous events - return Promise.resolve(); - }) - .then(() => { + // wait for a micro-task loop to fire our previous events + return Promise.resolve(); + }) + .then(() => { - t.equal(log[0], 'play 1 finished'); - t.notEqual(soundPlayer.outputNode, firstPlayNode, 'created new player node'); + t.equal(log[0], 'play 1 finished'); + t.notEqual(soundPlayer.outputNode, firstPlayNode, 'created new player node'); - t.equal(help.engineInputs.length, 2, 'there should be 2 players connected'); - t.equal(firstPlayNode.$state, 'PLAYING'); - t.equal(soundPlayer.outputNode.$state, 'PLAYING'); - t.equal(help.engineInputs[0].gain.value, 1, 'old sound connectect to gain node with volume 1'); + t.equal(help.engineInputs.length, 2, 'there should be 2 players connected'); + t.equal(firstPlayNode.$state, 'PLAYING'); + t.equal(soundPlayer.outputNode.$state, 'PLAYING'); + t.equal(help.engineInputs[0].gain.value, 1, 'old sound connectect to gain node with volume 1'); - const {currentTime} = audioContext; - audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + 0.001); - t.notEqual(help.engineInputs[0].gain.value, 1, - 'old sound connected to gain node which will fade'); + const {currentTime} = audioContext; + audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + 0.001); + t.notEqual(help.engineInputs[0].gain.value, 1, + 'old sound connected to gain node which will fade'); - audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + audioEngine.DECAY_DURATION + 0.001); - t.equal(soundPlayer.outputNode.$state, 'PLAYING'); - t.equal(firstPlayNode.$state, 'FINISHED'); + audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + audioEngine.DECAY_DURATION + 0.001); + t.equal(soundPlayer.outputNode.$state, 'PLAYING'); + t.equal(firstPlayNode.$state, 'FINISHED'); - t.equal(help.engineInputs[0].gain.value, 0, 'faded old sound to 0'); + t.equal(help.engineInputs[0].gain.value, 0, 'faded old sound to 0'); - t.equal(log.length, 1); - audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + audioEngine.DECAY_DURATION + 0.3); + t.equal(log.length, 1); + audioContext.$processTo(currentTime + audioEngine.DECAY_WAIT + audioEngine.DECAY_DURATION + 0.3); - // wait for a micro-task loop to fire our previous events - return Promise.resolve(); - }) - .then(() => { + // wait for a micro-task loop to fire our previous events + return Promise.resolve(); + }) + .then(() => { - t.equal(log[1], 'play 2 finished'); - t.equal(help.engineInputs.length, 1, 'old sound disconneted itself after done'); - t.equal(log.length, 2); + t.equal(log[1], 'play 2 finished'); + t.equal(help.engineInputs.length, 1, 'old sound disconneted itself after done'); + t.equal(log.length, 2); - t.end(); - }); + t.end(); + }); }); suite.end();