From c1f0b81fc5f152ef72708b233b668f46fd099937 Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Tue, 22 Jul 2014 11:29:44 -0400 Subject: [PATCH] increased recording size and wait time trying to reduce performance caused errors --- test/tests/Signal.js | 48 ++++++------- test/tests/SignalComparison.js | 30 ++++---- test/tests/SignalMath.js | 124 ++++----------------------------- 3 files changed, 51 insertions(+), 151 deletions(-) diff --git a/test/tests/Signal.js b/test/tests/Signal.js index 5583d71d..99457c7b 100644 --- a/test/tests/Signal.js +++ b/test/tests/Signal.js @@ -36,8 +36,8 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho expect(sig.getValue()).to.equal(10); var recorder = new Recorder(); sig.connect(recorder); - recorder.record(0.1, 0.05, function(buffers){ - buffer = buffers[0]; + recorder.record(0.1, 0.1, function(buffers){ + var buffer = buffers[0]; var reached100 = false; for (var i = 0; i < buffer.length; i++){ if (buffer[i] === 100){ @@ -53,16 +53,14 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho it("can change value with sample accurate timing", function(done){ var changeSignal = new Signal(0); - var waitTime = 0.03; - changeSignal.setValueAtTime(1, "+"+waitTime);//ramp after 50ms + changeSignal.setValueAtTime(1, "+0.15"); var recorder = new Recorder(); changeSignal.connect(recorder); - var delayTime = 0.05; - recorder.record(0.1, delayTime, function(buffers){ - buffer = buffers[0]; + recorder.record(0.1, 0.1, function(buffers){ + var buffer = buffers[0]; for (var i = 0; i < buffer.length; i++){ if (buffer[i] === 1){ - expect(changeSignal.samplesToSeconds(i)).is.closeTo(delayTime - waitTime, 0.01); + expect(changeSignal.samplesToSeconds(i)).is.closeTo(0.1, 0.01); changeSignal.dispose(); recorder.dispose(); done(); @@ -81,7 +79,7 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho signalSync.noGC(); var recorder = new Recorder(); signalSync.connect(recorder); - recorder.record(0.1, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; for (var i = 0; i < buffer.length; i++){ expect(buffer[i]).to.equal(4); @@ -98,14 +96,14 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho sig1.noGC(); var recorder = new Recorder(1); sig1.connect(recorder); - var waitTime = 0.03; + var waitTime = 0.15; expect(sig1.getValue()).to.equal(-10); sig1.linearRampToValueNow(1, waitTime); - recorder.record(0.1, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; for (var i = 0; i < buffer.length; i++){ if (buffer[i] === 1){ - expect(sig1.samplesToSeconds(i)).is.closeTo(waitTime, 0.01); + expect(sig1.samplesToSeconds(i)).is.closeTo(0.1, 0.01); done(); sig1.dispose(); break; @@ -118,7 +116,7 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho //MERGE describe("Tone.Merge", function(){ - this.timeout(500); + this.timeout(1000); it("can be created and disposed", function(){ var mer = new Merge(); @@ -134,7 +132,7 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho sigR.connect(merger.right); var recorder = new Recorder(2); merger.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var lBuffer = buffers[0]; var rBuffer = buffers[1]; //get the left buffer and check that all values are === 1 @@ -149,7 +147,7 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho //SCALE describe("Tone.Split", function(){ - this.timeout(500); + this.timeout(1000); it("can be created and disposed", function(){ var split = new Split(); @@ -169,14 +167,14 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho var recorderR = new Recorder(); split.left.connect(recorderL); split.right.connect(recorderR); - recorderL.record(0.05, 0.1, function(buffers){ + recorderL.record(0.1, 0.1, function(buffers){ var lBuffer = buffers[0]; for (var i = 0; i < lBuffer.length; i++){ expect(lBuffer[i]).to.equal(1); } }); - recorderR.record(0.05, 0.1, function(buffers){ - var rBuffer = recorderR.getFloat32Array()[0]; + recorderR.record(0.1, 0.1, function(buffers){ + var rBuffer = buffers[0]; for (var j = 0; j < rBuffer.length; j++){ expect(rBuffer[j]).to.equal(2); } @@ -188,7 +186,7 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho //THRESHOLD describe("Tone.Threshold", function(){ - this.timeout(500); + this.timeout(1000); it("can be created and disposed", function(){ var thresh = new Threshold(); @@ -201,7 +199,7 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho signal.connect(thresh); var recorder = new Recorder(); thresh.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -219,7 +217,7 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho signal.connect(thresh); var recorder = new Recorder(); thresh.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -237,7 +235,7 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho signal.connect(thresh); var recorder = new Recorder(); thresh.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -253,7 +251,7 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho //Gate describe("Tone.Gate", function(){ - this.timeout(500); + this.timeout(1000); it("can be created and disposed", function(){ var sw = new Gate(); @@ -266,7 +264,7 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho signal.connect(gate); var recorder = new Recorder(); gate.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -285,7 +283,7 @@ function(core, chai, Recorder, Signal, Oscillator, Merge, Split, Master, Thresho gate.open(); var recorder = new Recorder(); gate.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ diff --git a/test/tests/SignalComparison.js b/test/tests/SignalComparison.js index c48fcedb..ca91defe 100644 --- a/test/tests/SignalComparison.js +++ b/test/tests/SignalComparison.js @@ -9,7 +9,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le //EQUALS 0 describe("Tone.EqualZero", function(){ - this.timeout(500); + this.timeout(1000); it("can be created and disposed", function(){ var ez = new EqualZero(); @@ -22,7 +22,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le signal.connect(ez); var recorder = new Recorder(); ez.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -40,7 +40,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le signal.connect(ez); var recorder = new Recorder(); ez.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -58,7 +58,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le signal.connect(ez); var recorder = new Recorder(); ez.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -74,7 +74,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le //EQUALS describe("Tone.Equal", function(){ - this.timeout(500); + this.timeout(1000); it("can be created and disposed", function(){ var eq = new Equal(3); @@ -87,7 +87,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le signal.connect(eq); var recorder = new Recorder(); eq.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -105,7 +105,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le signal.connect(eq); var recorder = new Recorder(); eq.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -121,7 +121,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le //GREATER THAN describe("Tone.GreaterThan", function(){ - this.timeout(500); + this.timeout(1000); it("can be created and disposed", function(){ var gt = new GreaterThan(); @@ -134,7 +134,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le signal.connect(gt); var recorder = new Recorder(); gt.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -152,7 +152,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le signal.connect(gt); var recorder = new Recorder(); gt.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -171,7 +171,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le gt.setValue(50); var recorder = new Recorder(); gt.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -186,7 +186,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le //LESS THAN describe("Tone.LessThan", function(){ - this.timeout(500); + this.timeout(1000); it("can be created and disposed", function(){ var lt = new LessThan(2); @@ -199,7 +199,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le signal.connect(lt); var recorder = new Recorder(); lt.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.lenlth; i++){ @@ -217,7 +217,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le signal.connect(lt); var recorder = new Recorder(); lt.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.lenlth; i++){ @@ -235,7 +235,7 @@ function(core, chai, Recorder, Signal, Master, EqualZero, Equal, GreaterThan, Le signal.connect(lt); var recorder = new Recorder(); lt.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.lenlth; i++){ diff --git a/test/tests/SignalMath.js b/test/tests/SignalMath.js index 656c4bb6..8093a759 100644 --- a/test/tests/SignalMath.js +++ b/test/tests/SignalMath.js @@ -6,107 +6,9 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, Master.mute(); - //SIGNAL - describe("Tone.Signal", function(){ - this.timeout(1000); - - var signal = new Signal(0); - signal.toMaster(); - - after(function(){ - signal.dispose(); - }); - - it("can be created and disposed", function(){ - var s = new Signal(); - s.dispose(); - }); - - it("can start with a value initially", function(){ - expect(signal.getValue()).to.equal(0); - }); - - it("can set a value", function(){ - signal.setValue(10); - expect(signal.getValue()).to.equal(10); - }); - - it("can set a value in the future", function(done){ - signal.setValueAtTime(100, "+0.1"); - expect(signal.getValue()).to.equal(10); - var interval = setInterval(function(){ - if (signal.getValue() === 100){ - clearInterval(interval); - done(); - } - }, 10); - }); - - it("can change value with sample accurate timing", function(done){ - var changeSignal = new Signal(0); - var waitTime = 0.03; - changeSignal.setValueAtTime(1, "+"+waitTime);//ramp after 50ms - var recorder = new Recorder(); - changeSignal.connect(recorder); - var delayTime = 0.05; - recorder.record(0.1, delayTime, function(buffers){ - buffer = buffers[0]; - for (var i = 0; i < buffer.length; i++){ - if (buffer[i] === 1){ - expect(changeSignal.samplesToSeconds(i)).is.closeTo(delayTime - waitTime, 0.01); - changeSignal.dispose(); - recorder.dispose(); - done(); - break; - } - } - }); - }); - - it("can sync to another signal", function(done){ - var syncTo = new Signal(1); - var signalSync = new Signal(2); - signalSync.sync(syncTo); - syncTo.setValue(2); - syncTo.noGC(); - signalSync.noGC(); - var recorder = new Recorder(); - signalSync.connect(recorder); - recorder.record(0.1, 0.05, function(buffers){ - var buffer = buffers[0]; - for (var i = 0; i < buffer.length; i++){ - expect(buffer[i]).to.equal(4); - } - signalSync.dispose(); - recorder.dispose(); - done(); - }); - }); - - it("can ramp from the current value", function(done){ - signal.setValue(-10); - signal.noGC(); - var recorder = new Recorder(1); - signal.connect(recorder); - var waitTime = 0.03; - expect(signal.getValue()).to.equal(-10); - signal.linearRampToValueNow(1, waitTime); - recorder.record(0.1, 0.05, function(buffers){ - var buffer = buffers[0]; - for (var i = 0; i < buffer.length; i++){ - if (buffer[i] === 1){ - expect(signal.samplesToSeconds(i)).is.closeTo(waitTime, 0.01); - done(); - break; - } - } - }); - }); - }); - //ADD describe("Tone.Add", function(){ - this.timeout(500); + this.timeout(1000); var recorder = new Recorder(); @@ -124,7 +26,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, var adder = new Add(3); signal.connect(adder); adder.connect(recorder); - recorder.record(0.1, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -140,7 +42,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, signal.connect(adder); var recorder = new Recorder(); adder.connect(recorder); - recorder.record(0.1, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -153,7 +55,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, //MULTIPLY describe("Tone.Multiply", function(){ - this.timeout(500); + this.timeout(1000); it("can be created and disposed", function(){ var m = new Multiply(1); @@ -166,7 +68,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, signal.connect(mult); var recorder = new Recorder(); mult.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -181,7 +83,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, //SCALE describe("Tone.Scale", function(){ - this.timeout(500); + this.timeout(1000); it("can be created and disposed", function(){ var s = new Scale(0, 10); @@ -196,7 +98,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, osc.connect(scale); var recorder = new Recorder(); scale.connect(recorder); - recorder.record(0.05, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -209,7 +111,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, //ADD describe("Tone.Abs", function(){ - this.timeout(500); + this.timeout(1000); var recorder = new Recorder(); @@ -228,7 +130,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, signal.connect(abs); signal.noGC(); abs.connect(recorder); - recorder.record(0.1, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -247,7 +149,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, signal.connect(abs); var recorder = new Recorder(); abs.connect(recorder); - recorder.record(0.1, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -262,7 +164,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, //NEGATE describe("Tone.Negate", function(){ - this.timeout(500); + this.timeout(1000); var recorder = new Recorder(); @@ -281,7 +183,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, var neg = new Negate(); signal.connect(neg); neg.connect(recorder); - recorder.record(0.1, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){ @@ -300,7 +202,7 @@ function(core, chai, Recorder, Signal, Add, Multiply, Scale, Oscillator, Master, signal.connect(neg); var recorder = new Recorder(); neg.connect(recorder); - recorder.record(0.1, 0.05, function(buffers){ + recorder.record(0.1, 0.1, function(buffers){ var buffer = buffers[0]; //get the left buffer and check that all values are === 1 for (var i = 0; i < buffer.length; i++){