Skip to content

Commit 0de645f

Browse files
authored
Merge pull request #716 from Abhijay007/Abhijay007-Tests/gain-update
(Chore) : Added test to set the output level of gain Node
2 parents 2591c10 + 1012647 commit 0de645f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/tests/p5.Gain.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ describe('p5.Gain', function () {
3636
gain.connect(filter);
3737
gain.connect(filter.input);
3838
});
39+
it('can set the output level of gain node', (done) => {
40+
let osc = new p5.Oscillator('sine');
41+
let mainGainNode = new p5.Gain();
42+
let amplitude = new p5.Amplitude();
43+
44+
osc.amp(1);
45+
osc.start();
46+
osc.disconnect();
47+
48+
mainGainNode.setInput(osc);
49+
amplitude.setInput(mainGainNode);
50+
51+
mainGainNode.amp(0.5);
52+
setTimeout(function () {
53+
expect(amplitude.getLevel()).to.be.closeTo(0.25, 0.125);
54+
done();
55+
}, 100);
56+
});
3957
it('can disconnect', function () {
4058
let filter = new p5.Filter();
4159
gain.connect(filter);

0 commit comments

Comments
 (0)