Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update dsp tests for single-sample

  • Loading branch information...
commit 4d60da637a14d811c3a6041a80507f3ffa5178ae 1 parent b8f8d20
@oampo authored
View
28 tests/dsp/AllPassFilter.js
@@ -12,28 +12,16 @@ function testAPF() {
sine.connect(apf);
apf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ apf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data);
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer);
}
test("All Pass Filter", testAPF);
-
-function testEmpty() {
- var audiolet = new Audiolet();
- var apf = new AllPassFilter(audiolet);
- var node = new Introspector(audiolet, 1, 0);
- apf.connect(node);
-
- node.tick(8192, 0);
-
- Assert.assertEquals(node.inputBuffers[0].isEmpty, true, "Buffer empty");
-}
-
-test("Empty input", testEmpty);
View
72 tests/dsp/BandPassFilter.js
@@ -12,15 +12,16 @@ function testBPF() {
sine.connect(bpf);
bpf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ bpf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data);
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer);
}
test("Band Pass Filter", testBPF);
@@ -35,15 +36,16 @@ function testFilteringLows() {
sine.connect(bpf);
bpf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ bpf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data, -0.1, 0.1); // Check for low amplitude
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer, -0.1, 0.1); // Check for low amplitude
}
test("Is Filtering Lows", testFilteringLows);
@@ -58,14 +60,16 @@ function testPassingCenter() {
sine.connect(bpf);
bpf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ bpf.tick();
+ recorder.tick();
+
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertAudibleValues(data);
- Assert.assertValuesReach(data); // Check for high amplitude
+ var buffer = recorder.buffers[0][0];
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesReach(buffer); // Check for high amplitude
}
test("Is Passing Center", testPassingCenter);
@@ -80,28 +84,16 @@ function testFilteringHighs() {
sine.connect(bpf);
bpf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ bpf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data, -0.1, 0.1); // Check for low amplitude
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer, -0.1, 0.1); // Check for low amplitude
}
test("Is Filtering Highs", testFilteringHighs);
-
-function testEmpty() {
- var audiolet = new Audiolet();
- var bpf = new BandPassFilter(audiolet);
- var node = new Introspector(audiolet, 1, 0);
- bpf.connect(node);
-
- node.tick(8192, 0);
-
- Assert.assertEquals(node.inputBuffers[0].isEmpty, true, "Buffer empty");
-}
-
-test("Empty input", testEmpty);
View
68 tests/dsp/BandRejectFilter.js
@@ -12,15 +12,16 @@ function testBRF() {
sine.connect(brf);
brf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ brf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data);
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer);
}
test("Band Reject Filter", testBRF);
@@ -36,14 +37,15 @@ function testPassingLows() {
sine.connect(brf);
brf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ brf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertAudibleValues(data);
- Assert.assertValuesReach(data); // Check for high amplitude
+ var buffer = recorder.buffers[0][0];
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesReach(buffer); // Check for high amplitude
}
test("Is Passing Lows", testPassingLows);
@@ -58,15 +60,16 @@ function testFilteringCenter() {
sine.connect(brf);
brf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ brf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data, -0.5, 0.5); // Check for low amplitude
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer, -0.5, 0.5); // Check for low amplitude
}
test("Is Filtering Center", testFilteringCenter);
@@ -81,27 +84,16 @@ function testPassingHighs() {
sine.connect(brf);
brf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ brf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertAudibleValues(data);
- Assert.assertValuesReach(data); // Check for high amplitude
+ var buffer = recorder.buffers[0][0];
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesReach(buffer); // Check for high amplitude
}
test("Is Passing Highs", testPassingHighs);
-function testEmpty() {
- var audiolet = new Audiolet();
- var brf = new BandRejectFilter(audiolet);
- var node = new Introspector(audiolet, 1, 0);
- brf.connect(node);
-
- node.tick(8192, 0);
-
- Assert.assertEquals(node.inputBuffers[0].isEmpty, true, "Buffer empty");
-}
-
-test("Empty input", testEmpty);
View
56 tests/dsp/HighPassFilter.js
@@ -12,15 +12,16 @@ function testHPF() {
sine.connect(hpf);
hpf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ hpf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data);
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer);
}
test("High Pass Filter", testHPF);
@@ -35,15 +36,16 @@ function testFilteringLows() {
sine.connect(hpf);
hpf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ hpf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data, -0.1, 0.1); // Check for low amplitude
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer, -0.1, 0.1); // Check for low amplitude
}
test("Is Filtering Lows", testFilteringLows);
@@ -58,27 +60,15 @@ function testPassingHighs() {
sine.connect(hpf);
hpf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ hpf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertAudibleValues(data);
- Assert.assertValuesReach(data); // Check for high amplitude
+ var buffer = recorder.buffers[0][0];
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesReach(buffer); // Check for high amplitude
}
test("Is Passing Highs", testPassingHighs);
-
-function testEmpty() {
- var audiolet = new Audiolet();
- var hpf = new HighPassFilter(audiolet);
- var node = new Introspector(audiolet, 1, 0);
- hpf.connect(node);
-
- node.tick(8192, 0);
-
- Assert.assertEquals(node.inputBuffers[0].isEmpty, true, "Buffer empty");
-}
-
-test("Empty input", testEmpty);
View
55 tests/dsp/LowPassFilter.js
@@ -12,15 +12,16 @@ function testLPF() {
sine.connect(lpf);
lpf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ lpf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data);
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer);
}
test("Low Pass Filter", testLPF);
@@ -35,15 +36,16 @@ function testFilteringHighs() {
sine.connect(lpf);
lpf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ lpf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data, -0.1, 0.1); // Check for low amplitude
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer, -0.1, 0.1); // Check for low amplitude
}
test("Is Filtering Highs", testFilteringHighs);
@@ -58,27 +60,16 @@ function testPassingLows() {
sine.connect(lpf);
lpf.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ lpf.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertAudibleValues(data);
- Assert.assertValuesReach(data); // Check for high amplitude
+ var buffer = recorder.buffers[0][0];
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesReach(buffer); // Check for high amplitude
}
test("Is Passing Lows", testPassingLows);
-function testEmpty() {
- var audiolet = new Audiolet();
- var lpf = new LowPassFilter(audiolet);
- var node = new Introspector(audiolet, 1, 0);
- lpf.connect(node);
-
- node.tick(8192, 0);
-
- Assert.assertEquals(node.inputBuffers[0].isEmpty, true, "Buffer empty");
-}
-
-test("Empty input", testEmpty);
View
12 tests/dsp/Saw.js
@@ -10,14 +10,14 @@ function testSaw() {
saw.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ saw.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data);
+ var buffer = recorder.buffers[0][0];
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer);
}
test("Saw", testSaw);
View
14 tests/dsp/Sine.js
@@ -10,15 +10,15 @@ function testSine() {
sine.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ sine.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data);
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer);
}
test("Sine", testSine);
View
12 tests/dsp/Square.js
@@ -10,14 +10,14 @@ function testSquare() {
square.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ square.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data);
+ var buffer = recorder.buffers[0][0];
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer);
}
test("Square", testSquare);
View
14 tests/dsp/Triangle.js
@@ -10,15 +10,15 @@ function testTriangle() {
triangle.connect(recorder);
- for (var i=0; i<10; i++) {
- recorder.tick(8192, i);
+ for (var i=0; i<81920; i++) {
+ triangle.tick();
+ recorder.tick();
}
- var buffer = recorder.buffers[0];
- var data = buffer.getChannelData(0);
- Assert.assertContinuous(data);
- Assert.assertAudibleValues(data);
- Assert.assertValuesInRange(data);
+ var buffer = recorder.buffers[0][0];
+ Assert.assertContinuous(buffer);
+ Assert.assertAudibleValues(buffer);
+ Assert.assertValuesInRange(buffer);
}
test("Triangle", testTriangle);
Please sign in to comment.
Something went wrong with that request. Please try again.