Skip to content

Commit

Permalink
Merge pull request #1159 from jdanford/update-standardized-audio-context
Browse files Browse the repository at this point in the history
Update standardized-audio-context, fix little lint errors
  • Loading branch information
tambien authored Jan 26, 2023
2 parents 9b15a92 + de4dd28 commit 47d4644
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
rules: {
"prefer-rest-params": "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",
"jsdoc/check-alignment": 1,
"jsdoc/check-param-names": ["error"],
Expand Down
2 changes: 1 addition & 1 deletion Tone/component/analysis/Meter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class Meter extends MeterBase<MeterOptions> {
const rms = Math.sqrt(totalSquared / values.length);
// the rms can only fall at the rate of the smoothing
// 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]);
});
if (this.channels === 1) {
Expand Down
4 changes: 2 additions & 2 deletions Tone/core/clock/TickSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class TickSource<TypeName extends "bpm" | "hertz"> extends ToneWithContex
if (lastState.state === "started" && e.state !== "started") {
elapsedTicks += this.frequency.getTicksAtTime(e.time) - this.frequency.getTicksAtTime(periodStartTime);
// 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 };
}
}
Expand Down Expand Up @@ -275,7 +275,7 @@ export class TickSource<TypeName extends "bpm" | "hertz"> extends ToneWithContex
if (lastState.state === "started" && e.state !== "started") {
elapsedSeconds += e.time - periodStartTime;
// 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 };
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tone/core/clock/Ticker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class Ticker {

this._callback = callback;
this._type = type;
this._minimumUpdateInterval = Math.max( 128/(contextSampleRate || 44100), .001 );
this._minimumUpdateInterval = Math.max(128/(contextSampleRate || 44100), .001);
this.updateInterval = updateInterval;

// create the clock source for the first time
Expand Down
10 changes: 5 additions & 5 deletions Tone/core/context/ToneAudioBuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ export class ToneAudioBuffer extends Tone {
const location = document.createElement("a");
location.href = baseUrl + url;
location.pathname = (location.pathname + location.hash)
.split("/")
.map(encodeURIComponent)
.join("/");
.split("/")
.map(encodeURIComponent)
.join("/");

const response = await fetch(location.href);
if (!response.ok) {
Expand All @@ -425,8 +425,8 @@ export class ToneAudioBuffer extends Tone {
const extensions = url.split(".");
const extension = extensions[extensions.length - 1];
const response = document
.createElement("audio")
.canPlayType("audio/" + extension);
.createElement("audio")
.canPlayType("audio/" + extension);
return response !== "";
}

Expand Down
3 changes: 2 additions & 1 deletion Tone/core/type/Frequency.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable key-spacing */
import { getContext } from "../Global";
import { intervalToFrequencyRatio, mtof } from "./Conversions";
import { ftom, getA4, setA4 } from "./Conversions";
Expand Down Expand Up @@ -215,7 +216,7 @@ export class FrequencyClass<Type extends number = Hertz> extends TimeClass<Type,
//-------------------------------------

/**
* Note to scale index.
* Note to scale index.
* @hidden
*/
const noteToScaleIndex = {
Expand Down
4 changes: 2 additions & 2 deletions Tone/effect/Chorus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe("Chorus", () => {
() => {
const chorus = new Chorus().toDestination().start();
const osc = new Oscillator(220, "sawtooth")
.connect(chorus)
.start();
.connect(chorus)
.start();
},
"chorus.wav",
0.25
Expand Down
2 changes: 1 addition & 1 deletion Tone/fromContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type ToneObject = {
* Bind the TimeBaseClass to the context
*/
function bindTypeClass(context: Context, type) {
return (...args: any[]) => new type(context, ...args);
return (...args: unknown[]) => new type(context, ...args);
}

/**
Expand Down
26 changes: 13 additions & 13 deletions Tone/source/buffer/Player.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,9 @@ describe("Player", () => {
const player = new Player(buffer);
player.toDestination();
player
.start(0, 0, 0.05)
.start(0.1, 0, 0.05)
.start(0.2, 0, 0.05);
.start(0, 0, 0.05)
.start(0.1, 0, 0.05)
.start(0.2, 0, 0.05);
player.stop(0.1);
}, 0.3).then((buff) => {
expect(buff.getTimeOfLastSound()).to.be.closeTo(0.1, 0.02);
Expand Down Expand Up @@ -559,9 +559,9 @@ describe("Player", () => {
it("plays synced to the Transport", () => {
return Offline(({ transport }) => {
const player = new Player(buffer)
.sync()
.start(0)
.toDestination();
.sync()
.start(0)
.toDestination();
transport.start(0);
}, 0.05).then((buff) => {
expect(buff.isSilent()).to.be.false;
Expand All @@ -587,13 +587,13 @@ describe("Player", () => {
it("offsets correctly when started by the Transport", () => {
const testSample =
buffer.toArray(0)[
Math.floor(0.13125 * getContext().sampleRate)
Math.floor(0.13125 * getContext().sampleRate)
];
return Offline(({ transport }) => {
const player = new Player(buffer)
.sync()
.start(0, 0.1)
.toDestination();
.sync()
.start(0, 0.1)
.toDestination();
transport.start(0, 0.03125);
}, 0.05).then((buff) => {
expect(buff.toArray()[0][0]).to.equal(testSample);
Expand Down Expand Up @@ -709,12 +709,12 @@ describe("Player", () => {
setTimeout(() => {
player.restart(undefined, undefined, 1);
const checkStopTimes = new Set();
player["_activeSources"].forEach(source => {
checkStopTimes.add(source["_stopTime"]);
player._activeSources.forEach(source => {
checkStopTimes.add(source._stopTime);
});
getContext().lookAhead = originalLookAhead;
// ensure each source has a different stopTime
expect(checkStopTimes.size).to.equal(player["_activeSources"].size);
expect(checkStopTimes.size).to.equal(player._activeSources.size);
done();
}, 250);
},
Expand Down
88 changes: 44 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"yargs": "^17.3.0"
},
"dependencies": {
"standardized-audio-context": "^25.3.29",
"standardized-audio-context": "^25.3.37",
"tslib": "^2.3.1"
},
"prettier": {
Expand Down

0 comments on commit 47d4644

Please sign in to comment.