mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
updated tests with global recorder settings
This commit is contained in:
parent
4b51032c7a
commit
0103735589
2 changed files with 60 additions and 85 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* global it, describe, after */
|
/* global it, describe, recorderDelay, recorderDuration, maxTimeout, after*/
|
||||||
|
|
||||||
define(["tests/Core", "chai", "Tone/component/DryWet", "Tone/core/Master", "Tone/signal/Signal",
|
define(["tests/Core", "chai", "Tone/component/DryWet", "Tone/core/Master", "Tone/signal/Signal",
|
||||||
"Tone/component/Recorder", "Tone/component/Panner", "Tone/component/LFO", "Tone/component/Gate",
|
"Tone/component/Recorder", "Tone/component/Panner", "Tone/component/LFO", "Tone/component/Gate",
|
||||||
|
@ -11,7 +11,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
Master.mute();
|
Master.mute();
|
||||||
|
|
||||||
describe("Tone.DryWet", function(){
|
describe("Tone.DryWet", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
var dryWet, drySignal, wetSignal, recorder;
|
var dryWet, drySignal, wetSignal, recorder;
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
|
|
||||||
it("pass 100% dry signal", function(done){
|
it("pass 100% dry signal", function(done){
|
||||||
dryWet = new DryWet();
|
dryWet = new DryWet();
|
||||||
dryWet.toMaster();
|
|
||||||
drySignal = new Signal(10);
|
drySignal = new Signal(10);
|
||||||
wetSignal = new Signal(20);
|
wetSignal = new Signal(20);
|
||||||
drySignal.connect(dryWet.dry);
|
drySignal.connect(dryWet.dry);
|
||||||
|
@ -30,23 +29,22 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
recorder = new Recorder();
|
recorder = new Recorder();
|
||||||
dryWet.connect(recorder);
|
dryWet.connect(recorder);
|
||||||
dryWet.setDry(1);
|
dryWet.setDry(1);
|
||||||
recorder.record(0.05, 0.1, function(buffers){
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
var buffer = buffers[0];
|
var buffer = buffers[0];
|
||||||
for (var i = 0; i < buffer.length; i++){
|
for (var i = 0; i < buffer.length; i++){
|
||||||
expect(buffer[i]).to.equal(10);
|
expect(buffer[i]).to.equal(10);
|
||||||
}
|
}
|
||||||
done();
|
|
||||||
dryWet.dispose();
|
dryWet.dispose();
|
||||||
drySignal.dispose();
|
drySignal.dispose();
|
||||||
wetSignal.dispose();
|
wetSignal.dispose();
|
||||||
recorder.dispose();
|
recorder.dispose();
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("pass 100% wet signal", function(done){
|
it("pass 100% wet signal", function(done){
|
||||||
dryWet = new DryWet();
|
dryWet = new DryWet();
|
||||||
dryWet.toMaster();
|
|
||||||
drySignal = new Signal(10);
|
drySignal = new Signal(10);
|
||||||
wetSignal = new Signal(20);
|
wetSignal = new Signal(20);
|
||||||
drySignal.connect(dryWet.dry);
|
drySignal.connect(dryWet.dry);
|
||||||
|
@ -54,7 +52,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
recorder = new Recorder();
|
recorder = new Recorder();
|
||||||
dryWet.connect(recorder);
|
dryWet.connect(recorder);
|
||||||
dryWet.setWet(1);
|
dryWet.setWet(1);
|
||||||
recorder.record(0.05, 0.1, function(buffers){
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
var buffer = buffers[0];
|
var buffer = buffers[0];
|
||||||
for (var i = 0; i < buffer.length; i++){
|
for (var i = 0; i < buffer.length; i++){
|
||||||
expect(buffer[i]).to.equal(20);
|
expect(buffer[i]).to.equal(20);
|
||||||
|
@ -69,17 +67,14 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
|
|
||||||
it("can mix two signals", function(done){
|
it("can mix two signals", function(done){
|
||||||
dryWet = new DryWet();
|
dryWet = new DryWet();
|
||||||
dryWet.toMaster();
|
|
||||||
drySignal = new Signal(10);
|
drySignal = new Signal(10);
|
||||||
drySignal.noGC();
|
|
||||||
wetSignal = new Signal(20);
|
wetSignal = new Signal(20);
|
||||||
drySignal.connect(dryWet.dry);
|
drySignal.connect(dryWet.dry);
|
||||||
wetSignal.connect(dryWet.wet);
|
wetSignal.connect(dryWet.wet);
|
||||||
wetSignal.noGC();
|
|
||||||
recorder = new Recorder();
|
recorder = new Recorder();
|
||||||
dryWet.connect(recorder);
|
dryWet.connect(recorder);
|
||||||
dryWet.setWet(1);
|
dryWet.setWet(1);
|
||||||
recorder.record(0.05, 0.1, function(buffers){
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
var buffer = buffers[0];
|
var buffer = buffers[0];
|
||||||
for (var i = 0; i < buffer.length; i++){
|
for (var i = 0; i < buffer.length; i++){
|
||||||
expect(buffer[i]).to.equal(20);
|
expect(buffer[i]).to.equal(20);
|
||||||
|
@ -91,41 +86,12 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
recorder.dispose();
|
recorder.dispose();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can ramp from dry to wet", function(done){
|
|
||||||
dryWet = new DryWet();
|
|
||||||
drySignal = new Signal(10);
|
|
||||||
wetSignal = new Signal(20);
|
|
||||||
drySignal.connect(dryWet.dry);
|
|
||||||
wetSignal.connect(dryWet.wet);
|
|
||||||
recorder = new Recorder();
|
|
||||||
recorder.toMaster();
|
|
||||||
dryWet.connect(recorder);
|
|
||||||
dryWet.setWet(0);
|
|
||||||
dryWet.setWet(1, 0.05);
|
|
||||||
recorder.record(0.1, 0.0, function(buffers){
|
|
||||||
var buffer = buffers[0];
|
|
||||||
expect(buffer[0]).to.be.closeTo(10, 0.01);
|
|
||||||
for (var i = 0; i < buffer.length; i++){
|
|
||||||
if (buffer[i] === 20){
|
|
||||||
expect(recorder.samplesToSeconds(i)).to.be.closeTo(0.05, 0.01);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
done();
|
|
||||||
dryWet.dispose();
|
|
||||||
drySignal.dispose();
|
|
||||||
wetSignal.dispose();
|
|
||||||
recorder.dispose();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Tone.Recorder", function(){
|
describe("Tone.Recorder", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
var recorder = new Recorder();
|
var recorder = new Recorder();
|
||||||
recorder.toMaster();
|
|
||||||
|
|
||||||
after(function(){
|
after(function(){
|
||||||
recorder.dispose();
|
recorder.dispose();
|
||||||
|
@ -139,7 +105,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
it("can record an incoming signal", function(done){
|
it("can record an incoming signal", function(done){
|
||||||
var sig = new Signal(1);
|
var sig = new Signal(1);
|
||||||
sig.connect(recorder);
|
sig.connect(recorder);
|
||||||
recorder.record(0.001, 0.1, function(buffers){
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
var buffer = buffers[0];
|
var buffer = buffers[0];
|
||||||
for (var i = 0; i < buffer.length; i++){
|
for (var i = 0; i < buffer.length; i++){
|
||||||
expect(buffer[i]).to.equal(1);
|
expect(buffer[i]).to.equal(1);
|
||||||
|
@ -151,10 +117,9 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Tone.Panner", function(){
|
describe("Tone.Panner", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
var panner = new Panner();
|
var panner = new Panner();
|
||||||
panner.toMaster();
|
|
||||||
|
|
||||||
after(function(){
|
after(function(){
|
||||||
panner.dispose();
|
panner.dispose();
|
||||||
|
@ -172,7 +137,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
panner.connect(recorder);
|
panner.connect(recorder);
|
||||||
//pan hard right
|
//pan hard right
|
||||||
panner.setPan(1);
|
panner.setPan(1);
|
||||||
recorder.record(0.01, 0.1, function(buffers){
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
var bufferL = buffers[0];
|
var bufferL = buffers[0];
|
||||||
var bufferR = buffers[1];
|
var bufferR = buffers[1];
|
||||||
for (var i = 0; i < bufferL.length; i++){
|
for (var i = 0; i < bufferL.length; i++){
|
||||||
|
@ -187,7 +152,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Tone.LFO", function(){
|
describe("Tone.LFO", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
it("can be created and disposed", function(){
|
it("can be created and disposed", function(){
|
||||||
var l = new LFO();
|
var l = new LFO();
|
||||||
|
@ -206,7 +171,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
lfo.start();
|
lfo.start();
|
||||||
var recorder = new Recorder();
|
var recorder = new Recorder();
|
||||||
lfo.connect(recorder);
|
lfo.connect(recorder);
|
||||||
recorder.record(0.01, 0.1, function(buffers){
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
var buffer = buffers[0];
|
var buffer = buffers[0];
|
||||||
for (var i = 0; i < buffer.length; i++){
|
for (var i = 0; i < buffer.length; i++){
|
||||||
expect(buffer[i]).to.be.within(10, 20);
|
expect(buffer[i]).to.be.within(10, 20);
|
||||||
|
@ -223,7 +188,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
lfo.setMin(15);
|
lfo.setMin(15);
|
||||||
var recorder = new Recorder();
|
var recorder = new Recorder();
|
||||||
lfo.connect(recorder);
|
lfo.connect(recorder);
|
||||||
recorder.record(0.01, 0.1, function(buffers){
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
var buffer = buffers[0];
|
var buffer = buffers[0];
|
||||||
for (var i = 0; i < buffer.length; i++){
|
for (var i = 0; i < buffer.length; i++){
|
||||||
expect(buffer[i]).to.be.within(15, 20);
|
expect(buffer[i]).to.be.within(15, 20);
|
||||||
|
@ -237,7 +202,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
|
|
||||||
|
|
||||||
describe("Tone.Gate", function(){
|
describe("Tone.Gate", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
it("can be created and disposed", function(){
|
it("can be created and disposed", function(){
|
||||||
var g = new Gate();
|
var g = new Gate();
|
||||||
|
@ -250,7 +215,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
var recorder = new Recorder();
|
var recorder = new Recorder();
|
||||||
sig.connect(gate);
|
sig.connect(gate);
|
||||||
gate.connect(recorder);
|
gate.connect(recorder);
|
||||||
recorder.record(0.01, 0.1, function(buffers){
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
var buffer = buffers[0];
|
var buffer = buffers[0];
|
||||||
for (var i = 0; i < buffer.length; i++){
|
for (var i = 0; i < buffer.length; i++){
|
||||||
expect(buffer[i]).to.equal(0);
|
expect(buffer[i]).to.equal(0);
|
||||||
|
@ -268,7 +233,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
var recorder = new Recorder();
|
var recorder = new Recorder();
|
||||||
sig.connect(gate);
|
sig.connect(gate);
|
||||||
gate.connect(recorder);
|
gate.connect(recorder);
|
||||||
recorder.record(0.01, 0.1, function(buffers){
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
var buffer = buffers[0];
|
var buffer = buffers[0];
|
||||||
for (var i = 0; i < buffer.length; i++){
|
for (var i = 0; i < buffer.length; i++){
|
||||||
expect(buffer[i]).to.greaterThan(0);
|
expect(buffer[i]).to.greaterThan(0);
|
||||||
|
@ -282,7 +247,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Tone.Follower", function(){
|
describe("Tone.Follower", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
it("can be created and disposed", function(){
|
it("can be created and disposed", function(){
|
||||||
var f = new Follower();
|
var f = new Follower();
|
||||||
|
@ -290,13 +255,13 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
});
|
});
|
||||||
|
|
||||||
it("smoothes the incoming signal", function(done){
|
it("smoothes the incoming signal", function(done){
|
||||||
var foll = new Follower(0.1);
|
var foll = new Follower(recorderDuration, 0.5);
|
||||||
var sig = new Signal(0);
|
var sig = new Signal(0);
|
||||||
var recorder = new Recorder();
|
var recorder = new Recorder();
|
||||||
sig.connect(foll);
|
sig.connect(foll);
|
||||||
sig.setValue(1);
|
|
||||||
foll.connect(recorder);
|
foll.connect(recorder);
|
||||||
recorder.record(0.01, 0.1, function(buffers){
|
sig.setValueAtTime(1, "+", recorderDelay);
|
||||||
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
var buffer = buffers[0];
|
var buffer = buffers[0];
|
||||||
for (var i = 0; i < buffer.length; i++){
|
for (var i = 0; i < buffer.length; i++){
|
||||||
expect(buffer[i]).to.lessThan(1);
|
expect(buffer[i]).to.lessThan(1);
|
||||||
|
@ -311,7 +276,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Tone.Envelope", function(){
|
describe("Tone.Envelope", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
it("can be created and disposed", function(){
|
it("can be created and disposed", function(){
|
||||||
var e = new Envelope();
|
var e = new Envelope();
|
||||||
|
@ -338,7 +303,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Tone.Filter", function(){
|
describe("Tone.Filter", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
it("can be created and disposed", function(){
|
it("can be created and disposed", function(){
|
||||||
var f = new Filter();
|
var f = new Filter();
|
||||||
|
@ -362,7 +327,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Tone.EQ", function(){
|
describe("Tone.EQ", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
it("can be created and disposed", function(){
|
it("can be created and disposed", function(){
|
||||||
var eq = new EQ();
|
var eq = new EQ();
|
||||||
|
@ -373,7 +338,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
|
|
||||||
//MERGE
|
//MERGE
|
||||||
describe("Tone.Merge", function(){
|
describe("Tone.Merge", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
it("can be created and disposed", function(){
|
it("can be created and disposed", function(){
|
||||||
var mer = new Merge();
|
var mer = new Merge();
|
||||||
|
@ -389,7 +354,7 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
sigR.connect(merger.right);
|
sigR.connect(merger.right);
|
||||||
var recorder = new Recorder(2);
|
var recorder = new Recorder(2);
|
||||||
merger.connect(recorder);
|
merger.connect(recorder);
|
||||||
recorder.record(0.1, 0.1, function(buffers){
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
var lBuffer = buffers[0];
|
var lBuffer = buffers[0];
|
||||||
var rBuffer = buffers[1];
|
var rBuffer = buffers[1];
|
||||||
//get the left buffer and check that all values are === 1
|
//get the left buffer and check that all values are === 1
|
||||||
|
@ -404,36 +369,44 @@ function(coreTest, chai, DryWet, Master, Signal, Recorder, Panner, LFO, Gate, Fo
|
||||||
|
|
||||||
//SCALE
|
//SCALE
|
||||||
describe("Tone.Split", function(){
|
describe("Tone.Split", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
it("can be created and disposed", function(){
|
it("can be created and disposed", function(){
|
||||||
var split = new Split();
|
var split = new Split();
|
||||||
split.dispose();
|
split.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("merges two signal into one stereo signal and then split them back into two signals", function(done){
|
it("merges two signal into one stereo signal and then split them back into two signals on left side", function(done){
|
||||||
//make an oscillator to drive the signal
|
//make an oscillator to drive the signal
|
||||||
var sigL = new Signal(1);
|
var sig = new Signal(1);
|
||||||
var sigR = new Signal(2);
|
|
||||||
var merger = new Merge();
|
var merger = new Merge();
|
||||||
var split = new Split();
|
var split = new Split();
|
||||||
sigL.connect(merger.left);
|
sig.connect(merger.left);
|
||||||
sigR.connect(merger.right);
|
|
||||||
merger.connect(split);
|
merger.connect(split);
|
||||||
var recorderL = new Recorder();
|
var recorder = new Recorder();
|
||||||
var recorderR = new Recorder();
|
split.left.connect(recorder);
|
||||||
split.left.connect(recorderL);
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
split.right.connect(recorderR);
|
|
||||||
recorderL.record(0.1, 0.1, function(buffers){
|
|
||||||
var lBuffer = buffers[0];
|
var lBuffer = buffers[0];
|
||||||
for (var i = 0; i < lBuffer.length; i++){
|
for (var i = 0; i < lBuffer.length; i++){
|
||||||
expect(lBuffer[i]).to.equal(1);
|
expect(lBuffer[i]).to.equal(1);
|
||||||
}
|
}
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
recorderR.record(0.1, 0.1, function(buffers){
|
});
|
||||||
var rBuffer = buffers[0];
|
|
||||||
for (var j = 0; j < rBuffer.length; j++){
|
it("merges two signal into one stereo signal and then split them back into two signals on right side", function(done){
|
||||||
expect(rBuffer[j]).to.equal(2);
|
//make an oscillator to drive the signal
|
||||||
|
var sig = new Signal(2);
|
||||||
|
var merger = new Merge();
|
||||||
|
var split = new Split();
|
||||||
|
sig.connect(merger.right);
|
||||||
|
merger.connect(split);
|
||||||
|
var recorder = new Recorder();
|
||||||
|
split.right.connect(recorder);
|
||||||
|
recorder.record(recorderDuration, recorderDelay, function(buffers){
|
||||||
|
var lBuffer = buffers[0];
|
||||||
|
for (var i = 0; i < lBuffer.length; i++){
|
||||||
|
expect(lBuffer[i]).to.equal(2);
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global it, describe, after */
|
/* global it, describe, after, maxTimeout, recorderDelay, recorderDuration */
|
||||||
|
|
||||||
define(["chai", "Tone/source/Player", "Tone/core/Master", "Tone/source/Oscillator", "Tone/component/Recorder", "Tone/source/Noise", "tests/Core"],
|
define(["chai", "Tone/source/Player", "Tone/core/Master", "Tone/source/Oscillator", "Tone/component/Recorder", "Tone/source/Noise", "tests/Core"],
|
||||||
function(chai, Player, Master, Oscillator, Recorder, Noise){
|
function(chai, Player, Master, Oscillator, Recorder, Noise){
|
||||||
|
@ -8,7 +8,7 @@ function(chai, Player, Master, Oscillator, Recorder, Noise){
|
||||||
Master.mute();
|
Master.mute();
|
||||||
|
|
||||||
describe("Tone.Player", function(){
|
describe("Tone.Player", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
var player = new Player("./testAudio/kick.mp3");
|
var player = new Player("./testAudio/kick.mp3");
|
||||||
player.toMaster();
|
player.toMaster();
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ function(chai, Player, Master, Oscillator, Recorder, Noise){
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Tone.Oscillator", function(){
|
describe("Tone.Oscillator", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
var oscillator = new Oscillator();
|
var oscillator = new Oscillator();
|
||||||
oscillator.toMaster();
|
oscillator.toMaster();
|
||||||
|
@ -110,13 +110,14 @@ function(chai, Player, Master, Oscillator, Recorder, Noise){
|
||||||
it("be scheduled to start in the future", function(done){
|
it("be scheduled to start in the future", function(done){
|
||||||
var recorder = new Recorder();
|
var recorder = new Recorder();
|
||||||
oscillator.connect(recorder);
|
oscillator.connect(recorder);
|
||||||
oscillator.start("+.05");
|
var startOffset = 0.05;
|
||||||
recorder.record(0.1, 0.05, function(buffers){
|
oscillator.start("+"+(recorderDelay + startOffset));
|
||||||
|
recorder.record(recorderDuration + startOffset, recorderDelay, function(buffers){
|
||||||
oscillator.stop();
|
oscillator.stop();
|
||||||
var buffer = buffers[0];
|
var buffer = buffers[0];
|
||||||
for (var i = 0; i < buffer.length; i++){
|
for (var i = 0; i < buffer.length; i++){
|
||||||
if (buffer[i] !== 0){
|
if (buffer[i] !== 0){
|
||||||
expect(oscillator.samplesToSeconds(i)).to.be.closeTo(0.05, 0.01);
|
expect(oscillator.samplesToSeconds(i)).to.be.closeTo(startOffset, 0.1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +139,7 @@ function(chai, Player, Master, Oscillator, Recorder, Noise){
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Tone.Noise", function(){
|
describe("Tone.Noise", function(){
|
||||||
this.timeout(1000);
|
this.timeout(maxTimeout);
|
||||||
|
|
||||||
var noise = new Noise();
|
var noise = new Noise();
|
||||||
noise.toMaster();
|
noise.toMaster();
|
||||||
|
@ -185,13 +186,14 @@ function(chai, Player, Master, Oscillator, Recorder, Noise){
|
||||||
it("be scheduled to start in the future", function(done){
|
it("be scheduled to start in the future", function(done){
|
||||||
var recorder = new Recorder();
|
var recorder = new Recorder();
|
||||||
noise.connect(recorder);
|
noise.connect(recorder);
|
||||||
noise.start("+.05");
|
var startOffset = 0.1;
|
||||||
recorder.record(0.1, 0.05, function(buffers){
|
noise.start("+"+(recorderDelay + startOffset));
|
||||||
|
recorder.record(recorderDuration + startOffset, recorderDelay, function(buffers){
|
||||||
noise.stop();
|
noise.stop();
|
||||||
var buffer = buffers[0];
|
var buffer = buffers[0];
|
||||||
for (var i = 0; i < buffer.length; i++){
|
for (var i = 0; i < buffer.length; i++){
|
||||||
if (buffer[i] !== 0){
|
if (buffer[i] !== 0){
|
||||||
expect(noise.samplesToSeconds(i)).to.be.closeTo(0.05, 0.01);
|
expect(noise.samplesToSeconds(i)).to.be.closeTo(startOffset, 0.1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue