removing positive number restriction on frequency envelope octaves

This commit is contained in:
Yotam Mann 2020-11-02 13:47:24 -05:00
parent 66b377e1b5
commit 944fa51466
2 changed files with 9 additions and 4 deletions

View file

@ -60,6 +60,12 @@ describe("FrequencyEnvelope", () => {
env1.dispose();
});
it("can set a negative octave", () => {
const freqEnv = new FrequencyEnvelope();
freqEnv.octaves = -2;
freqEnv.dispose();
});
it("goes to the scaled range", async () => {
const e = {
attack: 0.01,

View file

@ -37,7 +37,7 @@ export class FrequencyEnvelope extends Envelope {
/**
* The number of octaves
*/
private _octaves: Positive;
private _octaves: number;
/**
* Internal scaler from 0-1 to the final output range
@ -104,11 +104,10 @@ export class FrequencyEnvelope extends Envelope {
* The number of octaves above the baseFrequency that the
* envelope will scale to.
*/
get octaves(): Positive {
get octaves(): number {
return this._octaves;
}
set octaves(octaves: Positive) {
assertRange(octaves, 0);
set octaves(octaves: number) {
this._octaves = octaves;
this._scale.max = this._baseFrequency * Math.pow(2, octaves);
}