tone 15.4.2 → 15.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Tone/effect/AutoPanner.test.ts +18 -0
- package/Tone/effect/AutoPanner.ts +30 -4
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/effect/AutoPanner.d.ts +13 -3
- package/build/esm/effect/AutoPanner.js +20 -2
- package/build/esm/effect/AutoPanner.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -87,5 +87,23 @@ describe("AutoPanner", () => {
|
|
|
87
87
|
expect(buffer.getValueAtTime(0)).to.be.closeTo(2, 0.1);
|
|
88
88
|
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(2, 0.1);
|
|
89
89
|
});
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Width Tests
|
|
93
|
+
*/
|
|
94
|
+
it("can set the width", () => {
|
|
95
|
+
const autoPanner = new AutoPanner();
|
|
96
|
+
autoPanner.width = 0.5;
|
|
97
|
+
expect(autoPanner.width).to.be.closeTo(0.5, 0.01);
|
|
98
|
+
autoPanner.dispose();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("can pass width in the constructor", () => {
|
|
102
|
+
const autoPanner = new AutoPanner({
|
|
103
|
+
width: 0.3,
|
|
104
|
+
});
|
|
105
|
+
expect(autoPanner.width).to.be.closeTo(0.3, 0.01);
|
|
106
|
+
autoPanner.dispose();
|
|
107
|
+
});
|
|
90
108
|
});
|
|
91
109
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Panner } from "../component/channel/Panner.js";
|
|
2
|
-
import { Frequency } from "../core/type/Units.js";
|
|
2
|
+
import { Frequency, NormalRange } from "../core/type/Units.js";
|
|
3
3
|
import { optionsFromArguments } from "../core/util/Defaults.js";
|
|
4
4
|
import { LFOEffect, LFOEffectOptions } from "./LFOEffect.js";
|
|
5
5
|
|
|
6
6
|
export interface AutoPannerOptions extends LFOEffectOptions {
|
|
7
7
|
channelCount: number;
|
|
8
|
+
width: NormalRange;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -24,7 +25,9 @@ export class AutoPanner extends LFOEffect<AutoPannerOptions> {
|
|
|
24
25
|
/**
|
|
25
26
|
* The filter node
|
|
26
27
|
*/
|
|
27
|
-
readonly _panner: Panner;
|
|
28
|
+
private readonly _panner: Panner;
|
|
29
|
+
|
|
30
|
+
private _width: NormalRange;
|
|
28
31
|
|
|
29
32
|
/**
|
|
30
33
|
* @param frequency Rate of left-right oscillation.
|
|
@@ -43,19 +46,42 @@ export class AutoPanner extends LFOEffect<AutoPannerOptions> {
|
|
|
43
46
|
context: this.context,
|
|
44
47
|
channelCount: options.channelCount,
|
|
45
48
|
});
|
|
49
|
+
|
|
50
|
+
this._width = options.width;
|
|
51
|
+
|
|
46
52
|
// connections
|
|
47
53
|
this.connectEffect(this._panner);
|
|
48
54
|
this._lfo.connect(this._panner.pan);
|
|
49
|
-
this.
|
|
50
|
-
this._lfo.max = 1;
|
|
55
|
+
this._updateLFORange();
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
static getDefaults(): AutoPannerOptions {
|
|
54
59
|
return Object.assign(LFOEffect.getDefaults(), {
|
|
55
60
|
channelCount: 1,
|
|
61
|
+
width: 1,
|
|
56
62
|
});
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Updates the LFO min/max based on width
|
|
67
|
+
*/
|
|
68
|
+
private _updateLFORange(): void {
|
|
69
|
+
this._lfo.min = -this._width;
|
|
70
|
+
this._lfo.max = this._width;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The width of the panning effect. 0 = no panning, 1 = full left-right panning.
|
|
75
|
+
*/
|
|
76
|
+
get width(): NormalRange {
|
|
77
|
+
return this._width;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
set width(width: NormalRange) {
|
|
81
|
+
this._width = width;
|
|
82
|
+
this._updateLFORange();
|
|
83
|
+
}
|
|
84
|
+
|
|
59
85
|
dispose(): this {
|
|
60
86
|
super.dispose();
|
|
61
87
|
this._panner.dispose();
|
package/Tone/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version: string = "15.4.
|
|
1
|
+
export const version: string = "15.4.3";
|