From e8e785ffdde0e58d396483dbd3481fc222460ef5 Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Sun, 15 Sep 2019 23:32:40 -0400 Subject: [PATCH] linting --- .eslintrc.js | 1 + Tone/component/analysis/FFT.test.ts | 4 +- Tone/component/analysis/Meter.test.ts | 6 +- Tone/component/analysis/Waveform.test.ts | 2 +- Tone/component/channel/CrossFade.ts | 8 +- Tone/component/channel/Mono.ts | 2 +- Tone/component/channel/MultibandSplit.test.ts | 2 +- Tone/component/channel/PanVol.test.ts | 6 +- Tone/component/channel/Panner.test.ts | 2 +- Tone/component/channel/Panner3D.test.ts | 16 +- Tone/component/channel/Panner3D.ts | 28 +-- Tone/component/channel/Solo.test.ts | 2 +- Tone/component/channel/Split.test.ts | 4 +- Tone/component/dynamics/Compressor.test.ts | 30 +-- Tone/component/dynamics/Compressor.ts | 28 +-- .../envelope/AmplitudeEnvelope.test.ts | 28 +-- Tone/component/envelope/Envelope.test.ts | 204 +++++++++--------- Tone/component/envelope/Envelope.ts | 50 ++--- Tone/component/filter/EQ3.test.ts | 18 +- Tone/component/filter/EQ3.ts | 10 +- Tone/component/filter/Filter.test.ts | 14 +- .../filter/PhaseShiftAllpass.test.ts | 12 +- Tone/component/filter/PhaseShiftAllpass.ts | 2 +- Tone/core/clock/TickSignal.test.ts | 8 +- Tone/core/clock/TickSignal.ts | 2 +- Tone/core/clock/TickSource.ts | 6 +- Tone/core/clock/Ticker.ts | 2 +- Tone/core/clock/Transport.test.ts | 126 +++++------ Tone/core/clock/Transport.ts | 18 +- Tone/core/clock/TransportEvent.test.ts | 6 +- Tone/core/clock/TransportRepeatEvent.test.ts | 6 +- Tone/core/context/AudioContext.ts | 2 +- Tone/core/context/Context.test.ts | 102 ++++----- Tone/core/context/Delay.ts | 8 +- Tone/core/context/Destination.ts | 2 +- Tone/core/context/Gain.test.ts | 2 +- Tone/core/context/Gain.ts | 16 +- Tone/core/context/OfflineContext.ts | 2 +- Tone/core/context/Param.test.ts | 40 ++-- Tone/core/context/ToneAudioBuffer.test.ts | 2 +- Tone/core/context/ToneAudioBuffers.test.ts | 22 +- Tone/core/context/ToneAudioNode.test.ts | 4 +- Tone/core/context/ToneAudioNode.ts | 4 +- Tone/core/type/Frequency.test.ts | 6 +- Tone/core/type/Frequency.ts | 26 +-- Tone/core/type/Midi.test.ts | 2 +- Tone/core/type/NoteUnits.ts | 12 +- Tone/core/type/Ticks.test.ts | 30 +-- Tone/core/type/Time.test.ts | 2 +- Tone/core/type/Time.ts | 2 +- Tone/core/type/TimeBase.ts | 2 +- Tone/core/type/TransportTime.test.ts | 4 +- Tone/core/type/Units.ts | 4 +- Tone/core/util/Defaults.ts | 10 +- Tone/core/util/Draw.ts | 2 +- Tone/core/util/Emitter.ts | 2 +- Tone/core/util/Interface.ts | 4 +- Tone/source/buffer/Player.test.ts | 64 +++--- Tone/source/buffer/Player.ts | 34 +-- Tone/source/buffer/Players.test.ts | 54 ++--- Tone/source/buffer/ToneBufferSource.test.ts | 14 +- Tone/source/buffer/ToneBufferSource.ts | 12 +- Tone/source/oscillator/AMOscillator.test.ts | 6 +- Tone/source/oscillator/AMOscillator.ts | 6 +- Tone/source/oscillator/FMOscillator.test.ts | 8 +- Tone/source/oscillator/FMOscillator.ts | 4 +- Tone/source/oscillator/FatOscillator.test.ts | 12 +- Tone/source/oscillator/FatOscillator.ts | 8 +- Tone/source/oscillator/LFO.test.ts | 36 ++-- Tone/source/oscillator/LFO.ts | 20 +- Tone/source/oscillator/OmniOscillator.test.ts | 32 +-- Tone/source/oscillator/OmniOscillator.ts | 14 +- Tone/source/oscillator/Oscillator.test.ts | 10 +- Tone/source/oscillator/Oscillator.ts | 2 +- Tone/source/oscillator/PWMOscillator.ts | 2 +- .../source/oscillator/PulseOscillator.test.ts | 18 +- Tone/source/oscillator/PulseOscillator.ts | 2 +- Tone/source/oscillator/ToneOscillatorNode.ts | 12 +- package.json | 4 +- 79 files changed, 673 insertions(+), 668 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 80a68441..24d124fd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,6 +17,7 @@ module.exports = { "quotes": [ "error","double" ], "no-console": ["error", { "allow": ["warn"] }], "@typescript-eslint/no-object-literal-type-assertion" : "off", + "@typescript-eslint/no-unused-vars": "off", "sort-imports": ["error", { "ignoreCase": true, "ignoreDeclarationSort": true, diff --git a/Tone/component/analysis/FFT.test.ts b/Tone/component/analysis/FFT.test.ts index 853b3213..d3c116bf 100644 --- a/Tone/component/analysis/FFT.test.ts +++ b/Tone/component/analysis/FFT.test.ts @@ -11,7 +11,7 @@ describe("FFT", () => { it("can get and set properties", () => { const fft = new FFT(); fft.set({ - size : 128, + size: 128, smoothing: 0.4, }); const values = fft.get(); @@ -57,7 +57,7 @@ describe("FFT", () => { it("outputs a normal range", (done) => { const noise = new Noise(); const fft = new FFT({ - normalRange : true, + normalRange: true, }); noise.connect(fft); noise.start(); diff --git a/Tone/component/analysis/Meter.test.ts b/Tone/component/analysis/Meter.test.ts index 6c4c41fb..e785a2c4 100644 --- a/Tone/component/analysis/Meter.test.ts +++ b/Tone/component/analysis/Meter.test.ts @@ -15,7 +15,7 @@ describe("Meter", () => { it("handles getter/setter as Object", () => { const meter = new Meter(); const values = { - smoothing : 0.2, + smoothing: 0.2, }; meter.set(values); expect(meter.get().smoothing).to.equal(0.2); @@ -30,7 +30,7 @@ describe("Meter", () => { it("can be constructed with an object", () => { const meter = new Meter({ - smoothing : 0.3, + smoothing: 0.3, }); expect(meter.smoothing).to.equal(0.3); meter.dispose(); @@ -43,7 +43,7 @@ describe("Meter", () => { }); }); - it ("warns of deprecated method", () => { + it("warns of deprecated method", () => { warns(() => { const meter = new Meter().toDestination(); meter.getLevel(); diff --git a/Tone/component/analysis/Waveform.test.ts b/Tone/component/analysis/Waveform.test.ts index e634cfa0..b688c125 100644 --- a/Tone/component/analysis/Waveform.test.ts +++ b/Tone/component/analysis/Waveform.test.ts @@ -11,7 +11,7 @@ describe("Waveform", () => { it("can get and set properties", () => { const anl = new Waveform(); anl.set({ - size : 128, + size: 128, }); const values = anl.get(); expect(values.size).to.equal(128); diff --git a/Tone/component/channel/CrossFade.ts b/Tone/component/channel/CrossFade.ts index 24c0e939..d4a0f24c 100644 --- a/Tone/component/channel/CrossFade.ts +++ b/Tone/component/channel/CrossFade.ts @@ -60,13 +60,13 @@ export class CrossFade extends ToneAudioNode { * Convert the fade value into an audio range value so it can be connected * to the panner.pan AudioParam */ - private _g2a: GainToAudio = new GainToAudio({ context : this.context }); + private _g2a: GainToAudio = new GainToAudio({ context: this.context }); /** * The input which is at full level when fade = 0 */ readonly a: Gain = new Gain({ - context : this.context, + context: this.context, gain: 0, }); @@ -74,14 +74,14 @@ export class CrossFade extends ToneAudioNode { * The input which is at full level when fade = 1 */ readonly b: Gain = new Gain({ - context : this.context, + context: this.context, gain: 0, }); /** * The output is a mix between `a` and `b` at the ratio of `fade` */ - readonly output: Gain = new Gain({ context : this.context }); + readonly output: Gain = new Gain({ context: this.context }); /** * CrossFade has no input, you must choose either `a` or `b` diff --git a/Tone/component/channel/Mono.ts b/Tone/component/channel/Mono.ts index c268d56a..62f7c169 100644 --- a/Tone/component/channel/Mono.ts +++ b/Tone/component/channel/Mono.ts @@ -35,7 +35,7 @@ export class Mono extends ToneAudioNode { super(optionsFromArguments(Mono.getDefaults(), arguments)); const options = optionsFromArguments(Mono.getDefaults(), arguments); - this.input = new Gain({context: this.context}); + this.input = new Gain({ context: this.context }); this._merge = this.output = new Merge({ channels: 2, diff --git a/Tone/component/channel/MultibandSplit.test.ts b/Tone/component/channel/MultibandSplit.test.ts index bd767054..38f77b53 100644 --- a/Tone/component/channel/MultibandSplit.test.ts +++ b/Tone/component/channel/MultibandSplit.test.ts @@ -19,7 +19,7 @@ describe("MultibandSplit", () => { it("can be constructed with an object", () => { const split = new MultibandSplit({ - Q : 8, + Q: 8, highFrequency: 2700, lowFrequency: 500, }); diff --git a/Tone/component/channel/PanVol.test.ts b/Tone/component/channel/PanVol.test.ts index d397e23e..1ce44511 100644 --- a/Tone/component/channel/PanVol.test.ts +++ b/Tone/component/channel/PanVol.test.ts @@ -20,8 +20,8 @@ describe("PanVol", () => { it("can be constructed with an options object", () => { const panVol = new PanVol({ - mute : true, - pan : 0.2, + mute: true, + pan: 0.2, }); expect(panVol.pan.value).to.be.closeTo(0.2, 0.001); expect(panVol.mute).to.be.true; @@ -31,7 +31,7 @@ describe("PanVol", () => { it("can set/get with an object", () => { const panVol = new PanVol(); panVol.set({ - volume : -10, + volume: -10, }); expect(panVol.get().volume).to.be.closeTo(-10, 0.1); panVol.dispose(); diff --git a/Tone/component/channel/Panner.test.ts b/Tone/component/channel/Panner.test.ts index 8aa32132..ae7b05b6 100644 --- a/Tone/component/channel/Panner.test.ts +++ b/Tone/component/channel/Panner.test.ts @@ -19,7 +19,7 @@ describe("Panner", () => { it("can be constructed with an options object", () => { const panner = new Panner({ - pan : 0.5, + pan: 0.5, }); expect(panner.pan.value).to.be.closeTo(0.5, 0.001); panner.dispose(); diff --git a/Tone/component/channel/Panner3D.test.ts b/Tone/component/channel/Panner3D.test.ts index 26885f29..e0be9998 100644 --- a/Tone/component/channel/Panner3D.test.ts +++ b/Tone/component/channel/Panner3D.test.ts @@ -56,14 +56,14 @@ describe("Panner3D", () => { it("can get/set all of the other attributes", () => { const values = { - coneInnerAngle : 120, - coneOuterAngle : 280, - coneOuterGain : 0.3, - distanceModel : "exponential", - maxDistance : 10002, - panningModel : "HRTF", - refDistance : 0.3, - rolloffFactor : 3, + coneInnerAngle: 120, + coneOuterAngle: 280, + coneOuterGain: 0.3, + distanceModel: "exponential", + maxDistance: 10002, + panningModel: "HRTF", + refDistance: 0.3, + rolloffFactor: 3, }; const panner = new Panner3D(); for (const v in values) { diff --git a/Tone/component/channel/Panner3D.ts b/Tone/component/channel/Panner3D.ts index e501bbac..89afe79c 100644 --- a/Tone/component/channel/Panner3D.ts +++ b/Tone/component/channel/Panner3D.ts @@ -99,20 +99,20 @@ export class Panner3D extends ToneAudioNode { static getDefaults(): Panner3DOptions { return Object.assign(ToneAudioNode.getDefaults(), { - coneInnerAngle : 360, - coneOuterAngle : 360, - coneOuterGain : 0, - distanceModel : "inverse" as DistanceModelType, - maxDistance : 10000, - orientationX : 0, - orientationY : 0, - orientationZ : 0, - panningModel : "equalpower" as PanningModelType, - positionX : 0, - positionY : 0, - positionZ : 0, - refDistance : 1, - rolloffFactor : 1, + coneInnerAngle: 360, + coneOuterAngle: 360, + coneOuterGain: 0, + distanceModel: "inverse" as DistanceModelType, + maxDistance: 10000, + orientationX: 0, + orientationY: 0, + orientationZ: 0, + panningModel: "equalpower" as PanningModelType, + positionX: 0, + positionY: 0, + positionZ: 0, + refDistance: 1, + rolloffFactor: 1, }); } diff --git a/Tone/component/channel/Solo.test.ts b/Tone/component/channel/Solo.test.ts index 2c23c7d1..e804c66a 100644 --- a/Tone/component/channel/Solo.test.ts +++ b/Tone/component/channel/Solo.test.ts @@ -26,7 +26,7 @@ describe("Solo", () => { }); it("can be passed into the constructor with an object", () => { - const sol = new Solo({ solo : true }); + const sol = new Solo({ solo: true }); expect(sol.solo).to.be.true; sol.dispose(); }); diff --git a/Tone/component/channel/Split.test.ts b/Tone/component/channel/Split.test.ts index f5993813..6e924c0e 100644 --- a/Tone/component/channel/Split.test.ts +++ b/Tone/component/channel/Split.test.ts @@ -28,7 +28,7 @@ describe("Split", () => { }); it("passes the incoming signal through on the left side", () => { - return ConstantOutput(({destination}) => { + return ConstantOutput(({ destination }) => { const split = new Split(); const signal = StereoSignal(1, 2).connect(split); split.connect(destination, 0, 0); @@ -36,7 +36,7 @@ describe("Split", () => { }); it("passes the incoming signal through on the right side", () => { - return ConstantOutput(({destination}) => { + return ConstantOutput(({ destination }) => { const split = new Split(); const signal = StereoSignal(1, 2).connect(split); split.connect(destination, 1, 0); diff --git a/Tone/component/dynamics/Compressor.test.ts b/Tone/component/dynamics/Compressor.test.ts index 102d11a6..2206d33b 100644 --- a/Tone/component/dynamics/Compressor.test.ts +++ b/Tone/component/dynamics/Compressor.test.ts @@ -19,11 +19,11 @@ describe("Compressor", () => { it("can be get and set through object", () => { const comp = new Compressor(); const values = { - attack : 0.03, - knee : 20, - ratio : 12, - release : 0.5, - threshold : -30, + attack: 0.03, + knee: 20, + ratio: 12, + release: 0.5, + threshold: -30, }; comp.set(values); expect(comp.get()).to.have.keys(["ratio", "threshold", "release", "attack", "ratio"]); @@ -32,11 +32,11 @@ describe("Compressor", () => { it("can be get and constructed with an object", () => { const comp = new Compressor({ - attack : 0.03, - knee : 20, - ratio : 12, - release : 0.5, - threshold : -30, + attack: 0.03, + knee: 20, + ratio: 12, + release: 0.5, + threshold: -30, }); expect(comp.threshold.value).to.have.be.closeTo(-30, 1); comp.dispose(); @@ -52,11 +52,11 @@ describe("Compressor", () => { it("can get/set all interfaces", () => { const comp = new Compressor(); const values = { - attack : 0.03, - knee : 18, - ratio : 12, - release : 0.5, - threshold : -30, + attack: 0.03, + knee: 18, + ratio: 12, + release: 0.5, + threshold: -30, }; comp.ratio.value = values.ratio; comp.threshold.value = values.threshold; diff --git a/Tone/component/dynamics/Compressor.ts b/Tone/component/dynamics/Compressor.ts index 094275ee..c2e92e4b 100644 --- a/Tone/component/dynamics/Compressor.ts +++ b/Tone/component/dynamics/Compressor.ts @@ -71,9 +71,9 @@ export class Compressor extends ToneAudioNode { this.threshold = new Param({ context: this.context, - convert : false, - param : this._compressor.threshold, - units : "decibels", + convert: false, + param: this._compressor.threshold, + units: "decibels", value: options.threshold, }); @@ -93,17 +93,17 @@ export class Compressor extends ToneAudioNode { this.knee = new Param({ context: this.context, - convert : false, - param : this._compressor.knee, - units : "decibels", + convert: false, + param: this._compressor.knee, + units: "decibels", value: options.knee, }); this.ratio = new Param({ context: this.context, - convert : false, - param : this._compressor.ratio, - units : "positive", + convert: false, + param: this._compressor.ratio, + units: "positive", value: options.ratio, }); @@ -113,11 +113,11 @@ export class Compressor extends ToneAudioNode { static getDefaults(): CompressorOptions { return Object.assign(ToneAudioNode.getDefaults(), { - attack : 0.003, - knee : 30, - ratio : 12, - release : 0.25, - threshold : -24, + attack: 0.003, + knee: 30, + ratio: 12, + release: 0.25, + threshold: -24, }); } diff --git a/Tone/component/envelope/AmplitudeEnvelope.test.ts b/Tone/component/envelope/AmplitudeEnvelope.test.ts index f0764e13..a8b86c41 100644 --- a/Tone/component/envelope/AmplitudeEnvelope.test.ts +++ b/Tone/component/envelope/AmplitudeEnvelope.test.ts @@ -17,10 +17,10 @@ describe("AmplitudeEnvelope", () => { it("matches a file", () => { return CompareToFile(() => { const ampEnv = new AmplitudeEnvelope({ - attack : 0.1, - decay : 0.2, - release : 0.2, - sustain : 0.1, + attack: 0.1, + decay: 0.2, + release: 0.2, + sustain: 0.1, }).toDestination(); const osc = new Oscillator().start(0).connect(ampEnv); ampEnv.triggerAttack(0); @@ -31,10 +31,10 @@ describe("AmplitudeEnvelope", () => { it("matches a file with multiple retriggers", () => { return CompareToFile(() => { const ampEnv = new AmplitudeEnvelope({ - attack : 0.1, - decay : 0.2, - release : 0.2, - sustain : 0.1, + attack: 0.1, + decay: 0.2, + release: 0.2, + sustain: 0.1, }).toDestination(); const osc = new Oscillator().start(0).connect(ampEnv); ampEnv.triggerAttack(0); @@ -45,12 +45,12 @@ describe("AmplitudeEnvelope", () => { it("matches a file with ripple attack/release", () => { return CompareToFile(() => { const ampEnv = new AmplitudeEnvelope({ - attack : 0.5, - attackCurve : "ripple", - decay : 0.2, - release : 0.3, - releaseCurve : "ripple", - sustain : 0.1, + attack: 0.5, + attackCurve: "ripple", + decay: 0.2, + release: 0.3, + releaseCurve: "ripple", + sustain: 0.1, }).toDestination(); const osc = new Oscillator().start(0).connect(ampEnv); ampEnv.triggerAttack(0); diff --git a/Tone/component/envelope/Envelope.test.ts b/Tone/component/envelope/Envelope.test.ts index 8a77bc58..856122d1 100644 --- a/Tone/component/envelope/Envelope.test.ts +++ b/Tone/component/envelope/Envelope.test.ts @@ -19,10 +19,10 @@ describe("Envelope", () => { it("can get and set values an Objects", () => { const env = new Envelope(); const values = { - attack : 0, - decay : 0.5, - release : "4n", - sustain : 1, + attack: 0, + decay: 0.5, + release: "4n", + sustain: 1, }; env.set(values); expect(env.get()).to.contain.keys(Object.keys(values)); @@ -48,9 +48,9 @@ describe("Envelope", () => { it("can take parameters as both an object and as arguments", () => { const env0 = new Envelope({ - attack : 0, - decay : 0.5, - sustain : 1, + attack: 0, + decay: 0.5, + sustain: 1, }); expect(env0.attack).to.equal(0); expect(env0.decay).to.equal(0.5); @@ -122,10 +122,10 @@ describe("Envelope", () => { it("correctly schedules an exponential attack", () => { const e = { - attack : 0.01, - decay : 0.4, - release : 0.1, - sustain : 0.5, + attack: 0.01, + decay: 0.4, + release: 0.1, + sustain: 0.5, }; return Offline(() => { const env = new Envelope(e.attack, e.decay, e.sustain, e.release); @@ -147,10 +147,10 @@ describe("Envelope", () => { it("correctly schedules a linear release", () => { const e = { - attack : 0.01, - decay : 0.4, - release : 0.1, - sustain : 0.5, + attack: 0.01, + decay: 0.4, + release: 0.1, + sustain: 0.5, }; return Offline(() => { const env = new Envelope(e.attack, e.decay, e.sustain, e.release); @@ -167,10 +167,10 @@ describe("Envelope", () => { it("correctly schedules a linear decay", () => { const e = { - attack : 0.1, - decay : 0.5, - release : 0.1, - sustain : 0, + attack: 0.1, + decay: 0.5, + release: 0.1, + sustain: 0, }; return Offline(() => { const env = new Envelope(e.attack, e.decay, e.sustain, e.release); @@ -190,10 +190,10 @@ describe("Envelope", () => { it("correctly schedules an exponential decay", () => { const e = { - attack : 0.1, - decay : 0.5, - release : 0.1, - sustain : 0, + attack: 0.1, + decay: 0.5, + release: 0.1, + sustain: 0, }; return Offline(() => { const env = new Envelope(e.attack, e.decay, e.sustain, e.release); @@ -212,10 +212,10 @@ describe("Envelope", () => { it("can schedule a very short attack", () => { const e = { - attack : 0.001, - decay : 0.01, - release : 0.1, - sustain : 0.1, + attack: 0.001, + decay: 0.01, + release: 0.1, + sustain: 0.1, }; return Offline(() => { const env = new Envelope(e.attack, e.decay, e.sustain, e.release); @@ -249,10 +249,10 @@ describe("Envelope", () => { it("correctly schedule a release", () => { const e = { - attack : 0.001, - decay : 0.01, - release : 0.3, - sustain : 0.5, + attack: 0.001, + decay: 0.01, + release: 0.3, + sustain: 0.5, }; const releaseTime = 0.2; return Offline(() => { @@ -289,10 +289,10 @@ describe("Envelope", () => { it("is silent before and after triggering", () => { const e = { - attack : 0.001, - decay : 0.01, - release : 0.3, - sustain : 0.5, + attack: 0.001, + decay: 0.01, + release: 0.3, + sustain: 0.5, }; const releaseTime = 0.2; const attackTime = 0.1; @@ -310,9 +310,9 @@ describe("Envelope", () => { it("is silent after decay if sustain is 0", () => { const e = { - attack : 0.01, - decay : 0.04, - sustain : 0, + attack: 0.01, + decay: 0.04, + sustain: 0, }; const attackTime = 0.1; return Offline(() => { @@ -329,10 +329,10 @@ describe("Envelope", () => { it("correctly schedule an attack release envelope", () => { const e = { - attack : 0.08, - decay : 0.2, - release : 0.2, - sustain : 0.1, + attack: 0.08, + decay: 0.2, + release: 0.2, + sustain: 0.1, }; const releaseTime = 0.4; return Offline(() => { @@ -359,10 +359,10 @@ describe("Envelope", () => { it("can schedule a combined AttackRelease", () => { const e = { - attack : 0.1, - decay : 0.2, - release : 0.1, - sustain : 0.35, + attack: 0.1, + decay: 0.2, + release: 0.1, + sustain: 0.35, }; const releaseTime = 0.4; const duration = 0.4; @@ -390,10 +390,10 @@ describe("Envelope", () => { it("can schedule a combined AttackRelease with velocity", () => { const e = { - attack : 0.1, - decay : 0.2, - release : 0.1, - sustain : 0.35, + attack: 0.1, + decay: 0.2, + release: 0.1, + sustain: 0.35, }; const releaseTime = 0.4; const duration = 0.4; @@ -422,10 +422,10 @@ describe("Envelope", () => { it("can schedule multiple envelopes", () => { const e = { - attack : 0.1, - decay : 0.2, - release : 0.1, - sustain : 0.0, + attack: 0.1, + decay: 0.2, + release: 0.1, + sustain: 0.0, }; return Offline(() => { const env = new Envelope(e.attack, e.decay, e.sustain, e.release); @@ -605,12 +605,12 @@ describe("Envelope", () => { it("outputs a signal when the attack/release curves are set to 'bounce'", () => { return Offline(() => { const env = new Envelope({ - attack : 0.3, - attackCurve : "bounce", - decay : 0, - release : 0.3, - releaseCurve : "bounce", - sustain : 1, + attack: 0.3, + attackCurve: "bounce", + decay: 0, + release: 0.3, + releaseCurve: "bounce", + sustain: 1, }).toDestination(); env.triggerAttackRelease(0.3, 0.1); }, 0.8).then((buffer) => { @@ -623,12 +623,12 @@ describe("Envelope", () => { it("outputs a signal when the attack/release curves are set to 'ripple'", () => { return Offline(() => { const env = new Envelope({ - attack : 0.3, - attackCurve : "ripple", - decay : 0, - release : 0.3, - releaseCurve : "ripple", - sustain : 1, + attack: 0.3, + attackCurve: "ripple", + decay: 0, + release: 0.3, + releaseCurve: "ripple", + sustain: 1, }).toDestination(); env.triggerAttackRelease(0.3, 0.1); }, 0.8).then((buffer) => { @@ -641,12 +641,12 @@ describe("Envelope", () => { it("outputs a signal when the attack/release curves are set to 'sine'", () => { return Offline(() => { const env = new Envelope({ - attack : 0.3, - attackCurve : "sine", - decay : 0, - release : 0.3, - releaseCurve : "sine", - sustain : 1, + attack: 0.3, + attackCurve: "sine", + decay: 0, + release: 0.3, + releaseCurve: "sine", + sustain: 1, }).toDestination(); env.triggerAttackRelease(0.3, 0.1); }, 0.8).then((buffer) => { @@ -659,12 +659,12 @@ describe("Envelope", () => { it("outputs a signal when the attack/release curves are set to 'cosine'", () => { return Offline(() => { const env = new Envelope({ - attack : 0.3, - attackCurve : "cosine", - decay : 0, - release : 0.3, - releaseCurve : "cosine", - sustain : 1, + attack: 0.3, + attackCurve: "cosine", + decay: 0, + release: 0.3, + releaseCurve: "cosine", + sustain: 1, }).toDestination(); env.triggerAttackRelease(0.3, 0.1); }, 0.8).then((buffer) => { @@ -677,12 +677,12 @@ describe("Envelope", () => { it("outputs a signal when the attack/release curves are set to 'step'", () => { return Offline(() => { const env = new Envelope({ - attack : 0.3, - attackCurve : "step", - decay : 0, - release : 0.3, - releaseCurve : "step", - sustain : 1, + attack: 0.3, + attackCurve: "step", + decay: 0, + release: 0.3, + releaseCurve: "step", + sustain: 1, }).toDestination(); env.triggerAttackRelease(0.3, 0.1); }, 0.8).then((buffer) => { @@ -699,12 +699,12 @@ describe("Envelope", () => { it("outputs a signal when the attack/release curves are set to an array", () => { return Offline(() => { const env = new Envelope({ - attack : 0.3, - attackCurve : [0, 1, 0, 1], - decay : 0, - release : 0.3, - releaseCurve : [1, 0, 1, 0], - sustain : 1, + attack: 0.3, + attackCurve: [0, 1, 0, 1], + decay: 0, + release: 0.3, + releaseCurve: [1, 0, 1, 0], + sustain: 1, }).toDestination(); expect(env.attackCurve).to.deep.equal([0, 1, 0, 1]); env.triggerAttackRelease(0.3, 0.1); @@ -722,12 +722,12 @@ describe("Envelope", () => { it("can scale a velocity with a custom curve", () => { return Offline(() => { const env = new Envelope({ - attack : 0.3, - attackCurve : [0, 1, 0, 1], - decay : 0, - release : 0.3, - releaseCurve : [1, 0, 1, 0], - sustain : 1, + attack: 0.3, + attackCurve: [0, 1, 0, 1], + decay: 0, + release: 0.3, + releaseCurve: [1, 0, 1, 0], + sustain: 1, }).toDestination(); env.triggerAttackRelease(0.4, 0.1, 0.5); }, 0.8).then((buffer) => { @@ -740,12 +740,12 @@ describe("Envelope", () => { it("can retrigger partial envelope with custom type", () => { return Offline(() => { const env = new Envelope({ - attack : 0.5, - attackCurve : "cosine", - decay : 0, - release : 0.5, - releaseCurve : "sine", - sustain : 1, + attack: 0.5, + attackCurve: "cosine", + decay: 0, + release: 0.5, + releaseCurve: "sine", + sustain: 1, }).toDestination(); env.triggerAttack(0); env.triggerRelease(0.2); diff --git a/Tone/component/envelope/Envelope.ts b/Tone/component/envelope/Envelope.ts index 290c2aa7..a46f2cb1 100644 --- a/Tone/component/envelope/Envelope.ts +++ b/Tone/component/envelope/Envelope.ts @@ -181,13 +181,13 @@ export class Envelope extends ToneAudioNode { static getDefaults(): EnvelopeOptions { return Object.assign(ToneAudioNode.getDefaults(), { - attack : 0.01, - attackCurve : "linear" as EnvelopeCurveName, - decay : 0.1, - decayCurve : "exponential" as BasicEnvelopeCurve, - release : 1, - releaseCurve : "exponential" as EnvelopeCurveName, - sustain : 0.5, + attack: 0.01, + attackCurve: "linear" as EnvelopeCurveName, + decay: 0.1, + decayCurve: "exponential" as BasicEnvelopeCurve, + release: 1, + releaseCurve: "exponential" as EnvelopeCurveName, + sustain: 0.5, }); } @@ -455,7 +455,7 @@ interface EnvelopeCurveMap { step: EnvelopeCurveObject; } -type EnvelopeCurveName = keyof EnvelopeCurveMap; +type EnvelopeCurveName = keyof EnvelopeCurveMap; /** * Generate some complex envelope curves. @@ -528,27 +528,27 @@ const EnvelopeCurves: EnvelopeCurveMap = (() => { * attack and release curve arrays */ return { - bounce : { - In : invertCurve(bounceCurve), - Out : bounceCurve, + bounce: { + In: invertCurve(bounceCurve), + Out: bounceCurve, }, - cosine : { - In : cosineCurve, - Out : reverseCurve(cosineCurve), + cosine: { + In: cosineCurve, + Out: reverseCurve(cosineCurve), }, - exponential : "exponential" as "exponential", - linear : "linear" as "linear", - ripple : { - In : rippleCurve, - Out : invertCurve(rippleCurve), + exponential: "exponential" as "exponential", + linear: "linear" as "linear", + ripple: { + In: rippleCurve, + Out: invertCurve(rippleCurve), }, - sine : { - In : sineCurve, - Out : invertCurve(sineCurve), + sine: { + In: sineCurve, + Out: invertCurve(sineCurve), }, - step : { - In : stairsCurve, - Out : invertCurve(stairsCurve), + step: { + In: stairsCurve, + Out: invertCurve(stairsCurve), }, }; })(); diff --git a/Tone/component/filter/EQ3.test.ts b/Tone/component/filter/EQ3.test.ts index 3698d916..2f598e85 100644 --- a/Tone/component/filter/EQ3.test.ts +++ b/Tone/component/filter/EQ3.test.ts @@ -12,11 +12,11 @@ describe("EQ3", () => { it("can be constructed with an object", () => { const eq3 = new EQ3({ - high : -10, - highFrequency : 2700, - low : -8, - lowFrequency : 500, - mid : -9, + high: -10, + highFrequency: 2700, + low: -8, + lowFrequency: 500, + mid: -9, }); expect(eq3.low.value).to.be.closeTo(-8, 0.1); expect(eq3.mid.value).to.be.closeTo(-9, 0.1); @@ -29,8 +29,8 @@ describe("EQ3", () => { it("can be get and set through object", () => { const eq3 = new EQ3(); eq3.set({ - high : -4, - lowFrequency : 250, + high: -4, + lowFrequency: 250, }); expect(eq3.get().high).to.be.closeTo(-4, 0.1); expect(eq3.get().lowFrequency).to.be.closeTo(250, 0.01); @@ -40,8 +40,8 @@ describe("EQ3", () => { it("passes the incoming signal through", () => { return PassAudio(input => { const eq3 = new EQ3({ - high : 12, - low : -20, + high: 12, + low: -20, }).toDestination(); input.connect(eq3); }); diff --git a/Tone/component/filter/EQ3.ts b/Tone/component/filter/EQ3.ts index fa3430f3..669ff454 100644 --- a/Tone/component/filter/EQ3.ts +++ b/Tone/component/filter/EQ3.ts @@ -126,11 +126,11 @@ export class EQ3 extends ToneAudioNode { static getDefaults(): EQ3Options { return Object.assign(ToneAudioNode.getDefaults(), { - high : 0, - highFrequency : 2500, - low : 0, - lowFrequency : 400, - mid : 0, + high: 0, + highFrequency: 2500, + low: 0, + lowFrequency: 400, + mid: 0, }); } diff --git a/Tone/component/filter/Filter.test.ts b/Tone/component/filter/Filter.test.ts index fa8773f9..6c2e5bf5 100644 --- a/Tone/component/filter/Filter.test.ts +++ b/Tone/component/filter/Filter.test.ts @@ -21,8 +21,8 @@ describe("Filter", () => { it("can be constructed with an object", () => { const filter = new Filter({ - frequency : 340, - type : "bandpass", + frequency: 340, + type: "bandpass", }); expect(filter.frequency.value).to.be.closeTo(340, 0.001); expect(filter.type).to.equal("bandpass"); @@ -32,11 +32,11 @@ describe("Filter", () => { it("can set/get values as an Object", () => { const filter = new Filter(); const values = { - Q : 2, - frequency : 440, - gain : -6, - rolloff : -24, - type : "highpass" as BiquadFilterType, + Q: 2, + frequency: 440, + gain: -6, + rolloff: -24, + type: "highpass" as BiquadFilterType, }; filter.set(values); expect(filter.get()).to.include.keys(["type", "frequency", "rolloff", "Q", "gain"]); diff --git a/Tone/component/filter/PhaseShiftAllpass.test.ts b/Tone/component/filter/PhaseShiftAllpass.test.ts index 6a617a6e..aba279fe 100644 --- a/Tone/component/filter/PhaseShiftAllpass.test.ts +++ b/Tone/component/filter/PhaseShiftAllpass.test.ts @@ -26,13 +26,13 @@ describe("PhaseShiftAllpass", () => { }); }); - it ("generates correct values with the phase shifted channel", () => { + it("generates correct values with the phase shifted channel", () => { return CompareToFile((context) => { // create impulse with 5 samples offset const constantNode = context.createConstantSource(); constantNode.start(0); - const oneSampleDelay = context.createIIRFilter([ 0.0, 1.0 ], [ 1.0, 0.0 ]); - const fiveSampleDelay = context.createIIRFilter([ 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 ], [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]); + const oneSampleDelay = context.createIIRFilter([0.0, 1.0], [1.0, 0.0]); + const fiveSampleDelay = context.createIIRFilter([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 0.0, 0.0, 0.0]); const sub = new Subtract(); connect(constantNode, oneSampleDelay); @@ -47,13 +47,13 @@ describe("PhaseShiftAllpass", () => { }, "phaseShiftAllpass.wav", 0.001); }); - it ("generates correct values with the offset90 channel", () => { + it("generates correct values with the offset90 channel", () => { return CompareToFile((context) => { // create impulse with 5 samples offset const constantNode = context.createConstantSource(); constantNode.start(0); - const oneSampleDelay = context.createIIRFilter([ 0.0, 1.0 ], [ 1.0, 0.0 ]); - const fiveSampleDelay = context.createIIRFilter([ 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 ], [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]); + const oneSampleDelay = context.createIIRFilter([0.0, 1.0], [1.0, 0.0]); + const fiveSampleDelay = context.createIIRFilter([0.0, 0.0, 0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 0.0, 0.0, 0.0]); const sub = new Subtract(); connect(constantNode, oneSampleDelay); diff --git a/Tone/component/filter/PhaseShiftAllpass.ts b/Tone/component/filter/PhaseShiftAllpass.ts index 5dfae6b8..ced9f7f2 100644 --- a/Tone/component/filter/PhaseShiftAllpass.ts +++ b/Tone/component/filter/PhaseShiftAllpass.ts @@ -13,7 +13,7 @@ export class PhaseShiftAllpass extends ToneAudioNode { readonly name: string = "PhaseShiftAllpass"; - readonly input = new Gain({ context : this.context }); + readonly input = new Gain({ context: this.context }); /** * The Allpass filter in the first bank diff --git a/Tone/core/clock/TickSignal.test.ts b/Tone/core/clock/TickSignal.test.ts index b5c37e52..46deff47 100644 --- a/Tone/core/clock/TickSignal.test.ts +++ b/Tone/core/clock/TickSignal.test.ts @@ -260,7 +260,7 @@ describe("TickSignal", () => { }); context("BPM / PPQ", () => { - it ("can be set as PPQ", () => { + it("can be set as PPQ", () => { const tickSignal = new TickSignal({ multiplier: 10, units: "bpm", @@ -308,7 +308,7 @@ describe("TickSignal", () => { return Offline((context) => { const sched = new TickSignal({ units: "bpm", - value : 120, + value: 120, }).connect(context.destination); sched.linearRampTo(60, 1, 0); }, 1.01).then(buffer => { @@ -321,9 +321,9 @@ describe("TickSignal", () => { it("outputs a signal with bpm units and a multiplier", () => { return Offline((context) => { const sched = new TickSignal({ - multiplier : 10, + multiplier: 10, units: "bpm", - value : 60, + value: 60, }).connect(context.destination); sched.linearRampTo(120, 1, 0); }, 1.01).then(buffer => { diff --git a/Tone/core/clock/TickSignal.ts b/Tone/core/clock/TickSignal.ts index ce0e3ae6..aa08d483 100644 --- a/Tone/core/clock/TickSignal.ts +++ b/Tone/core/clock/TickSignal.ts @@ -42,7 +42,7 @@ export class TickSignal extends Signal { this.input = this._param = new TickParam({ context: this.context, convert: options.convert, - multiplier : options.multiplier, + multiplier: options.multiplier, param: this._constantSource.offset, units: options.units, value: options.value, diff --git a/Tone/core/clock/TickSource.ts b/Tone/core/clock/TickSource.ts index 1bb201eb..a3eaefc9 100644 --- a/Tone/core/clock/TickSource.ts +++ b/Tone/core/clock/TickSource.ts @@ -149,7 +149,7 @@ export class TickSource extends ToneWithContext extends ToneWithContext extends ToneWithContext { + this._timeout = setTimeout(() => { this._createTimeout(); this._callback(); }, this._updateInterval * 1000); diff --git a/Tone/core/clock/Transport.test.ts b/Tone/core/clock/Transport.test.ts index b4162e2c..44d7898d 100644 --- a/Tone/core/clock/Transport.test.ts +++ b/Tone/core/clock/Transport.test.ts @@ -12,7 +12,7 @@ describe("Transport", () => { it("can get and set bpm", () => { return Offline((context) => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.bpm.value = 125; expect(transport.bpm.value).to.be.closeTo(125, 0.001); transport.bpm.value = 120; @@ -22,7 +22,7 @@ describe("Transport", () => { it("can get and set timeSignature as both an array or number", () => { return Offline((context) => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.timeSignature = [6, 8]; expect(transport.timeSignature).to.equal(3); transport.timeSignature = 5; @@ -32,7 +32,7 @@ describe("Transport", () => { it("can get and set timeSignature as both an array or number", () => { return Offline((context) => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.timeSignature = [6, 8]; expect(transport.timeSignature).to.equal(3); transport.timeSignature = 5; @@ -42,11 +42,11 @@ describe("Transport", () => { }); - context("looping", () => { + context("looping", () => { - it("can get and set loop points", () => { + it("can get and set loop points", () => { return Offline((context) => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.loopStart = 0.2; transport.loopEnd = 0.4; expect(transport.loopStart).to.be.closeTo(0.2, 0.01); @@ -57,7 +57,7 @@ describe("Transport", () => { }); }); - it("can loop events scheduled on the transport", () => { + it("can loop events scheduled on the transport", () => { let invocations = 0; return Offline((context) => { const transport = new Transport({ context }); @@ -66,7 +66,7 @@ describe("Transport", () => { }, 0); transport.setLoopPoints(0, 0.1).start(0); transport.loop = true; - }, 0.41).then( () => { + }, 0.41).then(() => { expect(invocations).to.equal(5); }); }); @@ -74,7 +74,7 @@ describe("Transport", () => { it("jumps to the loopStart after the loopEnd point", () => { let looped = false; return Offline((context) => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.on("loop", () => { looped = true; }); @@ -93,14 +93,14 @@ describe("Transport", () => { it("returns 0 if the transports not started", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); expect(transport.nextSubdivision()).to.equal(0); }); }); it("can get the next subdivision of the transport", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.start(0); return time => { whenBetween(time, 0.05, 0.07, () => { @@ -122,7 +122,7 @@ describe("Transport", () => { it("can get and set pulses per quarter", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.PPQ = 96; expect(transport.PPQ).to.equal(96); }); @@ -130,7 +130,7 @@ describe("Transport", () => { it("schedules a quarter note at the same time with a different PPQ", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.PPQ = 1; const id = transport.schedule(time => { expect(time).to.be.closeTo(transport.toSeconds("4n"), 0.1); @@ -142,7 +142,7 @@ describe("Transport", () => { it("invokes the right number of ticks with a different PPQ", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.bpm.value = 120; const ppq = 20; transport.PPQ = ppq; @@ -162,7 +162,7 @@ describe("Transport", () => { it("can jump to a specific tick number", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.ticks = 200; expect(transport.ticks).to.equal(200); transport.start(0); @@ -178,7 +178,7 @@ describe("Transport", () => { it("can get the current position in BarsBeatsSixteenths", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); expect(transport.position).to.equal("0:0:0"); transport.start(0); return atTime(0.05, () => { @@ -189,7 +189,7 @@ describe("Transport", () => { it("can get the current position in seconds", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); expect(transport.seconds).to.equal(0); transport.start(0.05); return time => { @@ -202,7 +202,7 @@ describe("Transport", () => { it("can get the current position in seconds during a bpm ramp", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); expect(transport.seconds).to.equal(0); transport.start(0.05); transport.bpm.linearRampTo(60, 0.5, 0.5); @@ -216,7 +216,7 @@ describe("Transport", () => { it("can set the current position in seconds", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); expect(transport.seconds).to.equal(0); transport.seconds = 3; expect(transport.seconds).to.be.closeTo(3, 0.01); @@ -225,7 +225,7 @@ describe("Transport", () => { it("can set the current position in BarsBeatsSixteenths", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); expect(transport.position).to.equal("0:0:0"); transport.position = "3:0"; expect(transport.position).to.equal("3:0:0"); @@ -236,7 +236,7 @@ describe("Transport", () => { it("can get the progress of the loop", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.setLoopPoints(0, "1m").start(); transport.loop = true; expect(transport.progress).to.be.equal(0); @@ -253,7 +253,7 @@ describe("Transport", () => { it("can start, pause, and restart", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.start(0).pause(0.2).start(0.4); const pulse = new Signal(0).toDestination(); @@ -303,7 +303,7 @@ describe("Transport", () => { it("resets ticks on stop but not on pause", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.start(0).pause(0.1).stop(0.2); expect(transport.getTicksAtTime(0)).to.be.equal(Math.floor(transport.PPQ * 0)); expect(transport.getTicksAtTime(0.05)).to.be.equal(Math.floor(transport.PPQ * 0.1)); @@ -316,7 +316,7 @@ describe("Transport", () => { it("tracks ticks after start", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.bpm.value = 120; const ppq = transport.PPQ; transport.start(); @@ -331,7 +331,7 @@ describe("Transport", () => { it("can start with a tick offset", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.start(0, "200i"); return time => { @@ -344,7 +344,7 @@ describe("Transport", () => { it("can toggle the state of the transport", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.toggle(0); transport.toggle(0.2); @@ -363,7 +363,7 @@ describe("Transport", () => { it("tracks ticks correctly with a different PPQ and BPM", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.PPQ = 96; transport.bpm.value = 90; transport.start(); @@ -382,7 +382,7 @@ describe("Transport", () => { it("can schedule an event on the timeline", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const eventID = transport.schedule(() => { }, 0); expect(eventID).to.be.a("number"); }); @@ -391,7 +391,7 @@ describe("Transport", () => { it("scheduled event gets invoked with the time of the event", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const startTime = 0.1; transport.schedule(time => { expect(time).to.be.closeTo(startTime, 0.01); @@ -406,7 +406,7 @@ describe("Transport", () => { it("can schedule events with TransportTime", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const startTime = 0.1; const eighth = transport.toSeconds("8n"); transport.schedule(time => { @@ -421,7 +421,7 @@ describe("Transport", () => { it("can clear a scheduled event", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const eventID = transport.schedule(() => { throw new Error("should not call this function"); }, 0); @@ -432,7 +432,7 @@ describe("Transport", () => { it("can cancel the timeline of scheduled object", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.schedule(() => { throw new Error("should not call this"); }, 0); @@ -443,7 +443,7 @@ describe("Transport", () => { it("can cancel the timeline of scheduleOnce object", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.scheduleOnce(() => { throw new Error("should not call this"); }, 0); @@ -455,7 +455,7 @@ describe("Transport", () => { it("scheduled event anywhere along the timeline", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const startTime = transport.now(); transport.schedule(time => { expect(time).to.be.closeTo(startTime + 0.5, 0.001); @@ -470,7 +470,7 @@ describe("Transport", () => { it("can schedule multiple events and invoke them in the right order", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); let first = false; transport.schedule(() => { first = true; @@ -488,7 +488,7 @@ describe("Transport", () => { it("invokes the event again if the timeline is restarted", () => { let iterations = 0; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.schedule(() => { iterations++; }, 0.05); @@ -501,7 +501,7 @@ describe("Transport", () => { it("can add an event after the Transport is started", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.start(0); let wasScheduled = false; return time => { @@ -523,7 +523,7 @@ describe("Transport", () => { it("can schedule a repeated event", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const eventID = transport.scheduleRepeat(noOp, 1); expect(eventID).to.be.a("number"); }); @@ -532,7 +532,7 @@ describe("Transport", () => { it("scheduled event gets invoked with the time of the event", () => { let invoked = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const startTime = 0.1; const eventID = transport.scheduleRepeat(time => { expect(time).to.be.closeTo(startTime, 0.01); @@ -547,7 +547,7 @@ describe("Transport", () => { it("can cancel the timeline of scheduleRepeat", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.scheduleRepeat(() => { throw new Error("should not call this"); }, 0.01, 0); @@ -559,7 +559,7 @@ describe("Transport", () => { it("can schedule events with TransportTime", () => { let invoked = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const startTime = 0.1; const eighth = transport.toSeconds("8n"); transport.scheduleRepeat(time => { @@ -574,7 +574,7 @@ describe("Transport", () => { it("can clear a scheduled event", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const eventID = transport.scheduleRepeat(() => { throw new Error("should not call this function"); }, 1, 0); @@ -586,7 +586,7 @@ describe("Transport", () => { it("can be scheduled in the future", () => { let invoked = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const startTime = 0.1; const eventID = transport.scheduleRepeat(time => { transport.clear(eventID); @@ -602,7 +602,7 @@ describe("Transport", () => { it("repeats a repeat event", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.scheduleRepeat(() => { invocations++; }, 0.1, 0); @@ -615,7 +615,7 @@ describe("Transport", () => { it("repeats at the repeat interval", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); let repeatTime = -1; transport.scheduleRepeat(time => { if (repeatTime !== -1) { @@ -634,7 +634,7 @@ describe("Transport", () => { let first = false; let second = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const firstID = transport.scheduleRepeat(() => { first = true; transport.clear(firstID); @@ -654,7 +654,7 @@ describe("Transport", () => { it("repeats for the given interval", () => { let repeatCount = 0; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.scheduleRepeat(time => { repeatCount++; }, 0.1, 0, 0.5); @@ -667,7 +667,7 @@ describe("Transport", () => { it("can add an event after the Transport is started", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.start(0); let wasScheduled = false; const times = [0.15, 0.3]; @@ -688,7 +688,7 @@ describe("Transport", () => { it("can add an event to the past after the Transport is started", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.start(0); let wasScheduled = false; const times = [0.15, 0.25]; @@ -712,7 +712,7 @@ describe("Transport", () => { it("can schedule a single event on the timeline", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const eventID = transport.scheduleOnce(() => {}, 0); expect(eventID).to.be.a("number"); }); @@ -721,7 +721,7 @@ describe("Transport", () => { it("scheduled event gets invoked with the time of the event", () => { let invoked = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const startTime = 0.1; const eventID = transport.scheduleOnce(time => { invoked = true; @@ -737,7 +737,7 @@ describe("Transport", () => { it("can schedule events with TransportTime", () => { let invoked = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const startTime = 0.1; const eighth = transport.toSeconds("8n"); transport.scheduleOnce(time => { @@ -752,7 +752,7 @@ describe("Transport", () => { it("can clear a scheduled event", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const eventID = transport.scheduleOnce(() => { throw new Error("should not call this function"); }, 0); @@ -764,7 +764,7 @@ describe("Transport", () => { it("can be scheduled in the future", () => { let invoked = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const startTime = transport.now() + 0.1; const eventID = transport.scheduleOnce(time => { transport.clear(eventID); @@ -780,7 +780,7 @@ describe("Transport", () => { it("the event is removed after is is invoked", () => { let iterations = 0; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.scheduleOnce(() => { iterations++; }, 0); @@ -797,7 +797,7 @@ describe("Transport", () => { it("invokes start/stop/pause events", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.on("start", () => { invocations++; }); @@ -816,7 +816,7 @@ describe("Transport", () => { it("invokes start event with correct offset", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.on("start", (time, offset) => { expect(time).to.be.closeTo(0.2, 0.01); expect(offset).to.be.closeTo(0.5, 0.001); @@ -831,7 +831,7 @@ describe("Transport", () => { it("invokes the event just before the scheduled time", () => { let invoked = false; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.on("start", (time, offset) => { expect(time - transport.context.currentTime).to.be.closeTo(0, 0.01); expect(offset).to.equal(0); @@ -846,7 +846,7 @@ describe("Transport", () => { it("passes in the time argument to the events", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const now = transport.now(); transport.on("start", time => { invocations++; @@ -865,7 +865,7 @@ describe("Transport", () => { it("invokes the 'loop' method on loop", () => { let loops = 0; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const sixteenth = transport.toSeconds("16n"); transport.setLoopPoints(0, sixteenth); transport.loop = true; @@ -888,7 +888,7 @@ describe("Transport", () => { it("can get/set the swing subdivision", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.swingSubdivision = "8n"; expect(transport.swingSubdivision).to.equal("8n"); transport.swingSubdivision = "4n"; @@ -898,7 +898,7 @@ describe("Transport", () => { it("can get/set the swing amount", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.swing = 0.5; expect(transport.swing).to.equal(0.5); transport.swing = 0; @@ -909,7 +909,7 @@ describe("Transport", () => { it("can swing", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.swing = 1; transport.swingSubdivision = "8n"; const eightNote = transport.toSeconds("8n"); diff --git a/Tone/core/clock/Transport.ts b/Tone/core/clock/Transport.ts index 6d05f1b2..f170cbb6 100644 --- a/Tone/core/clock/Transport.ts +++ b/Tone/core/clock/Transport.ts @@ -163,9 +163,9 @@ export class Transport extends ToneWithContext implements Emit // CLOCK/TEMPO this._ppq = options.ppq; this._clock = new Clock({ - callback : this._processTick.bind(this), + callback: this._processTick.bind(this), context: this.context, - frequency : 0, + frequency: 0, units: "bpm", }); this._bindClockEvents(); @@ -241,7 +241,7 @@ export class Transport extends ToneWithContext implements Emit schedule(callback: TransportCallback, time: TransportTime | TransportTimeClass): number { const event = new TransportEvent(this, { callback, - time : new TransportTimeClass(this.context, time).toTicks(), + time: new TransportTimeClass(this.context, time).toTicks(), }); return this._addEvent(event, this._timeline); } @@ -267,9 +267,9 @@ export class Transport extends ToneWithContext implements Emit ): number { const event = new TransportRepeatEvent(this, { callback, - duration : new TimeClass(this.context, duration).toTicks(), + duration: new TimeClass(this.context, duration).toTicks(), interval: new TimeClass(this.context, interval).toTicks(), - time : new TransportTimeClass(this.context, startTime).toTicks(), + time: new TransportTimeClass(this.context, startTime).toTicks(), }); // kick it off if the Transport is started // @ts-ignore @@ -285,8 +285,8 @@ export class Transport extends ToneWithContext implements Emit scheduleOnce(callback: TransportCallback, time: TransportTime | TransportTimeClass): number { const event = new TransportEvent(this, { callback, - once : true, - time : new TransportTimeClass(this.context, time).toTicks(), + once: true, + time: new TransportTimeClass(this.context, time).toTicks(), }); return this._addEvent(event, this._timeline); } @@ -644,8 +644,8 @@ export class Transport extends ToneWithContext implements Emit // @ts-ignore ratioSignal.connect(signal._param); this._syncedSignals.push({ - initial : signal.value, - ratio : ratioSignal, + initial: signal.value, + ratio: ratioSignal, signal, }); signal.value = 0; diff --git a/Tone/core/clock/TransportEvent.test.ts b/Tone/core/clock/TransportEvent.test.ts index 6406335a..e0769308 100644 --- a/Tone/core/clock/TransportEvent.test.ts +++ b/Tone/core/clock/TransportEvent.test.ts @@ -7,7 +7,7 @@ describe("TransportEvent", () => { it("can be created and disposed", () => { return Offline((context) => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const event = new TransportEvent(transport, { time: 0, }); @@ -17,7 +17,7 @@ describe("TransportEvent", () => { it("has a unique id", () => { return Offline((context) => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const event = new TransportEvent(transport, { time: 0, }); @@ -29,7 +29,7 @@ describe("TransportEvent", () => { it("can invoke the callback", () => { let wasInvoked = false; return Offline((context) => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const event = new TransportEvent(transport, { callback: (time) => { expect(time).to.equal(100); diff --git a/Tone/core/clock/TransportRepeatEvent.test.ts b/Tone/core/clock/TransportRepeatEvent.test.ts index bd2a49f1..5c1305e4 100644 --- a/Tone/core/clock/TransportRepeatEvent.test.ts +++ b/Tone/core/clock/TransportRepeatEvent.test.ts @@ -7,7 +7,7 @@ describe("TransportRepeatEvent", () => { it("can be created and disposed", () => { return Offline((context) => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const event = new TransportRepeatEvent(transport, { duration: 100, interval: 4, @@ -19,7 +19,7 @@ describe("TransportRepeatEvent", () => { it("generates a unique event ID", () => { return Offline((context) => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const event = new TransportRepeatEvent(transport, { time: 0, }); @@ -30,7 +30,7 @@ describe("TransportRepeatEvent", () => { it("is removed from the Transport when disposed", () => { return Offline((context) => { - const transport = new Transport({context}); + const transport = new Transport({ context }); const event = new TransportRepeatEvent(transport, { time: 0, }); diff --git a/Tone/core/context/AudioContext.ts b/Tone/core/context/AudioContext.ts index b8ef9e0d..1ef4e10f 100644 --- a/Tone/core/context/AudioContext.ts +++ b/Tone/core/context/AudioContext.ts @@ -14,7 +14,7 @@ function createAudioContext(): AudioContext { * Create a new OfflineAudioContext */ export function createOfflineAudioContext(channels: number, length: number, sampleRate: number): OfflineAudioContext { - return new stdOfflineAudioContext(channels, length, sampleRate) as unknown as OfflineAudioContext; + return new stdOfflineAudioContext(channels, length, sampleRate) as unknown as OfflineAudioContext; } /** diff --git a/Tone/core/context/Context.test.ts b/Tone/core/context/Context.test.ts index f7c47d28..e32f1f96 100644 --- a/Tone/core/context/Context.test.ts +++ b/Tone/core/context/Context.test.ts @@ -12,9 +12,9 @@ import { connect } from "./ToneAudioNode"; describe("Context", () => { -// if (!Supports.AUDIO_CONTEXT_CLOSE_RESOLVES) { -// return; -// } + // if (!Supports.AUDIO_CONTEXT_CLOSE_RESOLVES) { + // return; + // } context("AudioContext", () => { @@ -63,7 +63,7 @@ describe("Context", () => { context("state", () => { - it ("can suspend and resume the state", async () => { + it("can suspend and resume the state", async () => { const ac = new AudioContext(); const context = new Context(ac); expect(context.rawContext).to.equal(ac); @@ -189,7 +189,7 @@ describe("Context", () => { it("is invoked in the offline context", () => { return Offline(context => { - const transport = new Transport({context}); + const transport = new Transport({ context }); transport.context.setTimeout(() => { expect(transport.now()).to.be.closeTo(0.01, 0.005); }, 0.01); @@ -271,59 +271,59 @@ describe("Context", () => { }); }); -// context("Tone", () => { + // context("Tone", () => { -// it("has a context", () => { -// expect(Tone.context).to.exist; -// expect(Tone.context).to.be.instanceOf(Context); -// }); + // it("has a context", () => { + // expect(Tone.context).to.exist; + // expect(Tone.context).to.be.instanceOf(Context); + // }); -// it("can set a new context", () => { -// const originalContext = Tone.context; -// Tone.context = new Context(); -// return Tone.context.dispose().then(() => { -// Tone.context = originalContext; -// }); -// }); + // it("can set a new context", () => { + // const originalContext = Tone.context; + // Tone.context = new Context(); + // return Tone.context.dispose().then(() => { + // Tone.context = originalContext; + // }); + // }); -// it("has a consistent context after offline rendering", () => { -// const initialContext = Tone.context; -// const initialTransport = Tone.Transport; -// return Offline(() => { }).then(() => { -// expect(Tone.context).to.equal(initialContext); -// expect(Tone.Transport).to.equal(initialTransport); -// }); -// }); + // it("has a consistent context after offline rendering", () => { + // const initialContext = Tone.context; + // const initialTransport = Tone.Transport; + // return Offline(() => { }).then(() => { + // expect(Tone.context).to.equal(initialContext); + // expect(Tone.Transport).to.equal(initialTransport); + // }); + // }); -// it("invokes the resume promise", () => { -// return Tone.context.resume(); -// }); + // it("invokes the resume promise", () => { + // return Tone.context.resume(); + // }); -// it("invokes init when a new context is set", done => { -// this.timeout(200); -// const initFn = function(context) { -// expect(Tone.context).to.equal(context); -// Context.off("init", initFn); -// done(); -// }; -// Context.on("init", initFn); -// Tone.context = new Context(); -// }); + // it("invokes init when a new context is set", done => { + // this.timeout(200); + // const initFn = function(context) { + // expect(Tone.context).to.equal(context); + // Context.off("init", initFn); + // done(); + // }; + // Context.on("init", initFn); + // Tone.context = new Context(); + // }); -// it("invokes close when a context is disposed", done => { -// this.timeout(200); -// const closeFn = function(context) { -// expect(context).to.be.instanceOf(Context); -// Context.off("close", closeFn); -// // set a new context -// Tone.context = new Context(); -// done(); -// }; -// Context.on("close", closeFn); -// Tone.context.dispose(); -// }); + // it("invokes close when a context is disposed", done => { + // this.timeout(200); + // const closeFn = function(context) { + // expect(context).to.be.instanceOf(Context); + // Context.off("close", closeFn); + // // set a new context + // Tone.context = new Context(); + // done(); + // }; + // Context.on("close", closeFn); + // Tone.context.dispose(); + // }); -// }); + // }); context("get/set", () => { diff --git a/Tone/core/context/Delay.ts b/Tone/core/context/Delay.ts index 5c28e2ee..ac4d4578 100644 --- a/Tone/core/context/Delay.ts +++ b/Tone/core/context/Delay.ts @@ -53,9 +53,9 @@ export class Delay extends ToneAudioNode { this.delayTime = new Param({ context: this.context, - param : this._delayNode.delayTime, - units : "time", - value : options.delayTime, + param: this._delayNode.delayTime, + units: "time", + value: options.delayTime, }); readOnly(this, "delayTime"); @@ -63,7 +63,7 @@ export class Delay extends ToneAudioNode { static getDefaults(): DelayOptions { return Object.assign(ToneAudioNode.getDefaults(), { - delayTime : 0, + delayTime: 0, maxDelay: 1, }); } diff --git a/Tone/core/context/Destination.ts b/Tone/core/context/Destination.ts index 7c33baad..d0d5fd69 100644 --- a/Tone/core/context/Destination.ts +++ b/Tone/core/context/Destination.ts @@ -32,7 +32,7 @@ export class Destination extends ToneAudioNode { readonly name: string = "Destination"; input: Volume = new Volume({ context: this.context }); - output: Gain = new Gain({ context : this.context }); + output: Gain = new Gain({ context: this.context }); /** * The volume of the master output. diff --git a/Tone/core/context/Gain.test.ts b/Tone/core/context/Gain.test.ts index db79cd2f..5de8b1d7 100644 --- a/Tone/core/context/Gain.test.ts +++ b/Tone/core/context/Gain.test.ts @@ -31,7 +31,7 @@ describe("Gain", () => { it("can be constructed with options object", () => { const gainNode = new Gain({ - gain : 0.4, + gain: 0.4, }); expect(gainNode.gain.value).to.be.closeTo(0.4, 0.001); gainNode.dispose(); diff --git a/Tone/core/context/Gain.ts b/Tone/core/context/Gain.ts index 0d3c7705..8578f7e1 100644 --- a/Tone/core/context/Gain.ts +++ b/Tone/core/context/Gain.ts @@ -45,20 +45,20 @@ export class Gain extends ToneAudioNode { const param = new Param({ context, param: context.createConstantSource().offset, - value : 1.1, + value: 1.1, }); expect(param.getValueAtTime(0)).to.equal(1.1); param.dispose(); }); }); - it ("requires a param in the constructor", () => { + it("requires a param in the constructor", () => { expect(() => { const param = new Param({ value: 1.1, @@ -97,7 +97,7 @@ describe("Param", () => { context, param: source.offset, units: "number", - value : 0, + value: 0, }); param.setValueCurveAtTime([0, 0.5, 0, 1, 1.5], 0.1, 0.8, 0.5); expect(param.getValueAtTime(0.91)).to.be.closeTo(0.75, 0.01); @@ -106,7 +106,7 @@ describe("Param", () => { matchesOutputCurve(param, testBuffer); }); - it ("a mixture of scheduling curves", async () => { + it("a mixture of scheduling curves", async () => { let param; const testBuffer = await Offline(context => { const source = context.createConstantSource(); @@ -115,7 +115,7 @@ describe("Param", () => { param = new Param({ context, param: source.offset, - value : 0.1, + value: 0.1, }); param.setValueAtTime(0, 0); param.setValueAtTime(1, 0.1); @@ -199,8 +199,8 @@ describe("Param", () => { const osc = audioContext.createOscillator(); const param = new Param({ context: audioContext, - param : osc.frequency, - units : "frequency", + param: osc.frequency, + units: "frequency", }); expect(() => { // @ts-ignore @@ -229,8 +229,8 @@ describe("Param", () => { const gain = audioContext.createGain(); const param = new Param({ context: audioContext, - param : gain.gain, - units : "bpm", + param: gain.gain, + units: "bpm", }); expect(param.units).to.equal("bpm"); param.dispose(); @@ -255,9 +255,9 @@ describe("Param", () => { source.start(0); const param = new Param({ context, - convert : false, + convert: false, param: source.offset, - units : "decibels", + units: "decibels", }); param.value = -10; expect(param.value).to.be.closeTo(-10, 0.01); @@ -268,7 +268,7 @@ describe("Param", () => { }); context("apply", () => { - it ("can apply a scheduled curve", () => { + it("can apply a scheduled curve", () => { let sig; return Offline(context => { const signal = new Signal(); @@ -293,7 +293,7 @@ describe("Param", () => { }); }); - it ("can apply a scheduled curve that starts with a setTargetAtTime", () => { + it("can apply a scheduled curve that starts with a setTargetAtTime", () => { let sig; return Offline(context => { const signal = new Signal(); @@ -313,7 +313,7 @@ describe("Param", () => { }); }); - it ("can apply a scheduled curve that starts with a setTargetAtTime and then schedules other things", () => { + it("can apply a scheduled curve that starts with a setTargetAtTime and then schedules other things", () => { let sig; return Offline(context => { const signal = new Signal(); @@ -380,7 +380,7 @@ describe("Param", () => { const source = audioContext.createConstantSource(); source.connect(audioContext.rawContext.destination); const param = new Param({ - context : audioContext, + context: audioContext, param: source.offset, units, }); @@ -408,21 +408,21 @@ describe("Param", () => { }); context("defaultValue", () => { - it ("has the right default value for default units", () => { + it("has the right default value for default units", () => { const source = audioContext.createConstantSource(); source.connect(audioContext.rawContext.destination); const param = new Param({ - context : audioContext, + context: audioContext, param: source.offset, }); expect(param.defaultValue).to.be.equal(1); }); - it ("has the right default value for default decibels", () => { + it("has the right default value for default decibels", () => { const source = audioContext.createConstantSource(); source.connect(audioContext.rawContext.destination); const param = new Param({ - context : audioContext, + context: audioContext, param: source.offset, units: "decibels", }); @@ -460,7 +460,7 @@ describe("Param", () => { } const allUnits: UnitName[] = ["number", "decibels", "normalRange", "audioRange", "gain", - "positive", "time", "frequency", "transportTime", "ticks", "bpm", "degrees", "samples", "hertz"]; + "positive", "time", "frequency", "transportTime", "ticks", "bpm", "degrees", "samples", "hertz"]; allUnits.forEach(unit => { if (unit === "decibels") { diff --git a/Tone/core/context/ToneAudioBuffer.test.ts b/Tone/core/context/ToneAudioBuffer.test.ts index 6ca23f89..720d44b3 100644 --- a/Tone/core/context/ToneAudioBuffer.test.ts +++ b/Tone/core/context/ToneAudioBuffer.test.ts @@ -61,7 +61,7 @@ describe("ToneAudioBuffer", () => { buffer.dispose(); done(); }, - reverse : true, + reverse: true, url: testFile, }); expect(buffer.reverse).to.equal(true); diff --git a/Tone/core/context/ToneAudioBuffers.test.ts b/Tone/core/context/ToneAudioBuffers.test.ts index 0f7bb0b7..ce54ee30 100644 --- a/Tone/core/context/ToneAudioBuffers.test.ts +++ b/Tone/core/context/ToneAudioBuffers.test.ts @@ -14,7 +14,7 @@ describe("ToneAudioBuffers", () => { it("loads a file from an object string", done => { const buffer = new ToneAudioBuffers({ - sine : testFile, + sine: testFile, }, () => { expect(buffer).to.be.instanceof(ToneAudioBuffers); buffer.dispose(); @@ -24,8 +24,8 @@ describe("ToneAudioBuffers", () => { it("can get a buffer loaded from an object", done => { const buffer = new ToneAudioBuffers({ - kick : testFile2, - sine : testFile, + kick: testFile2, + sine: testFile, }, () => { expect(buffer.get("kick")).to.be.instanceof(ToneAudioBuffer); buffer.dispose(); @@ -35,7 +35,7 @@ describe("ToneAudioBuffers", () => { it("throws an error when it tries to get an object that doesnt exist", done => { const buffer = new ToneAudioBuffers({ - sine : testFile, + sine: testFile, }, () => { expect(() => { buffer.get("nope"); @@ -47,8 +47,8 @@ describe("ToneAudioBuffers", () => { it("tests if it has a buffer", done => { const buffer = new ToneAudioBuffers({ - kick : testFile2, - sine : testFile, + kick: testFile2, + sine: testFile, }, () => { expect(buffer.has("kick")).to.be.true; expect(buffer.has("sine")).to.be.true; @@ -60,22 +60,22 @@ describe("ToneAudioBuffers", () => { it("can pass in buffers as object and options object in second arg", done => { const buffer = new ToneAudioBuffers({ - baseUrl : "./audio/", + baseUrl: "./audio/", onload(): void { expect(buffer.has("sine")).to.be.true; buffer.dispose(); done(); }, urls: { - sine : "sine.wav", + sine: "sine.wav", }, }); }); it("reports itself as loaded", done => { const buffer = new ToneAudioBuffers({ - kick : testFile2, - sine : testFile, + kick: testFile2, + sine: testFile, }, () => { expect(buffer.loaded).to.be.true; buffer.dispose(); @@ -86,7 +86,7 @@ describe("ToneAudioBuffers", () => { it("can load from a base url", done => { const buffer = new ToneAudioBuffers({ - hat : "hh.wav", + hat: "hh.wav", }, () => { expect(buffer.get("hat")).to.be.instanceof(ToneAudioBuffer); buffer.dispose(); diff --git a/Tone/core/context/ToneAudioNode.test.ts b/Tone/core/context/ToneAudioNode.test.ts index d37063e9..dcef685d 100644 --- a/Tone/core/context/ToneAudioNode.test.ts +++ b/Tone/core/context/ToneAudioNode.test.ts @@ -129,7 +129,7 @@ describe("ToneAudioNode", () => { }); context("connections", () => { - it("can connect with args", () => { + it("can connect with args", () => { const nodeA = new Gain(); const nodeB = new Gain(); nodeA.connect(nodeB, 0, 0); @@ -153,7 +153,7 @@ describe("ToneAudioNode", () => { nodeB.dispose(); }); - it("Tone nodes can disconnect from everything with no args", () => { + it("Tone nodes can disconnect from everything with no args", () => { const nodeA = new Gain(); const nodeB = new Gain(); nodeA.connect(nodeB); diff --git a/Tone/core/context/ToneAudioNode.ts b/Tone/core/context/ToneAudioNode.ts index 2ce7c7b5..80a1fcb4 100644 --- a/Tone/core/context/ToneAudioNode.ts +++ b/Tone/core/context/ToneAudioNode.ts @@ -5,7 +5,7 @@ import { isDefined } from "../util/TypeCheck"; import { Param } from "./Param"; import { ToneWithContext, ToneWithContextOptions } from "./ToneWithContext"; -export type InputNode = ToneAudioNode | AudioNode | Param | AudioParam; +export type InputNode = ToneAudioNode | AudioNode | Param | AudioParam; export type OutputNode = ToneAudioNode | AudioNode; interface ChannelProperties { @@ -24,7 +24,7 @@ export type ToneAudioNodeOptions = ToneWithContextOptions; * @category Core */ export abstract class ToneAudioNode -extends ToneWithContext { + extends ToneWithContext { /** * The name of the class diff --git a/Tone/core/type/Frequency.test.ts b/Tone/core/type/Frequency.test.ts index b3593170..cf37b478 100644 --- a/Tone/core/type/Frequency.test.ts +++ b/Tone/core/type/Frequency.test.ts @@ -79,7 +79,7 @@ describe("FrequencyClass", () => { }); it("can convert from Ticks", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Frequency(Ticks(transport.PPQ)).valueOf()).to.equal(2); expect(Frequency(Ticks("4n")).valueOf()).to.equal(2); }); @@ -95,7 +95,7 @@ describe("FrequencyClass", () => { }); it("evaluates notation", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { transport.bpm.value = 120; transport.timeSignature = 4; expect(Frequency("4n").valueOf()).to.equal(2); @@ -117,7 +117,7 @@ describe("FrequencyClass", () => { }); it("evalutes ticks", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Frequency(transport.PPQ, "i").valueOf()).to.equal(2); expect(Frequency(1, "i").valueOf()).to.equal(transport.PPQ * 2); }); diff --git a/Tone/core/type/Frequency.ts b/Tone/core/type/Frequency.ts index 57b8a318..16b7db1d 100644 --- a/Tone/core/type/Frequency.ts +++ b/Tone/core/type/Frequency.ts @@ -39,8 +39,8 @@ export class FrequencyClass extends TimeClass { return Object.assign({}, super._getExpressions(), { - midi : { - regexp : /^(\d+(?:\.\d+)?midi)/, + midi: { + regexp: /^(\d+(?:\.\d+)?midi)/, method(value): number { if (this.defaultUnits === "midi") { return value; @@ -49,8 +49,8 @@ export class FrequencyClass extends TimeClass extends TimeClass extends TimeClass { }); it("can convert from Ticks", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Midi(Ticks(transport.PPQ)).valueOf()).to.equal(-24); expect(Midi(Ticks("4n")).valueOf()).to.equal(-24); }); diff --git a/Tone/core/type/NoteUnits.ts b/Tone/core/type/NoteUnits.ts index c0f9dd91..f3215afa 100644 --- a/Tone/core/type/NoteUnits.ts +++ b/Tone/core/type/NoteUnits.ts @@ -28,9 +28,9 @@ export type Note = "Cbb-4" | "Cb-4" | "C-4" | "C#-4" | "Cx-4" | "Dbb-4" | "Db-4" * @category Unit */ export type MidiNote = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | - 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | - 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | - 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | - 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | - 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | - 121 | 122 | 123 | 124 | 125 | 126 | 127; +21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | +41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | +61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | +81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | +101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | +121 | 122 | 123 | 124 | 125 | 126 | 127; diff --git a/Tone/core/type/Ticks.test.ts b/Tone/core/type/Ticks.test.ts index 8d974a89..44126a08 100644 --- a/Tone/core/type/Ticks.test.ts +++ b/Tone/core/type/Ticks.test.ts @@ -23,7 +23,7 @@ describe("TicksClass", () => { }); it("can pass in a number in the constructor", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { const time = Ticks(1); expect(time).to.be.instanceOf(TicksClass); expect(time.valueOf()).to.equal(1); @@ -32,7 +32,7 @@ describe("TicksClass", () => { }); it("can pass in a string in the constructor", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { const time = Ticks("1"); expect(time).to.be.instanceOf(TicksClass); expect(time.valueOf()).to.equal(1); @@ -41,7 +41,7 @@ describe("TicksClass", () => { }); it("can pass in a value and a type", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Ticks(4, "m").valueOf()).to.equal(transport.PPQ * 16); }); }); @@ -72,7 +72,7 @@ describe("TicksClass", () => { }); it("can convert from Time", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Ticks(Time(2)).valueOf()).to.equal(transport.PPQ * 4); expect(Ticks(Time("4n")).valueOf()).to.equal(transport.PPQ); expect(Ticks(Time(4, "n")).valueOf()).to.equal(transport.PPQ); @@ -80,7 +80,7 @@ describe("TicksClass", () => { }); it("can convert from Frequency", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Ticks(Frequency(2)).valueOf()).to.equal(transport.PPQ); expect(Ticks(Frequency("4n")).valueOf()).to.equal(transport.PPQ); expect(Ticks(Frequency(4, "n")).valueOf()).to.equal(transport.PPQ); @@ -88,23 +88,23 @@ describe("TicksClass", () => { }); it("can convert from TransportTime", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Ticks(TransportTime(2)).valueOf()).to.equal(transport.PPQ * 4); expect(Ticks(TransportTime("4n")).valueOf()).to.equal(transport.PPQ); }); }); it("can convert from Ticks", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Ticks(Ticks(transport.PPQ)).valueOf()).to.equal(transport.PPQ); expect(Ticks(Ticks("4n")).valueOf()).to.equal(transport.PPQ); }); }); it("can convert from an Object", () => { - return Offline(({transport}) => { - expect(Ticks({ "4n" : 2 }).valueOf()).to.equal(transport.PPQ * 2); - expect(Ticks({ "1n" : 1, "8t" : 2 }).valueOf()).to.equal(transport.PPQ * 4 + transport.PPQ * (2 / 3)); + return Offline(({ transport }) => { + expect(Ticks({ "4n": 2 }).valueOf()).to.equal(transport.PPQ * 2); + expect(Ticks({ "1n": 1, "8t": 2 }).valueOf()).to.equal(transport.PPQ * 4 + transport.PPQ * (2 / 3)); }); }); }); @@ -112,7 +112,7 @@ describe("TicksClass", () => { context("Quantizes values", () => { it("can quantize values", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Ticks("4t").quantize("4n").valueOf()).to.be.closeTo(transport.PPQ, 0.01); }); }); @@ -149,7 +149,7 @@ describe("TicksClass", () => { context("Conversions", () => { it("converts time into notation", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { transport.bpm.value = 120; transport.timeSignature = 4; expect(Ticks("4n").toNotation()).to.equal("4n"); @@ -160,13 +160,13 @@ describe("TicksClass", () => { }); it("converts time into samples", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Ticks(transport.PPQ).toSamples()).to.equal(0.5 * getContext().sampleRate); }); }); it("converts time into frequency", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Ticks(transport.PPQ * 4).toFrequency()).to.equal(0.5); expect(Ticks("2n").toFrequency()).to.equal(1); }); @@ -179,7 +179,7 @@ describe("TicksClass", () => { }); it("converts time into BarsBeatsSixteenths", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { expect(Ticks("3:1:3").toBarsBeatsSixteenths()).to.equal("3:1:3"); expect(Ticks(4 * transport.PPQ).toBarsBeatsSixteenths()).to.equal("1:0:0"); }); diff --git a/Tone/core/type/Time.test.ts b/Tone/core/type/Time.test.ts index e5439588..049aeef3 100644 --- a/Tone/core/type/Time.test.ts +++ b/Tone/core/type/Time.test.ts @@ -68,7 +68,7 @@ describe("TimeClass", () => { }); it("can convert from Ticks", () => { - return Offline(({ transport}) => { + return Offline(({ transport }) => { expect(Time(Ticks(transport.PPQ)).valueOf()).to.equal(0.5); expect(Time(Ticks("4n")).valueOf()).to.equal(0.5); }); diff --git a/Tone/core/type/Time.ts b/Tone/core/type/Time.ts index 2fb94d28..9ba254cd 100644 --- a/Tone/core/type/Time.ts +++ b/Tone/core/type/Time.ts @@ -13,7 +13,7 @@ import { BarsBeatsSixteenths, MidiNote, Seconds, Subdivision, Ticks, Time } from * @category Unit */ export class TimeClass -extends TimeBaseClass { + extends TimeBaseClass { readonly name: string = "Time"; diff --git a/Tone/core/type/TimeBase.ts b/Tone/core/type/TimeBase.ts index 13a5d72b..2b2ac7e9 100644 --- a/Tone/core/type/TimeBase.ts +++ b/Tone/core/type/TimeBase.ts @@ -1,6 +1,6 @@ import { Context } from "../context/Context"; import { Tone } from "../Tone"; -import { isDefined, isObject , isString, isUndef } from "../util/TypeCheck"; +import { isDefined, isObject, isString, isUndef } from "../util/TypeCheck"; import { BPM, Hertz, MidiNote, Milliseconds, Samples, Seconds, Ticks, Time } from "./Units"; export type TimeValue = Time | TimeBaseClass; diff --git a/Tone/core/type/TransportTime.test.ts b/Tone/core/type/TransportTime.test.ts index f1ba0f5a..1d041e95 100644 --- a/Tone/core/type/TransportTime.test.ts +++ b/Tone/core/type/TransportTime.test.ts @@ -97,8 +97,8 @@ describe("TransportTimeClass", () => { it("can convert from an Object", () => { return Offline(() => { - expect(TransportTime({ "4n" : 2 }).valueOf()).to.equal(1); - expect(TransportTime({ "1n" : 1, "8t" : 2 }).valueOf()).to.be.closeTo(2.333, 0.01); + expect(TransportTime({ "4n": 2 }).valueOf()).to.equal(1); + expect(TransportTime({ "1n": 1, "8t": 2 }).valueOf()).to.be.closeTo(2.333, 0.01); }); }); }); diff --git a/Tone/core/type/Units.ts b/Tone/core/type/Units.ts index ff5f4cf7..3bc0123f 100644 --- a/Tone/core/type/Units.ts +++ b/Tone/core/type/Units.ts @@ -51,7 +51,7 @@ export type Positive = number; * @category Unit */ export type Subdivision = "1m" | "1n" | "2n" | "2t" | "4n" | "4t" | "8n" | "8t" | "16n" | "16t" | - "32n" | "32t" | "64n" | "64t" | "128n" | "128t" | "256n" | "256t" | "0"; +"32n" | "32t" | "64n" | "64t" | "128n" | "128t" | "256n" | "256t" | "0"; /** * A time object has a subdivision as the keys and a number as the values. @@ -140,7 +140,7 @@ export type Radians = number; * Bars:Beats:Sixteenths. * @category Unit */ -export type BarsBeatsSixteenths = string; +export type BarsBeatsSixteenths = string; /** * Sampling is the reduction of a continuous signal to a discrete signal. * Audio is typically sampled 44100 times per second. diff --git a/Tone/core/util/Defaults.ts b/Tone/core/util/Defaults.ts index 982a9824..ea45fbfd 100644 --- a/Tone/core/util/Defaults.ts +++ b/Tone/core/util/Defaults.ts @@ -20,7 +20,9 @@ export function deepMerge(target: T, source1: U): T & U; export function deepMerge(target: T, source1: U, source2: V): T & U & V; export function deepMerge(target: T, source1: U, source2: V, source3: W): T & U & V & W; export function deepMerge(target: any, ...sources: any[]): any { - if (!sources.length) { return target; } + if (!sources.length) { + return target; + } const source = sources.shift(); if (isObject(target) && isObject(source)) { @@ -28,7 +30,9 @@ export function deepMerge(target: any, ...sources: any[]): any { if (noCopy(key, source[key])) { target[key] = source[key]; } else if (isObject(source[key])) { - if (!target[key]) { Object.assign(target, { [key]: {} }); } + if (!target[key]) { + Object.assign(target, { [key]: {} }); + } deepMerge(target[key], source[key] as any); } else { Object.assign(target, { [key]: source[key] as any }); @@ -63,7 +67,7 @@ export function optionsFromArguments( const partOfDefaults = Object.keys(args[0]).some(key => Reflect.has(defaults, key)); if (!partOfDefaults) { // merge that key - deepMerge(opts, {[objKey] : args[0]}); + deepMerge(opts, { [objKey]: args[0] }); // remove the obj key from the keys keys.splice(keys.indexOf(objKey), 1); // shift the first argument off diff --git a/Tone/core/util/Draw.ts b/Tone/core/util/Draw.ts index b20d8f93..f904c56c 100644 --- a/Tone/core/util/Draw.ts +++ b/Tone/core/util/Draw.ts @@ -62,7 +62,7 @@ export class Draw extends ToneWithContext { schedule(callback: () => void, time: Time): this { this._events.add({ callback, - time : this.toSeconds(time), + time: this.toSeconds(time), }); // start the draw loop on the first event if (this._events.length === 1) { diff --git a/Tone/core/util/Emitter.ts b/Tone/core/util/Emitter.ts index e15e5f19..5ea0cdc2 100644 --- a/Tone/core/util/Emitter.ts +++ b/Tone/core/util/Emitter.ts @@ -47,7 +47,7 @@ export class Emitter extends Tone { * @param callback The callback to invoke when the event is emitted */ once(event: EventType, callback: (...args: any[]) => void): this { - const boundCallback = (...args: any[]) => { + const boundCallback = (...args: any[]) => { // invoke the callback callback(...args); // remove the event diff --git a/Tone/core/util/Interface.ts b/Tone/core/util/Interface.ts index 42cf5810..15231c1e 100644 --- a/Tone/core/util/Interface.ts +++ b/Tone/core/util/Interface.ts @@ -40,6 +40,6 @@ export const noOp: (...args: any[]) => any = () => { export type RecursivePartial = { [P in keyof T]?: T[P] extends Array ? Array> : - T[P] extends object ? RecursivePartial : - T[P]; + T[P] extends object ? RecursivePartial : + T[P]; }; diff --git a/Tone/source/buffer/Player.test.ts b/Tone/source/buffer/Player.test.ts index 90738f07..6c40fde9 100644 --- a/Tone/source/buffer/Player.test.ts +++ b/Tone/source/buffer/Player.test.ts @@ -61,7 +61,7 @@ describe("Player", () => { context("onstop", () => { - it ("invokes the onstop method when the player is explicitly stopped", () => { + it("invokes the onstop method when the player is explicitly stopped", () => { let wasInvoked = false; return Offline(() => { const player = new Player({ @@ -76,7 +76,7 @@ describe("Player", () => { }); }); - it ("invokes the onstop method when the file is naturally over", () => { + it("invokes the onstop method when the file is naturally over", () => { let wasInvoked = false; return Offline(() => { const player = new Player(buffer); @@ -90,7 +90,7 @@ describe("Player", () => { }); }); - it ("invokes the onstop method on restart", () => { + it("invokes the onstop method on restart", () => { let wasInvoked = 0; return Offline(() => { const player = new Player(buffer); @@ -123,22 +123,22 @@ describe("Player", () => { it("can be created with an options object", () => { const player = new Player({ - loop : true, - url : "./audio/sine.wav", + loop: true, + url: "./audio/sine.wav", }); player.dispose(); }); it("can autostart after loading", (done) => { const player = new Player({ - autostart : true, + autostart: true, onload(): void { setTimeout(() => { expect(player.state).to.be.equal("started"); done(); }, 10); }, - url : "./audio/sine.wav", + url: "./audio/sine.wav", }); }); @@ -146,7 +146,7 @@ describe("Player", () => { context("Reverse", () => { - it ("can get/set reverse", () => { + it("can get/set reverse", () => { const player = new Player(); player.reverse = true; expect(player.reverse).to.equal(true); @@ -159,8 +159,8 @@ describe("Player", () => { const lastSample = audioBuffer[audioBuffer.length - 1 - jump]; return Offline(() => { const player = new Player({ - reverse : true, - url : buffer.get(), + reverse: true, + url: buffer.get(), }).toDestination(); player.start(0); }).then((buff) => { @@ -298,7 +298,7 @@ describe("Player", () => { }); context("PlaybackRate", () => { - it ("reports itself as completed after the stop time when playbackRate = 1", () => { + it("reports itself as completed after the stop time when playbackRate = 1", () => { return Offline(() => { const player = new Player(buffer); player.start(0); @@ -308,7 +308,7 @@ describe("Player", () => { }, buffer.duration * 1.1); }); - it ("no longer reports itself as stopped when playback rate is changed to < 1", () => { + it("no longer reports itself as stopped when playback rate is changed to < 1", () => { return Offline(() => { const player = new Player(buffer); player.start(0); @@ -319,7 +319,7 @@ describe("Player", () => { }, buffer.duration * 1.1); }); - it ("when end is explicitly scheduled, it does not matter if playbackRate is changed", () => { + it("when end is explicitly scheduled, it does not matter if playbackRate is changed", () => { return Offline(() => { const player = new Player(buffer); player.start(0).stop(0.1); @@ -337,10 +337,10 @@ describe("Player", () => { const player = new Player(); expect(player.loop).to.be.false; player.set({ - fadeIn : 0.1, - fadeOut : 0.2, - loop : true, - loopStart : 0.4, + fadeIn: 0.1, + fadeOut: 0.2, + loop: true, + loopStart: 0.4, }); expect(player.loop).to.be.true; expect(player.loopStart).to.equal(0.4); @@ -354,10 +354,10 @@ describe("Player", () => { expect(player.loop).to.be.false; player.start(); player.set({ - loop : true, - loopEnd : 0.3, - loopStart : 0.2, - playbackRate : 0.9, + loop: true, + loopEnd: 0.3, + loopStart: 0.2, + playbackRate: 0.9, }); expect(player.loop).to.be.true; expect(player.loopStart).to.equal(0.2); @@ -368,11 +368,11 @@ describe("Player", () => { it("can get an options object", () => { const player = new Player({ - loop : true, - loopEnd : 0.3, - loopStart : 0.2, - reverse : true, - url : "./audio/sine.wav", + loop: true, + loopEnd: 0.3, + loopStart: 0.2, + reverse: true, + url: "./audio/sine.wav", }); expect(player.get().loopStart).to.equal(0.2); expect(player.get().loopEnd).to.equal(0.3); @@ -536,7 +536,7 @@ describe("Player", () => { }); it("plays synced to the Transport", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { const player = new Player(buffer).sync().start(0).toDestination(); transport.start(0); }, 0.05).then((buff) => { @@ -546,7 +546,7 @@ describe("Player", () => { it("offsets correctly when started by the Transport", () => { const testSample = buffer.toArray(0)[Math.floor(0.13125 * getContext().sampleRate)]; - return Offline(({transport}) => { + return Offline(({ transport }) => { const player = new Player(buffer).sync().start(0, 0.1).toDestination(); transport.start(0, 0.03125); }, 0.05).then((buff) => { @@ -555,7 +555,7 @@ describe("Player", () => { }); it("starts at the correct position when Transport is offset and playbackRate is not 1", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { // make a ramp between 0-1 const ramp = new Float32Array(Math.floor(getContext().sampleRate * 0.3)); for (let i = 0; i < ramp.length; i++) { @@ -573,7 +573,7 @@ describe("Player", () => { }); it("starts with an offset when synced and started after Transport is running", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { const ramp = new Float32Array(Math.floor(getContext().sampleRate * 0.3)); for (let i = 0; i < ramp.length; i++) { ramp[i] = (i / (ramp.length)) * 0.3; @@ -593,7 +593,7 @@ describe("Player", () => { }); it("can pass in an offset when synced and started after Transport is running", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { const ramp = new Float32Array(Math.floor(getContext().sampleRate * 0.3)); for (let i = 0; i < ramp.length; i++) { ramp[i] = (i / (ramp.length)) * 0.3; @@ -623,7 +623,7 @@ describe("Player", () => { onesArray[index] = 1; }); const onesBuffer = ToneAudioBuffer.fromArray(onesArray); - const player = new Player({ url : onesBuffer, fadeOut : 0.1, fadeIn : 0.1 }).toDestination(); + const player = new Player({ url: onesBuffer, fadeOut: 0.1, fadeIn: 0.1 }).toDestination(); player.start(0); }, 0.6).then((buff) => { expect(buff.getRmsAtTime(0)).to.be.closeTo(0, 0.1); diff --git a/Tone/source/buffer/Player.ts b/Tone/source/buffer/Player.ts index 946fe2ec..3e041cc9 100644 --- a/Tone/source/buffer/Player.ts +++ b/Tone/source/buffer/Player.ts @@ -109,15 +109,15 @@ export class Player extends Source { static getDefaults(): PlayerOptions { return Object.assign(Source.getDefaults(), { - autostart : false, - fadeIn : 0, - fadeOut : 0, - loop : false, - loopEnd : 0, - loopStart : 0, - onload : noOp, - playbackRate : 1, - reverse : false, + autostart: false, + fadeIn: 0, + fadeOut: 0, + loop: false, + loopEnd: 0, + loopStart: 0, + onload: noOp, + playbackRate: 1, + reverse: false, }); } @@ -209,15 +209,15 @@ export class Player extends Source { // make the source const source = new ToneBufferSource({ - buffer : this._buffer, + buffer: this._buffer, context: this.context, - fadeIn : this.fadeIn, - fadeOut : this.fadeOut, - loop : this._loop, - loopEnd : this._loopEnd, - loopStart : this._loopStart, - onended : this._onSourceEnd.bind(this), - playbackRate : this._playbackRate, + fadeIn: this.fadeIn, + fadeOut: this.fadeOut, + loop: this._loop, + loopEnd: this._loopEnd, + loopStart: this._loopStart, + onended: this._onSourceEnd.bind(this), + playbackRate: this._playbackRate, }).connect(this.output); // set the looping properties diff --git a/Tone/source/buffer/Players.test.ts b/Tone/source/buffer/Players.test.ts index 385a3223..ef231fbf 100644 --- a/Tone/source/buffer/Players.test.ts +++ b/Tone/source/buffer/Players.test.ts @@ -16,13 +16,13 @@ describe("Players", () => { return buffer.load("./audio/sine.wav"); }); - BasicTests(Players, { test : buffer }); + BasicTests(Players, { test: buffer }); context("Constructor", () => { it("can be constructed with an object containing a ToneAudioBuffer", () => { const players = new Players({ - test : buffer, + test: buffer, }); expect(players.player("test").buffer.get()).to.equal(buffer.get()); players.dispose(); @@ -30,7 +30,7 @@ describe("Players", () => { it("can be constructed with an AudioBuffer", () => { const players = new Players({ - test : buffer.get() as AudioBuffer, + test: buffer.get() as AudioBuffer, }); expect(players.player("test").buffer.get()).to.equal(buffer.get()); players.dispose(); @@ -38,8 +38,8 @@ describe("Players", () => { it("can be constructed with a url", (done) => { const players = new Players({ - test0 : "./audio/sine.wav", - test1 : "./audio/sine.wav", + test0: "./audio/sine.wav", + test1: "./audio/sine.wav", }, () => { expect(players.player("test0")).to.be.instanceOf(Player); expect(players.player("test0").buffer.loaded).to.be.true; @@ -53,24 +53,24 @@ describe("Players", () => { it("can pass in additional args in the second parameters", (done) => { const players = new Players({ - test : "./audio/sine.wav", + test: "./audio/sine.wav", }, { - onload : () => { + onload: () => { expect(players.player("test").buffer.loaded).to.be.true; expect(players.volume.value).to.be.closeTo(-12, 0.1); players.dispose(); done(); }, - volume : -12, + volume: -12, }); }); it("can get and set fadeIn/Out", () => { const players = new Players({ - test : "./audio/sine.wav", + test: "./audio/sine.wav", }, { - fadeIn : 0.1, - fadeOut : 0.2, + fadeIn: 0.1, + fadeOut: 0.2, }); expect(players.fadeIn).to.equal(0.1); expect(players.fadeOut).to.equal(0.2); @@ -88,7 +88,7 @@ describe("Players", () => { it("says it 'has' a sample", () => { const players = new Players({ - test : buffer, + test: buffer, }); expect(players.has("test")).to.be.true; expect(players.has("nope")).to.be.false; @@ -97,7 +97,7 @@ describe("Players", () => { it("can get a sample", () => { const players = new Players({ - test : buffer, + test: buffer, }); expect(players.player("test")).to.be.instanceOf(Player); players.dispose(); @@ -105,7 +105,7 @@ describe("Players", () => { it("throws an error if it tries to get a sample which is not there", () => { const players = new Players({ - test : buffer, + test: buffer, }); expect(() => { players.player("nope"); @@ -148,7 +148,7 @@ describe("Players", () => { it("makes a sound", () => { return OutputAudio(() => { const players = new Players({ - test : buffer, + test: buffer, }).toDestination(); players.player("test").start(0); }); @@ -157,7 +157,7 @@ describe("Players", () => { it("can be muted", () => { return Offline(() => { const players = new Players({ - test : buffer, + test: buffer, }).toDestination(); players.player("test").start(0); players.mute = true; @@ -170,7 +170,7 @@ describe("Players", () => { it("be scheduled to start in the future", () => { return Offline(() => { const players = new Players({ - test : buffer, + test: buffer, }).toDestination(); players.player("test").start(0.1); }, 0.3).then((buffer2) => { @@ -185,7 +185,7 @@ describe("Players", () => { it("be scheduled to stop in the future", () => { return Offline(() => { const players = new Players({ - test : buffer, + test: buffer, }).toDestination(); players.player("test").start(0).stop(0.2); }, 0.3).then((buffer2) => { @@ -200,8 +200,8 @@ describe("Players", () => { it("if any of the players are playing, reports state as 'started'", () => { return Offline(() => { const players = new Players({ - test0 : buffer, - test1 : buffer, + test0: buffer, + test1: buffer, }).toDestination(); players.player("test0").start(0).stop(0.05); players.player("test1").start(0).stop(0.1); @@ -218,8 +218,8 @@ describe("Players", () => { it("can start multiple samples", () => { return OutputAudio(() => { const players = new Players({ - test0 : buffer, - test1 : buffer, + test0: buffer, + test1: buffer, }).toDestination(); players.player("test0").start(0).stop(0.01); players.player("test1").start(0); @@ -229,8 +229,8 @@ describe("Players", () => { it("can stop all of the samples in the future", () => { return Offline(() => { const players = new Players({ - test0 : buffer, - test1 : buffer, + test0: buffer, + test1: buffer, }).toDestination(); players.player("test0").start(0); players.player("test1").start(0); @@ -252,10 +252,10 @@ describe("Players", () => { }); const onesBuffer = ToneAudioBuffer.fromArray(onesArray); const players = new Players({ - test : onesBuffer, + test: onesBuffer, }, { - fadeIn : 0.1, - fadeOut : 0.1, + fadeIn: 0.1, + fadeOut: 0.1, }).toDestination(); players.player("test").start(0); }, 0.6).then((buffer2) => { diff --git a/Tone/source/buffer/ToneBufferSource.test.ts b/Tone/source/buffer/ToneBufferSource.test.ts index 6539e910..36276cdb 100644 --- a/Tone/source/buffer/ToneBufferSource.test.ts +++ b/Tone/source/buffer/ToneBufferSource.test.ts @@ -54,10 +54,10 @@ describe("ToneBufferSource", () => { it("can be created with an options object", () => { const source = new ToneBufferSource({ buffer, - loop : true, - loopEnd : 0.2, - loopStart : 0.1, - playbackRate : 0.5, + loop: true, + loopEnd: 0.2, + loopStart: 0.1, + playbackRate: 0.5, }); expect(source.loop).to.equal(true); expect(source.loopEnd).to.equal(0.2); @@ -204,9 +204,9 @@ describe("ToneBufferSource", () => { const player = new ToneBufferSource(); expect(player.loop).is.equal(false); player.set({ - loop : true, - loopEnd : 0.5, - loopStart : 0.4, + loop: true, + loopEnd: 0.5, + loopStart: 0.4, }); expect(player.loop).is.equal(true); expect(player.loopStart).to.equal(0.4); diff --git a/Tone/source/buffer/ToneBufferSource.ts b/Tone/source/buffer/ToneBufferSource.ts index fcf4af20..6db77b8d 100644 --- a/Tone/source/buffer/ToneBufferSource.ts +++ b/Tone/source/buffer/ToneBufferSource.ts @@ -69,9 +69,9 @@ export class ToneBufferSource extends OneShotSource { */ this.playbackRate = new Param({ context: this.context, - param : this._source.playbackRate, - units : "positive", - value : options.playbackRate, + param: this._source.playbackRate, + units: "positive", + value: options.playbackRate, }); // set some values initially @@ -87,10 +87,10 @@ export class ToneBufferSource extends OneShotSource { return Object.assign(OneShotSource.getDefaults(), { buffer: new ToneAudioBuffer(), loop: false, - loopEnd : 0, - loopStart : 0, + loopEnd: 0, + loopStart: 0, onload: noOp, - playbackRate : 1, + playbackRate: 1, }); } diff --git a/Tone/source/oscillator/AMOscillator.test.ts b/Tone/source/oscillator/AMOscillator.test.ts index ce932f64..d9329fa7 100644 --- a/Tone/source/oscillator/AMOscillator.test.ts +++ b/Tone/source/oscillator/AMOscillator.test.ts @@ -24,9 +24,9 @@ describe("AMOscillator", () => { it("can pass in parameters in the constructor", () => { const amOsc = new AMOscillator({ - harmonicity : 3, - modulationType : "square3", - type : "triangle2", + harmonicity: 3, + modulationType: "square3", + type: "triangle2", }); expect(amOsc.type).to.equal("triangle2"); expect(amOsc.harmonicity.value).to.be.closeTo(3, 0.001); diff --git a/Tone/source/oscillator/AMOscillator.ts b/Tone/source/oscillator/AMOscillator.ts index 1a6ce1e8..34f0cabe 100644 --- a/Tone/source/oscillator/AMOscillator.ts +++ b/Tone/source/oscillator/AMOscillator.ts @@ -89,8 +89,8 @@ export class AMOscillator extends Source implements ToneOsc super(optionsFromArguments(AMOscillator.getDefaults(), arguments, ["frequency", "type", "modulationType"])); const options = optionsFromArguments(AMOscillator.getDefaults(), arguments, ["frequency", "type", "modulationType"]); - this._carrier = new Oscillator({ - context : this.context, + this._carrier = new Oscillator({ + context: this.context, detune: options.detune, frequency: options.frequency, onstop: () => this.onstop(this), @@ -101,7 +101,7 @@ export class AMOscillator extends Source implements ToneOsc this.detune = this._carrier.detune; this._modulator = new Oscillator({ - context : this.context, + context: this.context, phase: options.phase, type: options.modulationType, } as OscillatorOptions); diff --git a/Tone/source/oscillator/FMOscillator.test.ts b/Tone/source/oscillator/FMOscillator.test.ts index e60a6a82..3c4cd208 100644 --- a/Tone/source/oscillator/FMOscillator.test.ts +++ b/Tone/source/oscillator/FMOscillator.test.ts @@ -24,9 +24,9 @@ describe("FMOscillator", () => { it("can pass in parameters in the constructor", () => { const fmOsc = new FMOscillator({ - harmonicity : 3, - modulationType : "square3", - type : "triangle2", + harmonicity: 3, + modulationType: "square3", + type: "triangle2", }); expect(fmOsc.type).to.equal("triangle2"); expect(fmOsc.harmonicity.value).to.be.closeTo(3, 0.001); @@ -43,7 +43,7 @@ describe("FMOscillator", () => { it("can set the modulationIndex", () => { const fmOsc = new FMOscillator({ - modulationIndex : 3, + modulationIndex: 3, }); expect(fmOsc.modulationIndex.value).to.be.closeTo(3, 0.001); fmOsc.modulationIndex.value = 0.2; diff --git a/Tone/source/oscillator/FMOscillator.ts b/Tone/source/oscillator/FMOscillator.ts index 7b391550..d10f68f2 100644 --- a/Tone/source/oscillator/FMOscillator.ts +++ b/Tone/source/oscillator/FMOscillator.ts @@ -90,7 +90,7 @@ export class FMOscillator extends Source implements ToneOsc const options = optionsFromArguments(FMOscillator.getDefaults(), arguments, ["frequency", "type", "modulationType"]); this._carrier = new Oscillator({ - context : this.context, + context: this.context, detune: options.detune, frequency: 0, onstop: () => this.onstop(this), @@ -107,7 +107,7 @@ export class FMOscillator extends Source implements ToneOsc }); this._modulator = new Oscillator({ - context : this.context, + context: this.context, phase: options.phase, type: options.modulationType, } as OscillatorOptions); diff --git a/Tone/source/oscillator/FatOscillator.test.ts b/Tone/source/oscillator/FatOscillator.test.ts index 58f67fc3..8aa7c0cc 100644 --- a/Tone/source/oscillator/FatOscillator.test.ts +++ b/Tone/source/oscillator/FatOscillator.test.ts @@ -24,8 +24,8 @@ describe("FatOscillator", () => { it("can pass in parameters in the constructor", () => { const fatOsc = new FatOscillator({ - count : 4, - spread : 25, + count: 4, + spread: 25, }); expect(fatOsc.spread).to.be.equal(25); expect(fatOsc.count).to.equal(4); @@ -34,7 +34,7 @@ describe("FatOscillator", () => { it("can set the partials and the count", () => { const fatOsc = new FatOscillator({ - count : 3, + count: 3, }); fatOsc.partials = [0, 2, 3, 4]; expect(fatOsc.partials).to.deep.equal([0, 2, 3, 4]); @@ -47,7 +47,7 @@ describe("FatOscillator", () => { it("can set the count after starting", () => { const fatOsc = new FatOscillator({ - count : 3, + count: 3, }); fatOsc.start(); fatOsc.count = 4; @@ -57,8 +57,8 @@ describe("FatOscillator", () => { it("correctly distributes the detune spread", () => { const fatOsc = new FatOscillator({ - count : 2, - spread : 20, + count: 2, + spread: 20, }); // @ts-ignore expect(fatOsc._oscillators.length).to.equal(2); diff --git a/Tone/source/oscillator/FatOscillator.ts b/Tone/source/oscillator/FatOscillator.ts index d45a133f..9aeb2306 100644 --- a/Tone/source/oscillator/FatOscillator.ts +++ b/Tone/source/oscillator/FatOscillator.ts @@ -95,9 +95,9 @@ export class FatOscillator extends Source implements ToneO static getDefaults(): FatOscillatorOptions { return Object.assign(Oscillator.getDefaults(), { - count : 3, - spread : 20, - type : "sawtooth", + count: 3, + spread: 20, + type: "sawtooth", }); } @@ -180,7 +180,7 @@ export class FatOscillator extends Source implements ToneO this._oscillators = []; for (let i = 0; i < count; i++) { const osc = new Oscillator({ - context : this.context, + context: this.context, onstop: i === 0 ? () => this.onstop(this) : noOp, }); if (this.type === "custom") { diff --git a/Tone/source/oscillator/LFO.test.ts b/Tone/source/oscillator/LFO.test.ts index 53a3dbf1..9a53a6d4 100644 --- a/Tone/source/oscillator/LFO.test.ts +++ b/Tone/source/oscillator/LFO.test.ts @@ -30,8 +30,8 @@ describe("LFO", () => { it("can be constructed with an object", () => { const lfo = new LFO({ - frequency : 0.3, - type : "triangle2", + frequency: 0.3, + type: "triangle2", }); expect(lfo.type).to.equal("triangle2"); expect(lfo.frequency.value).to.be.closeTo(0.3, 0.001); @@ -42,11 +42,11 @@ describe("LFO", () => { return Offline(() => { const lfo = new LFO(); const values = { - frequency : "8n", - max : 2, - min : -1, - phase : 180, - type : "square", + frequency: "8n", + max: 2, + min: -1, + phase: 180, + type: "square", } as Partial; lfo.set(values); expect(lfo.get()).to.contain.keys(Object.keys(values)); @@ -100,8 +100,8 @@ describe("LFO", () => { it("outputs a signal at the correct phase angle", () => { return Offline(() => { new LFO({ - min : 0, - phase : 90, + min: 0, + phase: 90, }).toDestination(); }).then((buffer) => { expect(buffer.value()).to.be.closeTo(0, 0.1); @@ -111,9 +111,9 @@ describe("LFO", () => { it("outputs the right phase when setting a new phase", () => { return Offline(() => { const lfo = new LFO({ - max : 1, - min : -1, - phase : 0, + max: 1, + min: -1, + phase: 0, }).toDestination(); lfo.phase = 270; }).then((buffer) => { @@ -124,10 +124,10 @@ describe("LFO", () => { it("can convert to other units", () => { return Offline(() => { const lfo = new LFO({ - frequency : 20, - max : 5, - min : -20, - units : "decibels", + frequency: 20, + max: 5, + min: -20, + units: "decibels", }).toDestination(); lfo.start(); }).then((buffer) => { @@ -171,7 +171,7 @@ describe("LFO", () => { }); it("can sync the frequency to the Transport", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { const lfo = new LFO(2); lfo.sync(); lfo.frequency.toDestination(); @@ -184,7 +184,7 @@ describe("LFO", () => { }); it("can unsync the frequency to the transport", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { const lfo = new LFO(2); lfo.sync(); lfo.frequency.toDestination(); diff --git a/Tone/source/oscillator/LFO.ts b/Tone/source/oscillator/LFO.ts index 14894dc9..6618c392 100644 --- a/Tone/source/oscillator/LFO.ts +++ b/Tone/source/oscillator/LFO.ts @@ -121,8 +121,8 @@ export class LFO extends ToneAudioNode { // @ts-ignore this._oscillator = new Oscillator({ context: this.context, - frequency : options.frequency, - type : options.type, + frequency: options.frequency, + type: options.type, }); this.frequency = this._oscillator.frequency; @@ -138,7 +138,7 @@ export class LFO extends ToneAudioNode { value: 0, }); this._zeros = new Zero({ context: this.context }); - this._a2g = new AudioToGain({ context : this.context }); + this._a2g = new AudioToGain({ context: this.context }); this._scaler = this.output = new Scale({ context: this.context, max: options.max, @@ -159,13 +159,13 @@ export class LFO extends ToneAudioNode { static getDefaults(): LFOOptions { return Object.assign(ToneAudioNode.getDefaults(), { - amplitude : 1, - frequency : "4n", - max : 1, - min : 0, - phase : 0, - type : "sine" as ToneOscillatorType, - units : "number" as UnitName, + amplitude: 1, + frequency: "4n", + max: 1, + min: 0, + phase: 0, + type: "sine" as ToneOscillatorType, + units: "number" as UnitName, }); } diff --git a/Tone/source/oscillator/OmniOscillator.test.ts b/Tone/source/oscillator/OmniOscillator.test.ts index f35c639d..0bf2f123 100644 --- a/Tone/source/oscillator/OmniOscillator.test.ts +++ b/Tone/source/oscillator/OmniOscillator.test.ts @@ -97,7 +97,7 @@ describe("OmniOscillator", () => { it("can get and set the type", () => { const osc = new OmniOscillator({ - type : "sawtooth", + type: "sawtooth", }); expect(osc.type).to.equal("sawtooth"); osc.dispose(); @@ -160,8 +160,8 @@ describe("OmniOscillator", () => { it("can be set to an FM oscillator", () => { const omni = new OmniOscillator(); omni.set({ - modulationIndex : 2, - type : "fmsquare2", + modulationIndex: 2, + type: "fmsquare2", }); expect(omni.type).to.equal("fmsquare2"); expect(omni.modulationIndex.value).to.equal(2); @@ -182,8 +182,8 @@ describe("OmniOscillator", () => { it("can be set to an FatOscillator", () => { const omni = new OmniOscillator({ count: 4, - spread : 25, - type : "fatsquare2", + spread: 25, + type: "fatsquare2", }); expect(omni.type).to.equal("fatsquare2"); expect(omni.count).to.equal(4); @@ -193,7 +193,7 @@ describe("OmniOscillator", () => { it("can get/set the partialCount", () => { const omni = new OmniOscillator({ - type : "square2", + type: "square2", }); expect(omni.partialCount).to.equal(2); omni.partialCount = 3; @@ -204,7 +204,7 @@ describe("OmniOscillator", () => { it("can get/set the sourceType", () => { const omni = new OmniOscillator({ - type : "fatsquare3", + type: "fatsquare3", }); expect(omni.type).to.equal("fatsquare3"); expect(omni.sourceType).to.equal("fat"); @@ -230,7 +230,7 @@ describe("OmniOscillator", () => { it("can get/set the baseType", () => { const omni = new OmniOscillator({ - type : "fatsquare3", + type: "fatsquare3", }); expect(omni.type).to.equal("fatsquare3"); expect(omni.sourceType).to.equal("fat"); @@ -253,12 +253,12 @@ describe("OmniOscillator", () => { it("can set a FM oscillator with partials", () => { const omni = new OmniOscillator({ - detune : 4, - harmonicity : 2, - partials : [2, 1, 2, 2], - phase : 120, - type : "fmcustom", - volume : -2, + detune: 4, + harmonicity: 2, + partials: [2, 1, 2, 2], + phase: 120, + type: "fmcustom", + volume: -2, }); expect(omni.volume.value).to.be.closeTo(-2, 0.01); expect(omni.detune.value).to.be.closeTo(4, 0.01); @@ -272,8 +272,8 @@ describe("OmniOscillator", () => { it("setting/getting values when the wrong type is set has no effect", () => { const omni = new OmniOscillator(440, "sine"); omni.set({ - harmonicity : 3, - modulationIndex : 4, + harmonicity: 3, + modulationIndex: 4, }); omni.spread = 40; expect(omni.spread).to.be.undefined; diff --git a/Tone/source/oscillator/OmniOscillator.ts b/Tone/source/oscillator/OmniOscillator.ts index 7993023b..4b11e0c4 100644 --- a/Tone/source/oscillator/OmniOscillator.ts +++ b/Tone/source/oscillator/OmniOscillator.ts @@ -1,5 +1,5 @@ import { AudioRange, Cents, Degrees, Frequency, Positive, Time } from "../../core/type/Units"; -import { optionsFromArguments } from "../../core/util/Defaults"; +import { optionsFromArguments } from "../../core/util/Defaults"; import { readOnly } from "../../core/util/Interface"; import { isNumber, isString } from "../../core/util/TypeCheck"; import { Signal } from "../../signal/Signal"; @@ -48,7 +48,7 @@ type IsFMOscillator = Osc extends FMOscillator ? Ret : undefined; type AnyOscillatorConstructor = new (...args: any[]) => AnyOscillator; const OmniOscillatorSourceMap: { - [key in OmniOscSourceType] : AnyOscillatorConstructor + [key in OmniOscSourceType]: AnyOscillatorConstructor } = { am: AMOscillator, fat: FatOscillator, @@ -71,8 +71,8 @@ const OmniOscillatorSourceMap: { * var omniOsc = new OmniOscillator("C#4", "pwm"); */ export class OmniOscillator -extends Source -implements Omit { + extends Source + implements Omit { readonly name: string = "OmniOscillator"; @@ -184,11 +184,11 @@ implements Omit { } else if (type.substr(0, 2) === "am") { this._createNewOscillator("am"); this._oscillator = this._oscillator as AMOscillator; - this._oscillator.type = type.substr(2) as ToneOscillatorType; + this._oscillator.type = type.substr(2) as ToneOscillatorType; } else if (type.substr(0, 3) === "fat") { this._createNewOscillator("fat"); this._oscillator = this._oscillator as FatOscillator; - this._oscillator.type = type.substr(3) as ToneOscillatorType; + this._oscillator.type = type.substr(3) as ToneOscillatorType; } else if (type === "pwm") { this._createNewOscillator("pwm"); this._oscillator = this._oscillator as PWMOscillator; @@ -285,7 +285,7 @@ implements Omit { this.context.setTimeout(() => oldOsc.dispose(), this.blockTime); } this._oscillator = new OscConstructor({ - context : this.context, + context: this.context, }); this.frequency.connect(this._oscillator.frequency); this.detune.connect(this._oscillator.detune); diff --git a/Tone/source/oscillator/Oscillator.test.ts b/Tone/source/oscillator/Oscillator.test.ts index 3e265960..ff5a81d8 100644 --- a/Tone/source/oscillator/Oscillator.test.ts +++ b/Tone/source/oscillator/Oscillator.test.ts @@ -217,7 +217,7 @@ describe("Oscillator", () => { context("Synchronization", () => { it("can sync the frequency to the Transport", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { transport.bpm.value = 120; const osc = new Oscillator(2); osc.frequency.toDestination(); @@ -229,7 +229,7 @@ describe("Oscillator", () => { }); it("can unsync the frequency from the Transport", () => { - return Offline(({transport}) => { + return Offline(({ transport }) => { transport.bpm.value = 120; const osc = new Oscillator(2); osc.frequency.toDestination(); @@ -243,13 +243,13 @@ describe("Oscillator", () => { }); context("initialValue", () => { - it ("can get the initial value of a basic oscillator type", () => { + it("can get the initial value of a basic oscillator type", () => { const osc = new Oscillator(10, "sine"); expect(osc.getInitialValue()).to.be.closeTo(0, 0.01); osc.dispose(); }); - it ("can get the initial value when the phase is rotated", () => { + it("can get the initial value when the phase is rotated", () => { const osc = new Oscillator({ phase: 90, type: "sine", @@ -258,7 +258,7 @@ describe("Oscillator", () => { osc.dispose(); }); - it ("can get the initial value of more complex types", () => { + it("can get the initial value of more complex types", () => { const osc = new Oscillator({ partials: [0, 2, 4, 1, 3], phase: 145, diff --git a/Tone/source/oscillator/Oscillator.ts b/Tone/source/oscillator/Oscillator.ts index afcea9e5..a6fb6e9e 100644 --- a/Tone/source/oscillator/Oscillator.ts +++ b/Tone/source/oscillator/Oscillator.ts @@ -360,7 +360,7 @@ export class Oscillator extends Source implements ToneOsc this._partialCount = this._partials.length; periodicWaveSize = partialCount; // if the partial count is 0, don't bother doing any computation - if (this._partials.length === 0 ) { + if (this._partials.length === 0) { return [real, imag]; } } else { diff --git a/Tone/source/oscillator/PWMOscillator.ts b/Tone/source/oscillator/PWMOscillator.ts index bc8562a9..d1ede5cc 100644 --- a/Tone/source/oscillator/PWMOscillator.ts +++ b/Tone/source/oscillator/PWMOscillator.ts @@ -75,7 +75,7 @@ export class PWMOscillator extends Source implements ToneO // @ts-ignore this._pulse._sawtooth.type = "sine"; - this.modulationFrequency = this._pulse.frequency; + this.modulationFrequency = this._pulse.frequency; this._modulator = new Oscillator({ context: this.context, diff --git a/Tone/source/oscillator/PulseOscillator.test.ts b/Tone/source/oscillator/PulseOscillator.test.ts index 5c01a121..65d663f5 100644 --- a/Tone/source/oscillator/PulseOscillator.test.ts +++ b/Tone/source/oscillator/PulseOscillator.test.ts @@ -26,8 +26,8 @@ describe("PulseOscillator", () => { it("can change the phase to 90", () => { return Offline(() => { const osc = new PulseOscillator({ - frequency : 1, - phase : 90, + frequency: 1, + phase: 90, width: 0, }); osc.toDestination(); @@ -46,8 +46,8 @@ describe("PulseOscillator", () => { it("can change the phase to -90", () => { return Offline(() => { const osc = new PulseOscillator({ - frequency : 1, - phase : 270, + frequency: 1, + phase: 270, width: 0, }); osc.toDestination(); @@ -69,7 +69,7 @@ describe("PulseOscillator", () => { it("can set the width", () => { const osc = new PulseOscillator({ - width : 0.2, + width: 0.2, }); expect(osc.width.value).to.be.closeTo(0.2, 0.001); osc.dispose(); @@ -78,8 +78,8 @@ describe("PulseOscillator", () => { it("outputs correctly with a width of 0", () => { return Offline(() => { const osc = new PulseOscillator({ - frequency : 1, - width : 0, + frequency: 1, + width: 0, }); osc.toDestination(); osc.start(0); @@ -95,8 +95,8 @@ describe("PulseOscillator", () => { it("outputs correctly with a width of 0.5", () => { return Offline(() => { const osc = new PulseOscillator({ - frequency : 1, - width : 0.5, + frequency: 1, + width: 0.5, }); osc.toDestination(); osc.start(0); diff --git a/Tone/source/oscillator/PulseOscillator.ts b/Tone/source/oscillator/PulseOscillator.ts index 9faac18d..653cf561 100644 --- a/Tone/source/oscillator/PulseOscillator.ts +++ b/Tone/source/oscillator/PulseOscillator.ts @@ -105,7 +105,7 @@ export class PulseOscillator extends Source implements T frequency: options.frequency, onstop: () => this.onstop(this), phase: options.phase, - type : "sawtooth", + type: "sawtooth", }); this.frequency = this._sawtooth.frequency; this.detune = this._sawtooth.detune; diff --git a/Tone/source/oscillator/ToneOscillatorNode.ts b/Tone/source/oscillator/ToneOscillatorNode.ts index 0234cdb4..afe0e2e3 100644 --- a/Tone/source/oscillator/ToneOscillatorNode.ts +++ b/Tone/source/oscillator/ToneOscillatorNode.ts @@ -55,16 +55,16 @@ export class ToneOscillatorNode extends OneShotSource this.frequency = new Param({ context: this.context, - param : this._oscillator.frequency, - units : "frequency", - value : options.frequency, + param: this._oscillator.frequency, + units: "frequency", + value: options.frequency, }); this.detune = new Param({ context: this.context, - param : this._oscillator.detune, - units : "cents", - value : options.detune, + param: this._oscillator.detune, + units: "cents", + value: options.detune, }); } diff --git a/package.json b/package.json index 642f1d7b..434f207e 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,8 @@ "karma": "karma start scripts/karma.conf.js --single-run --file $npm_config_file --dir $npm_config_dir", "karma:browser": "karma start scripts/karma.conf.js --auto-watch --browsers OnlineChrome --file $npm_config_file --dir $npm_config_dir", "karma:watch": "karma start scripts/karma.conf.js --auto-watch --file $npm_config_file --dir $npm_config_dir", - "lint": "eslint --ignore-pattern ./Tone/**/*.test.ts ./Tone/**/*.ts", - "lint:fix": "eslint --fix ./Tone/**/*.ts", + "lint": "eslint --ignore-pattern ./Tone/**/*.test.ts --ext ts ./Tone", + "lint:fix": "eslint --ext ts --fix ./Tone", "scratch": "webpack -w --env.scratch --mode=development", "test": "npm run karma", "test:watch": "npm run collect:tests && npm run karma:watch",