Skip to content

Commit 54c4566

Browse files
(Gsoc'21)🔨Corrects broken tests part-1
1 parent 89e7866 commit 54c4566

File tree

8 files changed

+854
-495
lines changed

8 files changed

+854
-495
lines changed

lib/p5.sound.js

Lines changed: 809 additions & 463 deletions
Large diffs are not rendered by default.

lib/p5.sound.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/p5.sound.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/p5.sound.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/looper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ class Score {
387387
constructor() {
388388
// for all of the arguments
389389
this.parts = [];
390-
this.currentPart = new Array(arguments.length);;
390+
this.currentPart = new Array(arguments.length);
391391

392392
var thisScore = this;
393393
for (var i in arguments) {
@@ -396,7 +396,7 @@ class Score {
396396
this.parts[i].onended = function () {
397397
thisScore.resetPart(i);
398398
playNextPart(thisScore);
399-
};
399+
};
400400
}
401401
this.looping = false;
402402
}

src/soundRecorder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class SoundRecorder {
8888
this._inputChannels = 2;
8989
this._outputChannels = 2; // stereo output, even if input is mono
9090

91-
const workletBufferSize = safeBufferSize(1024);
91+
const workletBufferSize = (this.bufferSize = safeBufferSize(1024));
9292

9393
this._workletNode = new AudioWorkletNode(
9494
ac,

test/tests/p5.EQ.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,30 @@ describe('p5.EQ', function () {
3636
expect(eq.bands[2].biquad.type).to.equal('peaking');
3737
});
3838

39-
it('a bands gain value can be changed', function () {
39+
it("a band's gain value can be changed", function () {
4040
const eq = new p5.EQ(8);
4141
expect(eq.bands[2].gain()).to.equal(0);
4242
eq.bands[2].gain(30);
4343
expect(eq.bands[2].gain()).to.equal(30);
4444
});
4545

46-
it('a bands freq value can be changed', function () {
46+
it('a band has correct default value', function () {
47+
const eq = new p5.EQ(8);
48+
setTimeout(() => {
49+
expect(eq.bands[0].freq()).to.equal(100);
50+
}, 100);
51+
});
52+
53+
it("a band's freq value can be changed", function () {
4754
const eq = new p5.EQ(8);
48-
expect(eq.bands[0].freq()).to.equal(100);
4955
eq.bands[0].freq(200);
50-
expect(eq.bands[0].gain()).to.equal(0);
51-
expect(eq.bands[0].freq()).to.equal(200);
56+
setTimeout(() => {
57+
expect(eq.bands[0].gain()).to.equal(0);
58+
expect(eq.bands[0].freq()).to.equal(200);
59+
}, 100);
5260
});
5361

54-
it('a bands type can be changed', function () {
62+
it("a band's type can be changed", function () {
5563
const eq = new p5.EQ();
5664
expect(eq.bands[2]._untoggledType).to.equal('peaking');
5765
eq.bands[2].setType('highshelf');

test/tests/p5.SoundRecorder.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,21 @@ describe('p5.SoundRecorder', function () {
5353

5454
const mic = new p5.AudioIn();
5555
mic.start(function () {
56+
recorder.setInput(mic);
5657
const outputSoundFile = new p5.SoundFile();
57-
recorder.record(outputSoundFile, recordingDuration, function () {
58-
expect(outputSoundFile.duration()).to.eq(recordingDuration);
59-
60-
const outputChannel = outputSoundFile.buffer.getChannelData(0);
61-
expect(outputChannel[0]).to.not.eq(0);
62-
63-
outputSoundFile.dispose();
64-
mic.dispose();
65-
p5.prototype.outputVolume(0);
66-
done();
67-
});
58+
setTimeout(() => {
59+
recorder.record(outputSoundFile, recordingDuration, function () {
60+
expect(outputSoundFile.duration()).to.eq(recordingDuration);
61+
62+
const outputChannel = outputSoundFile.buffer.getChannelData(0);
63+
expect(outputChannel[0]).to.not.eq(0);
64+
65+
outputSoundFile.dispose();
66+
mic.dispose();
67+
p5.prototype.outputVolume(0);
68+
done();
69+
});
70+
}, 100);
6871
});
6972
});
7073

@@ -106,16 +109,18 @@ describe('p5.SoundRecorder', function () {
106109
inputSoundFile.connect();
107110
inputSoundFile.loop();
108111
recorder.setInput();
109-
recorder.record(outputSoundFile, recordingDuration, function () {
110-
expect(outputSoundFile.duration()).to.eq(recordingDuration);
112+
setTimeout(() => {
113+
recorder.record(outputSoundFile, recordingDuration, function () {
114+
expect(outputSoundFile.duration()).to.eq(recordingDuration);
111115

112-
const outputChannel = outputSoundFile.buffer.getChannelData(0);
113-
expect(outputChannel[0]).to.not.eq(0);
116+
const outputChannel = outputSoundFile.buffer.getChannelData(0);
117+
expect(outputChannel[0]).to.not.eq(0);
114118

115-
outputSoundFile.dispose();
116-
p5.prototype.outputVolume(0);
117-
done();
118-
});
119+
outputSoundFile.dispose();
120+
p5.prototype.outputVolume(0);
121+
done();
122+
});
123+
}, 10);
119124
});
120125

121126
it('can save a recorded buffer to a .wav file', function (done) {

0 commit comments

Comments
 (0)