Merge pull request #1159 from jdanford/update-standardized-audio-context

Update standardized-audio-context, fix little lint errors
This commit is contained in:
Yotam Mann 2023-01-26 17:51:11 -05:00 committed by GitHub
commit 47d464487e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 73 additions and 72 deletions

View file

@ -5,7 +5,7 @@ module.exports = {
rules: { rules: {
"prefer-rest-params": "off", "prefer-rest-params": "off",
"@typescript-eslint/ban-ts-ignore": "off", "@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/ban-ts-comment" : "off", "@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-function": "off", "@typescript-eslint/no-empty-function": "off",
"jsdoc/check-alignment": 1, "jsdoc/check-alignment": 1,
"jsdoc/check-param-names": ["error"], "jsdoc/check-param-names": ["error"],

View file

@ -103,7 +103,7 @@ export class Meter extends MeterBase<MeterOptions> {
const rms = Math.sqrt(totalSquared / values.length); const rms = Math.sqrt(totalSquared / values.length);
// the rms can only fall at the rate of the smoothing // the rms can only fall at the rate of the smoothing
// but can jump up instantly // but can jump up instantly
this._rms[index] = Math.max(rms, this._rms[index] * this.smoothing); this._rms[index] = Math.max(rms, this._rms[index] * this.smoothing);
return this.normalRange ? this._rms[index] : gainToDb(this._rms[index]); return this.normalRange ? this._rms[index] : gainToDb(this._rms[index]);
}); });
if (this.channels === 1) { if (this.channels === 1) {

View file

@ -200,7 +200,7 @@ export class TickSource<TypeName extends "bpm" | "hertz"> extends ToneWithContex
if (lastState.state === "started" && e.state !== "started") { if (lastState.state === "started" && e.state !== "started") {
elapsedTicks += this.frequency.getTicksAtTime(e.time) - this.frequency.getTicksAtTime(periodStartTime); elapsedTicks += this.frequency.getTicksAtTime(e.time) - this.frequency.getTicksAtTime(periodStartTime);
// do not memoize the temporary event // do not memoize the temporary event
if (e.time != tmpEvent.time) { if (e.time !== tmpEvent.time) {
eventToMemoize = { state: e.state, time: e.time, ticks: elapsedTicks }; eventToMemoize = { state: e.state, time: e.time, ticks: elapsedTicks };
} }
} }
@ -275,7 +275,7 @@ export class TickSource<TypeName extends "bpm" | "hertz"> extends ToneWithContex
if (lastState.state === "started" && e.state !== "started") { if (lastState.state === "started" && e.state !== "started") {
elapsedSeconds += e.time - periodStartTime; elapsedSeconds += e.time - periodStartTime;
// do not memoize the temporary event // do not memoize the temporary event
if (e.time != tmpEvent.time) { if (e.time !== tmpEvent.time) {
eventToMemoize = { state: e.state, time: e.time, seconds: elapsedSeconds }; eventToMemoize = { state: e.state, time: e.time, seconds: elapsedSeconds };
} }
} }

View file

@ -42,7 +42,7 @@ export class Ticker {
this._callback = callback; this._callback = callback;
this._type = type; this._type = type;
this._minimumUpdateInterval = Math.max( 128/(contextSampleRate || 44100), .001 ); this._minimumUpdateInterval = Math.max(128/(contextSampleRate || 44100), .001);
this.updateInterval = updateInterval; this.updateInterval = updateInterval;
// create the clock source for the first time // create the clock source for the first time

View file

@ -397,9 +397,9 @@ export class ToneAudioBuffer extends Tone {
const location = document.createElement("a"); const location = document.createElement("a");
location.href = baseUrl + url; location.href = baseUrl + url;
location.pathname = (location.pathname + location.hash) location.pathname = (location.pathname + location.hash)
.split("/") .split("/")
.map(encodeURIComponent) .map(encodeURIComponent)
.join("/"); .join("/");
const response = await fetch(location.href); const response = await fetch(location.href);
if (!response.ok) { if (!response.ok) {
@ -425,8 +425,8 @@ export class ToneAudioBuffer extends Tone {
const extensions = url.split("."); const extensions = url.split(".");
const extension = extensions[extensions.length - 1]; const extension = extensions[extensions.length - 1];
const response = document const response = document
.createElement("audio") .createElement("audio")
.canPlayType("audio/" + extension); .canPlayType("audio/" + extension);
return response !== ""; return response !== "";
} }

View file

@ -1,3 +1,4 @@
/* eslint-disable key-spacing */
import { getContext } from "../Global"; import { getContext } from "../Global";
import { intervalToFrequencyRatio, mtof } from "./Conversions"; import { intervalToFrequencyRatio, mtof } from "./Conversions";
import { ftom, getA4, setA4 } from "./Conversions"; import { ftom, getA4, setA4 } from "./Conversions";
@ -215,7 +216,7 @@ export class FrequencyClass<Type extends number = Hertz> extends TimeClass<Type,
//------------------------------------- //-------------------------------------
/** /**
* Note to scale index. * Note to scale index.
* @hidden * @hidden
*/ */
const noteToScaleIndex = { const noteToScaleIndex = {

View file

@ -15,8 +15,8 @@ describe("Chorus", () => {
() => { () => {
const chorus = new Chorus().toDestination().start(); const chorus = new Chorus().toDestination().start();
const osc = new Oscillator(220, "sawtooth") const osc = new Oscillator(220, "sawtooth")
.connect(chorus) .connect(chorus)
.start(); .start();
}, },
"chorus.wav", "chorus.wav",
0.25 0.25

View file

@ -32,7 +32,7 @@ type ToneObject = {
* Bind the TimeBaseClass to the context * Bind the TimeBaseClass to the context
*/ */
function bindTypeClass(context: Context, type) { function bindTypeClass(context: Context, type) {
return (...args: any[]) => new type(context, ...args); return (...args: unknown[]) => new type(context, ...args);
} }
/** /**

View file

@ -502,9 +502,9 @@ describe("Player", () => {
const player = new Player(buffer); const player = new Player(buffer);
player.toDestination(); player.toDestination();
player player
.start(0, 0, 0.05) .start(0, 0, 0.05)
.start(0.1, 0, 0.05) .start(0.1, 0, 0.05)
.start(0.2, 0, 0.05); .start(0.2, 0, 0.05);
player.stop(0.1); player.stop(0.1);
}, 0.3).then((buff) => { }, 0.3).then((buff) => {
expect(buff.getTimeOfLastSound()).to.be.closeTo(0.1, 0.02); expect(buff.getTimeOfLastSound()).to.be.closeTo(0.1, 0.02);
@ -559,9 +559,9 @@ describe("Player", () => {
it("plays synced to the Transport", () => { it("plays synced to the Transport", () => {
return Offline(({ transport }) => { return Offline(({ transport }) => {
const player = new Player(buffer) const player = new Player(buffer)
.sync() .sync()
.start(0) .start(0)
.toDestination(); .toDestination();
transport.start(0); transport.start(0);
}, 0.05).then((buff) => { }, 0.05).then((buff) => {
expect(buff.isSilent()).to.be.false; expect(buff.isSilent()).to.be.false;
@ -587,13 +587,13 @@ describe("Player", () => {
it("offsets correctly when started by the Transport", () => { it("offsets correctly when started by the Transport", () => {
const testSample = const testSample =
buffer.toArray(0)[ buffer.toArray(0)[
Math.floor(0.13125 * getContext().sampleRate) Math.floor(0.13125 * getContext().sampleRate)
]; ];
return Offline(({ transport }) => { return Offline(({ transport }) => {
const player = new Player(buffer) const player = new Player(buffer)
.sync() .sync()
.start(0, 0.1) .start(0, 0.1)
.toDestination(); .toDestination();
transport.start(0, 0.03125); transport.start(0, 0.03125);
}, 0.05).then((buff) => { }, 0.05).then((buff) => {
expect(buff.toArray()[0][0]).to.equal(testSample); expect(buff.toArray()[0][0]).to.equal(testSample);
@ -709,12 +709,12 @@ describe("Player", () => {
setTimeout(() => { setTimeout(() => {
player.restart(undefined, undefined, 1); player.restart(undefined, undefined, 1);
const checkStopTimes = new Set(); const checkStopTimes = new Set();
player["_activeSources"].forEach(source => { player._activeSources.forEach(source => {
checkStopTimes.add(source["_stopTime"]); checkStopTimes.add(source._stopTime);
}); });
getContext().lookAhead = originalLookAhead; getContext().lookAhead = originalLookAhead;
// ensure each source has a different stopTime // ensure each source has a different stopTime
expect(checkStopTimes.size).to.equal(player["_activeSources"].size); expect(checkStopTimes.size).to.equal(player._activeSources.size);
done(); done();
}, 250); }, 250);
}, },

88
package-lock.json generated
View file

@ -9,7 +9,7 @@
"version": "14.8.0", "version": "14.8.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"standardized-audio-context": "^25.3.29", "standardized-audio-context": "^25.3.37",
"tslib": "^2.3.1" "tslib": "^2.3.1"
}, },
"devDependencies": { "devDependencies": {
@ -417,20 +417,20 @@
} }
}, },
"node_modules/@babel/runtime": { "node_modules/@babel/runtime": {
"version": "7.18.9", "version": "7.20.13",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.9.tgz", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.13.tgz",
"integrity": "sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==", "integrity": "sha512-gt3PKXs0DBoL9xCvOIIZ2NEqAGZqHjAnmVbfQtB620V0uReIQutpel14KcneZuer7UioY8ALKZ7iocavvzTNFA==",
"dependencies": { "dependencies": {
"regenerator-runtime": "^0.13.4" "regenerator-runtime": "^0.13.11"
}, },
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/runtime/node_modules/regenerator-runtime": { "node_modules/@babel/runtime/node_modules/regenerator-runtime": {
"version": "0.13.9", "version": "0.13.11",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
"integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
}, },
"node_modules/@babel/template": { "node_modules/@babel/template": {
"version": "7.18.10", "version": "7.18.10",
@ -1544,15 +1544,15 @@
"dev": true "dev": true
}, },
"node_modules/automation-events": { "node_modules/automation-events": {
"version": "4.0.20", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/automation-events/-/automation-events-4.0.20.tgz", "resolved": "https://registry.npmjs.org/automation-events/-/automation-events-5.0.0.tgz",
"integrity": "sha512-ALTOLrB4vTyXOsLPia8OKM1qZKtlsGC+3VDe3jcCGUpvgKTbqlzvaJU3HqDhU6jlVEMMBqT01XZv3K/3Z5g29w==", "integrity": "sha512-SkYa2YBwgRUJNsR5v6GxeJwP5IGnYtOMW37coplTOWMUpDYYrk5j8gGOhYa765rchRln/HssFzMAck/2P6zTFw==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.18.9", "@babel/runtime": "^7.20.7",
"tslib": "^2.4.0" "tslib": "^2.4.1"
}, },
"engines": { "engines": {
"node": ">=12.20.1" "node": ">=14.15.4"
} }
}, },
"node_modules/available-typed-arrays": { "node_modules/available-typed-arrays": {
@ -8780,13 +8780,13 @@
"dev": true "dev": true
}, },
"node_modules/standardized-audio-context": { "node_modules/standardized-audio-context": {
"version": "25.3.29", "version": "25.3.37",
"resolved": "https://registry.npmjs.org/standardized-audio-context/-/standardized-audio-context-25.3.29.tgz", "resolved": "https://registry.npmjs.org/standardized-audio-context/-/standardized-audio-context-25.3.37.tgz",
"integrity": "sha512-5RqrvuaphiR3W2t8nd8PRBhQKXTTf0gHu8I0BukH3A11C9ZHQQmeE9WywBe68TcYBj9DCm42db8OWTw1PluLUA==", "integrity": "sha512-lr0+RH/IJXYMts95oYKIJ+orTmstOZN3GXWVGmlkbMj8OLahREkRh7DhNGLYgBGDkBkhhc4ev5pYGSFN3gltHw==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.18.9", "@babel/runtime": "^7.20.7",
"automation-events": "^4.0.20", "automation-events": "^5.0.0",
"tslib": "^2.4.0" "tslib": "^2.4.1"
} }
}, },
"node_modules/statuses": { "node_modules/statuses": {
@ -9427,9 +9427,9 @@
} }
}, },
"node_modules/tslib": { "node_modules/tslib": {
"version": "2.4.0", "version": "2.4.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz",
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA=="
}, },
"node_modules/tsutils": { "node_modules/tsutils": {
"version": "3.21.0", "version": "3.21.0",
@ -10650,17 +10650,17 @@
"dev": true "dev": true
}, },
"@babel/runtime": { "@babel/runtime": {
"version": "7.18.9", "version": "7.20.13",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.9.tgz", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.13.tgz",
"integrity": "sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==", "integrity": "sha512-gt3PKXs0DBoL9xCvOIIZ2NEqAGZqHjAnmVbfQtB620V0uReIQutpel14KcneZuer7UioY8ALKZ7iocavvzTNFA==",
"requires": { "requires": {
"regenerator-runtime": "^0.13.4" "regenerator-runtime": "^0.13.11"
}, },
"dependencies": { "dependencies": {
"regenerator-runtime": { "regenerator-runtime": {
"version": "0.13.9", "version": "0.13.11",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
"integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
} }
} }
}, },
@ -11552,12 +11552,12 @@
"dev": true "dev": true
}, },
"automation-events": { "automation-events": {
"version": "4.0.20", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/automation-events/-/automation-events-4.0.20.tgz", "resolved": "https://registry.npmjs.org/automation-events/-/automation-events-5.0.0.tgz",
"integrity": "sha512-ALTOLrB4vTyXOsLPia8OKM1qZKtlsGC+3VDe3jcCGUpvgKTbqlzvaJU3HqDhU6jlVEMMBqT01XZv3K/3Z5g29w==", "integrity": "sha512-SkYa2YBwgRUJNsR5v6GxeJwP5IGnYtOMW37coplTOWMUpDYYrk5j8gGOhYa765rchRln/HssFzMAck/2P6zTFw==",
"requires": { "requires": {
"@babel/runtime": "^7.18.9", "@babel/runtime": "^7.20.7",
"tslib": "^2.4.0" "tslib": "^2.4.1"
} }
}, },
"available-typed-arrays": { "available-typed-arrays": {
@ -17292,13 +17292,13 @@
"dev": true "dev": true
}, },
"standardized-audio-context": { "standardized-audio-context": {
"version": "25.3.29", "version": "25.3.37",
"resolved": "https://registry.npmjs.org/standardized-audio-context/-/standardized-audio-context-25.3.29.tgz", "resolved": "https://registry.npmjs.org/standardized-audio-context/-/standardized-audio-context-25.3.37.tgz",
"integrity": "sha512-5RqrvuaphiR3W2t8nd8PRBhQKXTTf0gHu8I0BukH3A11C9ZHQQmeE9WywBe68TcYBj9DCm42db8OWTw1PluLUA==", "integrity": "sha512-lr0+RH/IJXYMts95oYKIJ+orTmstOZN3GXWVGmlkbMj8OLahREkRh7DhNGLYgBGDkBkhhc4ev5pYGSFN3gltHw==",
"requires": { "requires": {
"@babel/runtime": "^7.18.9", "@babel/runtime": "^7.20.7",
"automation-events": "^4.0.20", "automation-events": "^5.0.0",
"tslib": "^2.4.0" "tslib": "^2.4.1"
} }
}, },
"statuses": { "statuses": {
@ -17781,9 +17781,9 @@
} }
}, },
"tslib": { "tslib": {
"version": "2.4.0", "version": "2.4.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz",
"integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA=="
}, },
"tsutils": { "tsutils": {
"version": "3.21.0", "version": "3.21.0",

View file

@ -103,7 +103,7 @@
"yargs": "^17.3.0" "yargs": "^17.3.0"
}, },
"dependencies": { "dependencies": {
"standardized-audio-context": "^25.3.29", "standardized-audio-context": "^25.3.37",
"tslib": "^2.3.1" "tslib": "^2.3.1"
}, },
"prettier": { "prettier": {