tone 15.2.1 → 15.2.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/component/analysis/Analyser.ts +11 -11
- package/Tone/component/analysis/Follower.test.ts +38 -42
- package/Tone/component/analysis/MeterBase.ts +1 -1
- package/Tone/component/channel/Channel.test.ts +3 -4
- package/Tone/component/channel/Merge.test.ts +5 -6
- package/Tone/component/channel/MidSideSplit.test.ts +21 -25
- package/Tone/component/channel/Mono.test.ts +18 -20
- package/Tone/component/channel/PanVol.test.ts +3 -4
- package/Tone/component/channel/Panner.test.ts +28 -32
- package/Tone/component/channel/Recorder.ts +1 -1
- package/Tone/component/channel/Volume.test.ts +9 -12
- package/Tone/component/dynamics/Gate.test.ts +10 -14
- package/Tone/component/envelope/AmplitudeEnvelope.test.ts +7 -9
- package/Tone/component/envelope/Envelope.test.ts +347 -384
- package/Tone/component/envelope/Envelope.ts +1 -1
- package/Tone/component/filter/BiquadFilter.test.ts +5 -6
- package/Tone/component/filter/Convolver.test.ts +6 -9
- package/Tone/component/filter/FeedbackCombFilter.test.ts +14 -16
- package/Tone/component/filter/Filter.test.ts +5 -6
- package/Tone/component/filter/LowpassCombFilter.test.ts +15 -17
- package/Tone/component/filter/LowpassCombFilter.ts +1 -1
- package/Tone/core/clock/Clock.test.ts +18 -21
- package/Tone/core/clock/TickParam.ts +1 -1
- package/Tone/core/clock/TickSignal.test.ts +24 -27
- package/Tone/core/clock/TickSource.test.ts +1 -1
- package/Tone/core/clock/Transport.test.ts +133 -162
- package/Tone/core/clock/TransportEvent.test.ts +3 -4
- package/Tone/core/clock/TransportRepeatEvent.test.ts +6 -6
- package/Tone/core/context/Context.test.ts +8 -10
- package/Tone/core/context/Context.ts +1 -1
- package/Tone/core/context/Destination.test.ts +3 -4
- package/Tone/core/context/Offline.test.ts +23 -41
- package/Tone/core/context/OfflineContext.test.ts +20 -22
- package/Tone/core/context/Param.test.ts +33 -40
- package/Tone/core/context/ToneAudioBuffer.test.ts +4 -11
- package/Tone/core/context/ToneAudioBuffers.test.ts +10 -14
- package/Tone/core/context/ToneAudioBuffers.ts +2 -2
- package/Tone/core/type/Frequency.test.ts +6 -6
- package/Tone/core/type/Ticks.test.ts +1 -1
- package/Tone/core/type/Time.test.ts +2 -2
- package/Tone/core/type/TransportTime.test.ts +1 -1
- package/Tone/core/util/IntervalTimeline.test.ts +1 -1
- package/Tone/core/util/IntervalTimeline.ts +1 -1
- package/Tone/core/util/StateTimeline.test.ts +2 -2
- package/Tone/core/util/Timeline.test.ts +1 -1
- package/Tone/core/util/Timeline.ts +1 -1
- package/Tone/core/worklet/ToneAudioWorklet.ts +3 -1
- package/Tone/effect/AutoFilter.test.ts +10 -12
- package/Tone/effect/AutoPanner.test.ts +10 -12
- package/Tone/effect/AutoWah.ts +1 -1
- package/Tone/effect/Chorus.test.ts +10 -14
- package/Tone/effect/FrequencyShifter.test.ts +6 -7
- package/Tone/effect/FrequencyShifter.ts +1 -1
- package/Tone/effect/MidSideEffect.ts +1 -1
- package/Tone/effect/Reverb.test.ts +12 -15
- package/Tone/effect/StereoWidener.ts +1 -1
- package/Tone/effect/Tremolo.test.ts +10 -12
- package/Tone/effect/Vibrato.ts +1 -1
- package/Tone/event/Loop.test.ts +29 -36
- package/Tone/event/Part.test.ts +156 -184
- package/Tone/event/Part.ts +5 -5
- package/Tone/event/Pattern.test.ts +16 -20
- package/Tone/event/Sequence.test.ts +88 -103
- package/Tone/event/Sequence.ts +1 -1
- package/Tone/event/ToneEvent.test.ts +60 -70
- package/Tone/instrument/Instrument.ts +1 -1
- package/Tone/instrument/MonoSynth.test.ts +3 -4
- package/Tone/instrument/PolySynth.test.ts +62 -74
- package/Tone/instrument/PolySynth.ts +1 -1
- package/Tone/instrument/Sampler.test.ts +39 -48
- package/Tone/instrument/Synth.test.ts +41 -48
- package/Tone/signal/AudioToGain.test.ts +4 -5
- package/Tone/signal/Multiply.test.ts +1 -1
- package/Tone/signal/Negate.test.ts +2 -2
- package/Tone/signal/Signal.test.ts +120 -143
- package/Tone/signal/Signal.ts +1 -1
- package/Tone/signal/SyncedSignal.test.ts +108 -122
- package/Tone/signal/ToneConstantSource.test.ts +21 -25
- package/Tone/signal/WaveShaper.test.ts +5 -6
- package/Tone/source/Source.test.ts +43 -49
- package/Tone/source/UserMedia.test.ts +1 -2
- package/Tone/source/buffer/GrainPlayer.test.ts +29 -35
- package/Tone/source/buffer/Player.test.ts +162 -191
- package/Tone/source/buffer/Players.test.ts +44 -50
- package/Tone/source/buffer/Players.ts +1 -1
- package/Tone/source/buffer/ToneBufferSource.test.ts +176 -211
- package/Tone/source/oscillator/LFO.test.ts +49 -61
- package/Tone/source/oscillator/OmniOscillator.ts +0 -1
- package/Tone/source/oscillator/Oscillator.test.ts +24 -28
- package/Tone/source/oscillator/PulseOscillator.test.ts +36 -40
- package/Tone/source/oscillator/ToneOscillatorNode.test.ts +25 -29
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/component/analysis/Analyser.d.ts +1 -1
- package/build/esm/component/analysis/Analyser.js +11 -11
- package/build/esm/component/analysis/MeterBase.d.ts +1 -1
- package/build/esm/component/channel/Recorder.js.map +1 -1
- package/build/esm/component/envelope/Envelope.d.ts +1 -1
- package/build/esm/component/filter/LowpassCombFilter.d.ts +1 -1
- package/build/esm/core/clock/TickParam.js +1 -1
- package/build/esm/core/clock/TickParam.js.map +1 -1
- package/build/esm/core/context/Context.d.ts +1 -1
- package/build/esm/core/context/Context.js +1 -1
- package/build/esm/core/context/ToneAudioBuffers.d.ts +2 -2
- package/build/esm/core/context/ToneAudioBuffers.js +2 -2
- package/build/esm/core/util/IntervalTimeline.d.ts +1 -1
- package/build/esm/core/util/IntervalTimeline.js +1 -1
- package/build/esm/core/util/Timeline.d.ts +1 -1
- package/build/esm/core/util/Timeline.js +1 -1
- package/build/esm/core/worklet/ToneAudioWorklet.js.map +1 -1
- package/build/esm/effect/AutoWah.d.ts +1 -1
- package/build/esm/effect/FrequencyShifter.d.ts +1 -1
- package/build/esm/effect/FrequencyShifter.js +1 -1
- package/build/esm/effect/MidSideEffect.d.ts +1 -1
- package/build/esm/effect/MidSideEffect.js +1 -1
- package/build/esm/effect/StereoWidener.d.ts +1 -1
- package/build/esm/effect/StereoWidener.js +1 -1
- package/build/esm/effect/Vibrato.js +1 -1
- package/build/esm/effect/Vibrato.js.map +1 -1
- package/build/esm/event/Part.d.ts +2 -2
- package/build/esm/event/Part.js +5 -5
- package/build/esm/event/Part.js.map +1 -1
- package/build/esm/event/Sequence.d.ts +1 -1
- package/build/esm/instrument/Instrument.d.ts +1 -1
- package/build/esm/instrument/PolySynth.d.ts +1 -1
- package/build/esm/instrument/PolySynth.js +1 -1
- package/build/esm/signal/Signal.d.ts +1 -1
- package/build/esm/signal/Signal.js +1 -1
- package/build/esm/source/buffer/Players.d.ts +1 -1
- package/build/esm/source/buffer/Players.js +1 -1
- package/build/esm/source/oscillator/OmniOscillator.js +0 -1
- package/build/esm/source/oscillator/OmniOscillator.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/package.json +3 -1
|
@@ -33,7 +33,7 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
|
|
|
33
33
|
/**
|
|
34
34
|
* The analyser node.
|
|
35
35
|
*/
|
|
36
|
-
private
|
|
36
|
+
private _analyzers: AnalyserNode[] = [];
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Input and output are a gain node
|
|
@@ -81,10 +81,10 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
|
|
|
81
81
|
|
|
82
82
|
assertRange(options.channels, 1);
|
|
83
83
|
|
|
84
|
-
// create the
|
|
84
|
+
// create the analyzers
|
|
85
85
|
for (let channel = 0; channel < options.channels; channel++) {
|
|
86
|
-
this.
|
|
87
|
-
this._split.connect(this.
|
|
86
|
+
this._analyzers[channel] = this.context.createAnalyser();
|
|
87
|
+
this._split.connect(this._analyzers[channel], channel, 0);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// set the values initially
|
|
@@ -109,7 +109,7 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
|
|
|
109
109
|
* represents the analysis done on a channel.
|
|
110
110
|
*/
|
|
111
111
|
getValue(): Float32Array | Float32Array[] {
|
|
112
|
-
this.
|
|
112
|
+
this._analyzers.forEach((analyser, index) => {
|
|
113
113
|
const buffer = this._buffers[index];
|
|
114
114
|
if (this._type === "fft") {
|
|
115
115
|
analyser.getFloatFrequencyData(buffer);
|
|
@@ -128,10 +128,10 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
|
|
|
128
128
|
* The size of analysis. This must be a power of two in the range 16 to 16384.
|
|
129
129
|
*/
|
|
130
130
|
get size(): PowerOfTwo {
|
|
131
|
-
return this.
|
|
131
|
+
return this._analyzers[0].frequencyBinCount;
|
|
132
132
|
}
|
|
133
133
|
set size(size: PowerOfTwo) {
|
|
134
|
-
this.
|
|
134
|
+
this._analyzers.forEach((analyser, index) => {
|
|
135
135
|
analyser.fftSize = size * 2;
|
|
136
136
|
this._buffers[index] = new Float32Array(size);
|
|
137
137
|
});
|
|
@@ -142,7 +142,7 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
|
|
|
142
142
|
* separation is done using {@link Split}
|
|
143
143
|
*/
|
|
144
144
|
get channels(): number {
|
|
145
|
-
return this.
|
|
145
|
+
return this._analyzers.length;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/**
|
|
@@ -163,10 +163,10 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
|
|
|
163
163
|
* 0 represents no time averaging with the last analysis frame.
|
|
164
164
|
*/
|
|
165
165
|
get smoothing(): NormalRange {
|
|
166
|
-
return this.
|
|
166
|
+
return this._analyzers[0].smoothingTimeConstant;
|
|
167
167
|
}
|
|
168
168
|
set smoothing(val: NormalRange) {
|
|
169
|
-
this.
|
|
169
|
+
this._analyzers.forEach((a) => (a.smoothingTimeConstant = val));
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
|
@@ -174,7 +174,7 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
|
|
|
174
174
|
*/
|
|
175
175
|
dispose(): this {
|
|
176
176
|
super.dispose();
|
|
177
|
-
this.
|
|
177
|
+
this._analyzers.forEach((a) => a.disconnect());
|
|
178
178
|
this._split.dispose();
|
|
179
179
|
this._gain.dispose();
|
|
180
180
|
return this;
|
|
@@ -28,74 +28,70 @@ describe("Follower", () => {
|
|
|
28
28
|
follower.dispose();
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
it("smooths the incoming signal at 0.1", () => {
|
|
32
|
-
|
|
31
|
+
it("smooths the incoming signal at 0.1", async () => {
|
|
32
|
+
const buffer = await Offline(() => {
|
|
33
33
|
const foll = new Follower(0.1).toDestination();
|
|
34
34
|
const sig = new Signal(0);
|
|
35
35
|
sig.connect(foll);
|
|
36
36
|
sig.setValueAtTime(1, 0.1);
|
|
37
37
|
sig.setValueAtTime(0, 0.3);
|
|
38
|
-
}, 0.41)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
38
|
+
}, 0.41);
|
|
39
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.01);
|
|
40
|
+
expect(buffer.getValueAtTime(0.1)).to.be.closeTo(0.0, 0.01);
|
|
41
|
+
expect(buffer.getValueAtTime(0.15)).to.be.closeTo(0.95, 0.05);
|
|
42
|
+
expect(buffer.getValueAtTime(0.2)).to.be.closeTo(1, 0.01);
|
|
43
|
+
expect(buffer.getValueAtTime(0.3)).to.be.closeTo(1, 0.01);
|
|
44
|
+
expect(buffer.getValueAtTime(0.35)).to.be.closeTo(0.05, 0.05);
|
|
45
|
+
expect(buffer.getValueAtTime(0.4)).to.be.closeTo(0, 0.01);
|
|
47
46
|
});
|
|
48
47
|
|
|
49
|
-
it("smooths the incoming signal at 0.05", () => {
|
|
50
|
-
|
|
48
|
+
it("smooths the incoming signal at 0.05", async () => {
|
|
49
|
+
const buffer = await Offline(() => {
|
|
51
50
|
const foll = new Follower(0.05).toDestination();
|
|
52
51
|
const sig = new Signal(0);
|
|
53
52
|
sig.connect(foll);
|
|
54
53
|
sig.setValueAtTime(1, 0.1);
|
|
55
54
|
sig.setValueAtTime(0, 0.3);
|
|
56
|
-
}, 0.41)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
55
|
+
}, 0.41);
|
|
56
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.01);
|
|
57
|
+
expect(buffer.getValueAtTime(0.1)).to.be.closeTo(0.0, 0.01);
|
|
58
|
+
expect(buffer.getValueAtTime(0.125)).to.be.closeTo(0.95, 0.05);
|
|
59
|
+
expect(buffer.getValueAtTime(0.15)).to.be.closeTo(1, 0.01);
|
|
60
|
+
expect(buffer.getValueAtTime(0.3)).to.be.closeTo(1, 0.01);
|
|
61
|
+
expect(buffer.getValueAtTime(0.325)).to.be.closeTo(0.05, 0.05);
|
|
62
|
+
expect(buffer.getValueAtTime(0.35)).to.be.closeTo(0, 0.01);
|
|
65
63
|
});
|
|
66
64
|
|
|
67
|
-
it("smooths the incoming signal at 0.2", () => {
|
|
68
|
-
|
|
65
|
+
it("smooths the incoming signal at 0.2", async () => {
|
|
66
|
+
const buffer = await Offline(() => {
|
|
69
67
|
const foll = new Follower(0.2).toDestination();
|
|
70
68
|
const sig = new Signal(0);
|
|
71
69
|
sig.connect(foll);
|
|
72
70
|
sig.setValueAtTime(1, 0.1);
|
|
73
71
|
sig.setValueAtTime(0, 0.3);
|
|
74
|
-
}, 0.51)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
72
|
+
}, 0.51);
|
|
73
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.01);
|
|
74
|
+
expect(buffer.getValueAtTime(0.1)).to.be.closeTo(0.0, 0.01);
|
|
75
|
+
expect(buffer.getValueAtTime(0.2)).to.be.closeTo(0.95, 0.05);
|
|
76
|
+
expect(buffer.getValueAtTime(0.3)).to.be.closeTo(1, 0.01);
|
|
77
|
+
expect(buffer.getValueAtTime(0.4)).to.be.closeTo(0.05, 0.05);
|
|
78
|
+
expect(buffer.getValueAtTime(0.5)).to.be.closeTo(0, 0.01);
|
|
82
79
|
});
|
|
83
80
|
|
|
84
|
-
it("smooths the incoming signal at 0.5", () => {
|
|
85
|
-
|
|
81
|
+
it("smooths the incoming signal at 0.5", async () => {
|
|
82
|
+
const buffer = await Offline(() => {
|
|
86
83
|
const foll = new Follower(0.5).toDestination();
|
|
87
84
|
const sig = new Signal(0);
|
|
88
85
|
sig.connect(foll);
|
|
89
86
|
sig.setValueAtTime(1, 0.1);
|
|
90
87
|
sig.setValueAtTime(0, 0.6);
|
|
91
|
-
}, 1.11)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
88
|
+
}, 1.11);
|
|
89
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.01);
|
|
90
|
+
expect(buffer.getValueAtTime(0.1)).to.be.closeTo(0.0, 0.01);
|
|
91
|
+
expect(buffer.getValueAtTime(0.35)).to.be.closeTo(0.95, 0.05);
|
|
92
|
+
expect(buffer.getValueAtTime(0.6)).to.be.closeTo(1, 0.01);
|
|
93
|
+
expect(buffer.getValueAtTime(0.85)).to.be.closeTo(0.05, 0.05);
|
|
94
|
+
expect(buffer.getValueAtTime(1.1)).to.be.closeTo(0, 0.01);
|
|
99
95
|
});
|
|
100
96
|
|
|
101
97
|
it("passes the incoming signal through", () => {
|
|
@@ -37,14 +37,13 @@ describe("Channel", () => {
|
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
it("can mute the input", () => {
|
|
41
|
-
|
|
40
|
+
it("can mute the input", async () => {
|
|
41
|
+
const buffer = await Offline(() => {
|
|
42
42
|
const channel = new Channel(0).toDestination();
|
|
43
43
|
new Signal(1).connect(channel);
|
|
44
44
|
channel.mute = true;
|
|
45
|
-
}).then((buffer) => {
|
|
46
|
-
expect(buffer.isSilent()).to.be.true;
|
|
47
45
|
});
|
|
46
|
+
expect(buffer.isSilent()).to.be.true;
|
|
48
47
|
});
|
|
49
48
|
|
|
50
49
|
it("reports itself as muted when either muted or another channel is soloed", () => {
|
|
@@ -40,8 +40,8 @@ describe("Merge", () => {
|
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
it("merge two signal into one stereo signal", () => {
|
|
44
|
-
|
|
43
|
+
it("merge two signal into one stereo signal", async () => {
|
|
44
|
+
const buffer = await Offline(
|
|
45
45
|
() => {
|
|
46
46
|
const sigL = new Signal(1);
|
|
47
47
|
const sigR = new Signal(2);
|
|
@@ -52,10 +52,9 @@ describe("Merge", () => {
|
|
|
52
52
|
},
|
|
53
53
|
0.1,
|
|
54
54
|
2
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
55
|
+
);
|
|
56
|
+
expect(buffer.toArray()[0][0]).to.be.closeTo(1, 0.001);
|
|
57
|
+
expect(buffer.toArray()[1][0]).to.be.closeTo(2, 0.001);
|
|
59
58
|
});
|
|
60
59
|
});
|
|
61
60
|
});
|
|
@@ -19,47 +19,44 @@ describe("MidSideSplit", () => {
|
|
|
19
19
|
split.dispose();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
it("mid is if both L and R are the same", () => {
|
|
23
|
-
|
|
22
|
+
it("mid is if both L and R are the same", async () => {
|
|
23
|
+
const buffer = await Offline(() => {
|
|
24
24
|
const split = new MidSideSplit();
|
|
25
25
|
split.mid.toDestination();
|
|
26
26
|
const merge = new Merge().connect(split);
|
|
27
27
|
new Signal(0.5).connect(merge, 0, 0);
|
|
28
28
|
new Signal(0.5).connect(merge, 0, 1);
|
|
29
|
-
}).then((buffer) => {
|
|
30
|
-
expect(buffer.min()).to.be.closeTo(0.707, 0.01);
|
|
31
|
-
expect(buffer.max()).to.be.closeTo(0.707, 0.01);
|
|
32
29
|
});
|
|
30
|
+
expect(buffer.min()).to.be.closeTo(0.707, 0.01);
|
|
31
|
+
expect(buffer.max()).to.be.closeTo(0.707, 0.01);
|
|
33
32
|
});
|
|
34
33
|
|
|
35
|
-
it("side is 0 if both L and R are the same", () => {
|
|
36
|
-
|
|
34
|
+
it("side is 0 if both L and R are the same", async () => {
|
|
35
|
+
const buffer = await Offline(() => {
|
|
37
36
|
const split = new MidSideSplit();
|
|
38
37
|
split.side.toDestination();
|
|
39
38
|
const merge = new Merge().connect(split);
|
|
40
39
|
new Signal(0.5).connect(merge, 0, 0);
|
|
41
40
|
new Signal(0.5).connect(merge, 0, 1);
|
|
42
|
-
}).then((buffer) => {
|
|
43
|
-
expect(buffer.min()).to.be.closeTo(0, 0.01);
|
|
44
|
-
expect(buffer.max()).to.be.closeTo(0, 0.01);
|
|
45
41
|
});
|
|
42
|
+
expect(buffer.min()).to.be.closeTo(0, 0.01);
|
|
43
|
+
expect(buffer.max()).to.be.closeTo(0, 0.01);
|
|
46
44
|
});
|
|
47
45
|
|
|
48
|
-
it("mid is 0 if both L and R opposites", () => {
|
|
49
|
-
|
|
46
|
+
it("mid is 0 if both L and R opposites", async () => {
|
|
47
|
+
const buffer = await Offline(() => {
|
|
50
48
|
const split = new MidSideSplit();
|
|
51
49
|
split.mid.toDestination();
|
|
52
50
|
const merge = new Merge().connect(split);
|
|
53
51
|
new Signal(-1).connect(merge, 0, 0);
|
|
54
52
|
new Signal(1).connect(merge, 0, 1);
|
|
55
|
-
}).then((buffer) => {
|
|
56
|
-
expect(buffer.min()).to.be.closeTo(0, 0.01);
|
|
57
|
-
expect(buffer.max()).to.be.closeTo(0, 0.01);
|
|
58
53
|
});
|
|
54
|
+
expect(buffer.min()).to.be.closeTo(0, 0.01);
|
|
55
|
+
expect(buffer.max()).to.be.closeTo(0, 0.01);
|
|
59
56
|
});
|
|
60
57
|
|
|
61
|
-
it("can decompose and reconstruct a signal", () => {
|
|
62
|
-
|
|
58
|
+
it("can decompose and reconstruct a signal", async () => {
|
|
59
|
+
const buffer = await Offline(
|
|
63
60
|
() => {
|
|
64
61
|
const midSideMerge = new MidSideMerge().toDestination();
|
|
65
62
|
const split = new MidSideSplit();
|
|
@@ -71,14 +68,13 @@ describe("MidSideSplit", () => {
|
|
|
71
68
|
},
|
|
72
69
|
0.1,
|
|
73
70
|
2
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
71
|
+
);
|
|
72
|
+
buffer
|
|
73
|
+
.toArray()[0]
|
|
74
|
+
.forEach((l) => expect(l).to.be.closeTo(0.2, 0.01));
|
|
75
|
+
buffer
|
|
76
|
+
.toArray()[1]
|
|
77
|
+
.forEach((r) => expect(r).to.be.closeTo(0.4, 0.01));
|
|
82
78
|
});
|
|
83
79
|
});
|
|
84
80
|
});
|
|
@@ -9,40 +9,38 @@ describe("Mono", () => {
|
|
|
9
9
|
BasicTests(Mono);
|
|
10
10
|
|
|
11
11
|
context("Mono", () => {
|
|
12
|
-
it("Makes a mono signal in both channels", () => {
|
|
13
|
-
|
|
12
|
+
it("Makes a mono signal in both channels", async () => {
|
|
13
|
+
const buffer = await Offline(
|
|
14
14
|
() => {
|
|
15
15
|
const mono = new Mono().toDestination();
|
|
16
16
|
const signal = new Signal(2).connect(mono);
|
|
17
17
|
},
|
|
18
18
|
0.1,
|
|
19
19
|
2
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
20
|
+
);
|
|
21
|
+
expect(buffer.toArray()[0][0]).to.equal(2);
|
|
22
|
+
expect(buffer.toArray()[1][0]).to.equal(2);
|
|
23
|
+
expect(buffer.toArray()[0][100]).to.equal(2);
|
|
24
|
+
expect(buffer.toArray()[1][100]).to.equal(2);
|
|
25
|
+
expect(buffer.toArray()[0][1000]).to.equal(2);
|
|
26
|
+
expect(buffer.toArray()[1][1000]).to.equal(2);
|
|
28
27
|
});
|
|
29
28
|
|
|
30
|
-
it("Sums a stereo signal into a mono signal", () => {
|
|
31
|
-
|
|
29
|
+
it("Sums a stereo signal into a mono signal", async () => {
|
|
30
|
+
const buffer = await Offline(
|
|
32
31
|
() => {
|
|
33
32
|
const mono = new Mono().toDestination();
|
|
34
33
|
const signal = StereoSignal(2, 2).connect(mono);
|
|
35
34
|
},
|
|
36
35
|
0.1,
|
|
37
36
|
2
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
37
|
+
);
|
|
38
|
+
expect(buffer.toArray()[0][0]).to.equal(2);
|
|
39
|
+
expect(buffer.toArray()[1][0]).to.equal(2);
|
|
40
|
+
expect(buffer.toArray()[0][100]).to.equal(2);
|
|
41
|
+
expect(buffer.toArray()[1][100]).to.equal(2);
|
|
42
|
+
expect(buffer.toArray()[0][1000]).to.equal(2);
|
|
43
|
+
expect(buffer.toArray()[1][1000]).to.equal(2);
|
|
46
44
|
});
|
|
47
45
|
});
|
|
48
46
|
});
|
|
@@ -42,14 +42,13 @@ describe("PanVol", () => {
|
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
it("can mute the volume", () => {
|
|
46
|
-
|
|
45
|
+
it("can mute the volume", async () => {
|
|
46
|
+
const buffer = await Offline(() => {
|
|
47
47
|
const vol = new PanVol(0).toDestination();
|
|
48
48
|
new Signal(1).connect(vol);
|
|
49
49
|
vol.mute = true;
|
|
50
|
-
}).then((buffer) => {
|
|
51
|
-
expect(buffer.isSilent()).to.be.true;
|
|
52
50
|
});
|
|
51
|
+
expect(buffer.isSilent()).to.be.true;
|
|
53
52
|
});
|
|
54
53
|
});
|
|
55
54
|
});
|
|
@@ -30,56 +30,53 @@ describe("Panner", () => {
|
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
it("pans hard left when the pan is set to -1", () => {
|
|
34
|
-
|
|
33
|
+
it("pans hard left when the pan is set to -1", async () => {
|
|
34
|
+
const buffer = await Offline(
|
|
35
35
|
() => {
|
|
36
36
|
const panner = new Panner(-1).toDestination();
|
|
37
37
|
new Signal(1).connect(panner);
|
|
38
38
|
},
|
|
39
39
|
0.1,
|
|
40
40
|
2
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
41
|
+
);
|
|
42
|
+
const l = buffer.toArray()[0];
|
|
43
|
+
const r = buffer.toArray()[1];
|
|
44
|
+
expect(l[0]).to.be.closeTo(1, 0.01);
|
|
45
|
+
expect(r[0]).to.be.closeTo(0, 0.01);
|
|
47
46
|
});
|
|
48
47
|
|
|
49
|
-
it("pans hard right when the pan is set to 1", () => {
|
|
50
|
-
|
|
48
|
+
it("pans hard right when the pan is set to 1", async () => {
|
|
49
|
+
const buffer = await Offline(
|
|
51
50
|
() => {
|
|
52
51
|
const panner = new Panner(1).toDestination();
|
|
53
52
|
new Signal(1).connect(panner);
|
|
54
53
|
},
|
|
55
54
|
0.1,
|
|
56
55
|
2
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
56
|
+
);
|
|
57
|
+
const l = buffer.toArray()[0];
|
|
58
|
+
const r = buffer.toArray()[1];
|
|
59
|
+
expect(l[0]).to.be.closeTo(0, 0.01);
|
|
60
|
+
expect(r[0]).to.be.closeTo(1, 0.01);
|
|
63
61
|
});
|
|
64
62
|
|
|
65
|
-
it("mixes the signal in equal power when panned center", () => {
|
|
66
|
-
|
|
63
|
+
it("mixes the signal in equal power when panned center", async () => {
|
|
64
|
+
const buffer = await Offline(
|
|
67
65
|
() => {
|
|
68
66
|
const panner = new Panner(0).toDestination();
|
|
69
67
|
new Signal(1).connect(panner);
|
|
70
68
|
},
|
|
71
69
|
0.1,
|
|
72
70
|
2
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
71
|
+
);
|
|
72
|
+
const l = buffer.toArray()[0];
|
|
73
|
+
const r = buffer.toArray()[1];
|
|
74
|
+
expect(l[0]).to.be.closeTo(0.707, 0.01);
|
|
75
|
+
expect(r[0]).to.be.closeTo(0.707, 0.01);
|
|
79
76
|
});
|
|
80
77
|
|
|
81
|
-
it("can chain two panners when channelCount is 2", () => {
|
|
82
|
-
|
|
78
|
+
it("can chain two panners when channelCount is 2", async () => {
|
|
79
|
+
const buffer = await Offline(
|
|
83
80
|
() => {
|
|
84
81
|
const panner1 = new Panner({
|
|
85
82
|
channelCount: 2,
|
|
@@ -89,12 +86,11 @@ describe("Panner", () => {
|
|
|
89
86
|
},
|
|
90
87
|
0.1,
|
|
91
88
|
2
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
89
|
+
);
|
|
90
|
+
const l = buffer.toArray()[0];
|
|
91
|
+
const r = buffer.toArray()[1];
|
|
92
|
+
expect(l[0]).to.be.closeTo(1, 0.01);
|
|
93
|
+
expect(r[0]).to.be.closeTo(0, 0.01);
|
|
98
94
|
});
|
|
99
95
|
});
|
|
100
96
|
});
|
|
@@ -121,7 +121,7 @@ export class Recorder extends ToneAudioNode<RecorderOptions> {
|
|
|
121
121
|
|
|
122
122
|
this._recorder.addEventListener("start", handleStart, false);
|
|
123
123
|
});
|
|
124
|
-
if(this.state === "stopped") {
|
|
124
|
+
if (this.state === "stopped") {
|
|
125
125
|
this._recorder.start();
|
|
126
126
|
} else {
|
|
127
127
|
this._recorder.resume();
|
|
@@ -74,33 +74,30 @@ describe("Volume", () => {
|
|
|
74
74
|
// });
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
it("can lower the volume", () => {
|
|
78
|
-
|
|
77
|
+
it("can lower the volume", async () => {
|
|
78
|
+
const buffer = await Offline(() => {
|
|
79
79
|
const vol = new Volume(-10).toDestination();
|
|
80
80
|
new Signal(1).connect(vol);
|
|
81
|
-
}).then((buffer) => {
|
|
82
|
-
expect(buffer.value()).to.be.closeTo(0.315, 0.01);
|
|
83
81
|
});
|
|
82
|
+
expect(buffer.value()).to.be.closeTo(0.315, 0.01);
|
|
84
83
|
});
|
|
85
84
|
|
|
86
|
-
it("can mute the volume", () => {
|
|
87
|
-
|
|
85
|
+
it("can mute the volume", async () => {
|
|
86
|
+
const buffer = await Offline(() => {
|
|
88
87
|
const vol = new Volume(0).toDestination();
|
|
89
88
|
new Signal(1).connect(vol);
|
|
90
89
|
vol.mute = true;
|
|
91
|
-
}).then((buffer) => {
|
|
92
|
-
expect(buffer.isSilent()).to.equal(true);
|
|
93
90
|
});
|
|
91
|
+
expect(buffer.isSilent()).to.equal(true);
|
|
94
92
|
});
|
|
95
93
|
|
|
96
|
-
it("muted when volume is set to -Infinity", () => {
|
|
97
|
-
|
|
94
|
+
it("muted when volume is set to -Infinity", async () => {
|
|
95
|
+
const buffer = await Offline(() => {
|
|
98
96
|
const vol = new Volume(-Infinity).toDestination();
|
|
99
97
|
new Signal(1).connect(vol);
|
|
100
98
|
expect(vol.mute).to.equal(true);
|
|
101
|
-
}).then((buffer) => {
|
|
102
|
-
expect(buffer.isSilent()).to.equal(true);
|
|
103
99
|
});
|
|
100
|
+
expect(buffer.isSilent()).to.equal(true);
|
|
104
101
|
});
|
|
105
102
|
|
|
106
103
|
it("setting the volume unmutes it and reports itself as unmuted", () => {
|
|
@@ -46,28 +46,24 @@ describe("Gate", () => {
|
|
|
46
46
|
gate.dispose();
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
it("gates the incoming signal when below the threshold", () => {
|
|
50
|
-
|
|
49
|
+
it("gates the incoming signal when below the threshold", async () => {
|
|
50
|
+
const buffer = await Offline(() => {
|
|
51
51
|
const gate = new Gate(-9);
|
|
52
52
|
const sig = new Signal(-12, "decibels");
|
|
53
53
|
sig.connect(gate);
|
|
54
54
|
gate.toDestination();
|
|
55
|
-
}).then((buffer) => {
|
|
56
|
-
expect(buffer.isSilent()).to.be.true;
|
|
57
55
|
});
|
|
56
|
+
expect(buffer.isSilent()).to.be.true;
|
|
58
57
|
});
|
|
59
58
|
|
|
60
|
-
it("passes the incoming signal when above the threshold", () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
gate.toDestination();
|
|
67
|
-
}).then((buffer) => {
|
|
68
|
-
expect(buffer.min()).to.be.above(0);
|
|
69
|
-
});
|
|
59
|
+
it("passes the incoming signal when above the threshold", async () => {
|
|
60
|
+
const buffer = await Offline(() => {
|
|
61
|
+
const gate = new Gate(-11);
|
|
62
|
+
const sig = new Signal(-10, "decibels");
|
|
63
|
+
sig.connect(gate);
|
|
64
|
+
gate.toDestination();
|
|
70
65
|
});
|
|
66
|
+
expect(buffer.min()).to.be.above(0);
|
|
71
67
|
});
|
|
72
68
|
});
|
|
73
69
|
});
|
|
@@ -74,23 +74,21 @@ describe("AmplitudeEnvelope", () => {
|
|
|
74
74
|
ampEnv.dispose();
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
it("passes no signal before being triggered", () => {
|
|
78
|
-
|
|
77
|
+
it("passes no signal before being triggered", async () => {
|
|
78
|
+
const buffer = await Offline(() => {
|
|
79
79
|
const ampEnv = new AmplitudeEnvelope().toDestination();
|
|
80
80
|
new Signal(1).connect(ampEnv);
|
|
81
|
-
}).then((buffer) => {
|
|
82
|
-
expect(buffer.isSilent()).to.be.true;
|
|
83
81
|
});
|
|
82
|
+
expect(buffer.isSilent()).to.be.true;
|
|
84
83
|
});
|
|
85
84
|
|
|
86
|
-
it("passes signal once triggered", () => {
|
|
87
|
-
|
|
85
|
+
it("passes signal once triggered", async () => {
|
|
86
|
+
const buffer = await Offline(() => {
|
|
88
87
|
const ampEnv = new AmplitudeEnvelope().toDestination();
|
|
89
88
|
new Signal(1).connect(ampEnv);
|
|
90
89
|
ampEnv.triggerAttack(0.1);
|
|
91
|
-
}, 0.2)
|
|
92
|
-
|
|
93
|
-
});
|
|
90
|
+
}, 0.2);
|
|
91
|
+
expect(buffer.getTimeOfFirstSound()).to.be.closeTo(0.1, 0.001);
|
|
94
92
|
});
|
|
95
93
|
});
|
|
96
94
|
});
|