fixing amplitude to it's still centered in the same spot

fixes #777
This commit is contained in:
Yotam Mann 2020-10-30 11:17:27 -04:00
parent 5a52c9f1bf
commit ccf74922d4
2 changed files with 25 additions and 1 deletions

View file

@ -196,5 +196,29 @@ describe("LFO", () => {
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(2, 0.1);
});
});
it("can adjust the amplitude", () => {
return Offline(({ transport }) => {
const lfo = new LFO(10, -10, 10);
lfo.amplitude.value = 0.5;
lfo.toDestination();
lfo.start();
}, 0.1).then((buffer) => {
expect(buffer.min()).to.be.closeTo(-5, 0.1);
expect(buffer.max()).to.be.closeTo(5, 0.1);
});
});
it("can adjust the amplitude not centered at 0", () => {
return Offline(({ transport }) => {
const lfo = new LFO(10, 400, 4000);
lfo.amplitude.value = 0.5;
lfo.toDestination();
lfo.start();
}, 0.1).then((buffer) => {
expect(buffer.min()).to.be.closeTo(1300, 1);
expect(buffer.max()).to.be.closeTo(3100, 1);
});
});
});
});

View file

@ -150,7 +150,7 @@ export class LFO extends ToneAudioNode<LFOOptions> {
this.max = options.max;
// connect it up
this._oscillator.chain(this._a2g, this._amplitudeGain, this._scaler);
this._oscillator.chain(this._amplitudeGain, this._a2g, this._scaler);
this._zeros.connect(this._a2g);
this._stoppedSignal.connect(this._a2g);
readOnly(this, ["amplitude", "frequency"]);