migrating tests to new Offline API

This commit is contained in:
Yotam Mann 2017-02-20 14:06:44 -05:00
parent 15dd8107de
commit fc0a26027f
10 changed files with 523 additions and 943 deletions

View file

@ -1,5 +1,5 @@
define(["helper/OutputAudio", "Tone/source/Oscillator", "helper/Offline", "Test", "helper/Meter"],
function (OutputAudio, Oscillator, Offline, Test, Meter) {
define(["helper/OutputAudio", "Tone/source/Oscillator", "helper/Offline", "Test"],
function (OutputAudio, Oscillator, Offline, Test) {
return function(Constr, args){
@ -56,22 +56,12 @@ define(["helper/OutputAudio", "Tone/source/Oscillator", "helper/Offline", "Test"
osc.dispose();
});
it ("does not clip in volume", function(done){
var osc;
var meter = new Meter(0.2);
meter.before(function(dest){
osc = new Constr(args).connect(dest).start(0);
it ("does not clip in volume", function(){
return Offline(function(){
new Constr(args).toMaster().start(0);
}).then(function(buffer){
expect(buffer.max()).to.be.at.most(1);
});
meter.test(function(level){
if (level > 1){
throw new Error("audio clipped with level "+level);
}
});
meter.after(function(){
osc.dispose();
done();
});
meter.run();
});
});

View file

@ -1,6 +1,6 @@
define(["helper/OutputAudio", "Tone/source/Source", "helper/OutputAudioStereo",
"Test", "helper/Offline2", "helper/Meter", "helper/APITest"],
function (OutputAudio, Source, OutputAudioStereo, Test, Offline, Meter, APITest) {
"Test", "helper/Offline", "helper/APITest"],
function (OutputAudio, Source, OutputAudioStereo, Test, Offline, APITest) {
return function(Constr, args){
@ -18,129 +18,81 @@ define(["helper/OutputAudio", "Tone/source/Source", "helper/OutputAudioStereo",
instance.dispose();
});
it("starts and stops", function(done){
Offline(function(output, testFn, tearDown){
it("starts and stops", function(){
return Offline(function(){
var instance = new Constr(args);
expect(instance.state).to.equal("stopped");
instance.start(0).stop(0.2);
testFn(function(sample, time){
return function(time){
if (time >= 0 && time < 0.2){
expect(instance.state).to.equal("started");
} else if (time > 0.2){
expect(instance.state).to.equal("stopped");
}
});
tearDown(function(){
instance.dispose();
done();
});
};
}, 0.3);
});
it("makes a sound", function(done){
var instance;
OutputAudio(function(dest){
instance = new Constr(args);
instance.connect(dest);
it("makes a sound", function(){
return OutputAudio(function(){
var instance = new Constr(args);
instance.toMaster();
instance.start();
}, function(){
instance.dispose();
done();
});
});
it("produces sound in both channels", function(done){
var instance;
OutputAudioStereo(function(dest){
instance = new Constr(args);
instance.connect(dest);
it("produces sound in both channels", function(){
return OutputAudioStereo(function(){
var instance = new Constr(args);
instance.toMaster();
instance.start();
}, function(){
instance.dispose();
done();
});
});
it("be scheduled to start in the future", function(done){
var instance;
var meter = new Meter(0.3);
meter.before(function(dest){
instance = new Constr(args);
instance.connect(dest);
it("be scheduled to start in the future", function(){
return Offline(function(){
var instance = new Constr(args).toMaster();
instance.start(0.1);
}, 0.3).then(function(buffer){
buffer.forEach(function(sample, time){
if (sample > 0){
expect(time).to.be.at.least(0.099);
}
});
});
meter.test(function(sample, time){
if (sample > 0){
expect(time).to.be.at.least(0.1);
}
});
meter.after(function(){
instance.dispose();
done();
});
meter.run();
});
it("makes no sound if it is started and then stopped with a time at or before the start time", function(done){
var instance;
var meter = new Meter(1);
meter.before(function(dest){
instance = new Constr(args);
instance.connect(dest);
instance.start(0.5).stop(0);
it("makes no sound if it is started and then stopped with a time at or before the start time", function(){
return Offline(function(){
var instance = new Constr(args).toMaster();
instance.start(0.1).stop(0.05);
}, 0.3).then(function(buffer){
expect(buffer.isSilent()).to.be.true;
});
meter.test(function(sample){
expect(sample).to.equal(0);
});
meter.after(function(){
instance.dispose();
done();
});
meter.run();
});
it("can be muted", function(done){
var instance;
var meter = new Meter(0.25);
meter.before(function(dest){
instance = new Constr(args);
instance.connect(dest);
it("can be muted", function(){
return Offline(function(){
var instance = new Constr(args).toMaster();
instance.start(0);
instance.mute = true;
}, 0.3).then(function(buffer){
expect(buffer.isSilent()).to.be.true;
});
meter.test(function(sample){
expect(sample).to.equal(0);
});
meter.after(function(){
instance.dispose();
done();
});
meter.run();
});
it("be scheduled to stop in the future", function(done){
var instance;
var meter = new Meter(0.4);
meter.before(function(dest){
instance = new Constr(args);
instance.connect(dest);
it("be scheduled to stop in the future", function(){
return Offline(function(){
var instance = new Constr(args).toMaster();
instance.start(0).stop(0.2);
instance.mute = true;
}, 0.3).then(function(buffer){
buffer.forEach(function(sample, time){
if (time > 0.2){
expect(sample).to.equal(0);
}
});
});
//keep a moving average of the output
meter.test(function(sample, time){
if (time > 0.02 && sample < 0.001){
expect(time).to.be.gte(0.2);
}
});
meter.after(function(){
instance.dispose();
done();
});
meter.run();
});
});

View file

@ -1,4 +1,4 @@
define(["helper/Basic", "Tone/source/BufferSource", "helper/Offline2", "Tone/core/Buffer", "helper/Meter", "helper/Meter2"],
define(["helper/Basic", "Tone/source/BufferSource", "helper/Offline", "Tone/core/Buffer", "helper/Meter", "helper/Meter2"],
function (BasicTests, BufferSource, Offline, Buffer, Meter, Meter2) {
if (window.__karma__){
@ -85,25 +85,17 @@ define(["helper/Basic", "Tone/source/BufferSource", "helper/Offline2", "Tone/cor
player.dispose();
});
it("loops the audio", function(done){
var player;
var meter = new Meter(buffer.duration * 2);
meter.before(function(dest){
player = new BufferSource(buffer);
it("loops the audio", function(){
return Offline(function(){
var player = new BufferSource(buffer);
player.loop = true;
player.connect(dest);
player.toMaster();
player.start(0);
}, buffer.duration * 2).then(function(buff){
buff.getRMS().forEach(function(val){
expect(val).to.be.above(0);
});
});
meter.test(function(sample, time){
if (time > 0.1){
expect(sample).to.be.above(0);
}
});
meter.after(function(){
player.dispose();
done();
});
meter.run();
});
});
@ -140,64 +132,62 @@ define(["helper/Basic", "Tone/source/BufferSource", "helper/Offline2", "Tone/cor
});
});
it("can be play for a specific duration", function(done){
var meter = new Meter2(function(dest, test, after){
it("can play for a specific duration", function(){
return Meter2(function(){
var player = new BufferSource(buffer);
player.connect(dest);
player.toMaster();
player.start(0).stop(0.1);
test(function(sample, time){
if (sample === 0){
expect(time).to.at.least(0.1);
return function(time){
if (time > 0.1){
expect(player.state).to.equal("stopped");
}
};
}, 0.4).then(function(buffer){
buffer.forEach(function(level, time){
if (time >= 0 && time < 0.1){
expect(level).to.be.greaterThan(0);
} else if (time > 0.1){
expect(level).to.equal(0);
}
});
after(function(){
player.dispose();
done();
});
}, 0.4);
});
});
it("can be play for a specific duration passed in the 'start' method", function(done){
var player;
var meter = new Meter(0.4);
meter.before(function(dest){
player = new BufferSource(buffer);
player.connect(dest);
it("can play for a specific duration passed in the 'start' method", function(){
return Meter2(function(){
var player = new BufferSource(buffer);
player.toMaster();
player.start(0, 0, 0.1);
return function(time){
if (time > 0.1){
expect(player.state).to.equal("stopped");
}
};
}, 0.4).then(function(buffer){
buffer.forEach(function(level, time){
if (time >= 0 && time < 0.1){
expect(level).to.be.greaterThan(0);
} else if (time > 0.1){
expect(level).to.equal(0);
}
});
});
meter.test(function(sample, time){
if (sample < 0.001){
expect(time).to.at.least(0.1);
expect(player.state).to.equal("stopped");
}
});
meter.after(function(){
player.dispose();
done();
});
meter.run();
});
it("reports the right state", function(done){
Offline(function(output, test, after){
it("reports the right state", function(){
return Offline(function(){
var player = new BufferSource(buffer).toMaster();
player.start(0.2).stop(0.4);
test(function(sample, time){
return function(time){
if (time >= 0.2 && time < 0.4){
expect(player.state).to.equal("started");
} else {
expect(player.state).to.equal("stopped");
}
});
after(function(){
player.dispose();
done();
});
};
}, 0.5);
});
@ -219,78 +209,58 @@ define(["helper/Basic", "Tone/source/BufferSource", "helper/Offline2", "Tone/cor
}, 300);
});
it("can be scheduled to stop", function(done){
Meter2(function(output, test, after){
it("can be scheduled to stop", function(){
return Meter2(function(){
var player = new BufferSource(buffer).toMaster();
player.start(0).stop(0.1);
test(function(sample, time){
}, 0.6).then(function(rms){
rms.forEach(function(level, time){
if (time > 0.01 && time < 0.1){
expect(sample).to.be.gt(0);
expect(level).to.be.gt(0);
} else if (time > 0.11){
expect(sample).to.equal(0);
expect(level).to.equal(0);
}
});
after(function(){
player.dispose();
done();
});
}, 0.6);
});
});
it("can be scheduled to stop with a ramp", function(done){
Meter2(function(output, test, after){
it("can be scheduled to stop with a ramp", function(){
return Meter2(function(){
var player = new BufferSource(buffer).toMaster();
player.start(0).stop(0.1, 0.1);
test(function(sample, time){
}, 0.6).then(function(rms){
rms.forEach(function(level, time){
if (time > 0.01 && time < 0.2){
expect(sample).to.be.gt(0);
expect(level).to.be.gt(0);
} else if (time > 0.21){
expect(sample).to.equal(0);
expect(level).to.equal(0);
}
});
after(function(){
player.dispose();
done();
});
}, 0.5);
});
});
it("can be scheduled to start at a lower gain", function(done){
Offline(function(output, test, after){
it("can be scheduled to start at a lower gain", function(){
return Offline(function(){
var player = new BufferSource(buffer).toMaster();
player.start(0, 0, undefined, 0.5);
test(function(sample){
}, 0.5).then(function(buffer){
buffer.forEach(function(sample){
expect(sample).to.be.lte(0.5);
});
after(function(){
player.dispose();
done();
});
}, 0.5);
});
});
it("can be scheduled to start with a ramp", function(done){
Offline(function(output, test, after){
it("can be scheduled to start with a ramp", function(){
return Offline(function(){
var player = new BufferSource(buffer).toMaster();
player.start(0, 0, undefined, 1, 0.1);
test(function(sample, time){
}, 0.5).then(function(buffer){
buffer.forEach(function(sample, time){
if (time < 0.1){
expect(sample).to.be.lte(time * 10);
}
});
after(function(){
player.dispose();
done();
});
}, 0.5);
});
});
});

View file

@ -1,6 +1,6 @@
define(["helper/Basic", "Tone/source/MultiPlayer", "helper/Offline", "helper/SourceTests",
"Tone/core/Buffer", "helper/Meter", "helper/OutputAudioStereo", "helper/Meter2"],
function (BasicTests, MultiPlayer, Offline, SourceTests, Buffer, Meter, OutputAudioStereo, Meter2) {
"Tone/core/Buffer", "helper/OutputAudioStereo", "helper/Meter"],
function (BasicTests, MultiPlayer, Offline, SourceTests, Buffer, OutputAudioStereo, Meter) {
if (window.__karma__){
Buffer.baseUrl = "/base/test/";
@ -52,140 +52,96 @@ define(["helper/Basic", "Tone/source/MultiPlayer", "helper/Offline", "helper/Sou
context("Makes Sound", function(){
it("produces sound in both channels", function(done){
var player;
OutputAudioStereo(function(dest){
player = new MultiPlayer().add("buffer", buffer);
player.connect(dest);
it("produces sound in both channels", function(){
return OutputAudioStereo(function(){
var player = new MultiPlayer().add("buffer", buffer);
player.toMaster();
player.start("buffer");
}, function(){
player.dispose();
done();
});
});
it("be scheduled to start in the future", function(done){
var player;
var meter = new Meter(0.3);
meter.before(function(dest){
player = new MultiPlayer().add("buffer", buffer);
player.connect(dest);
it("be scheduled to start in the future", function(){
return Offline(function(){
var player = new MultiPlayer().add("buffer", buffer).toMaster();
player.start("buffer", 0.1);
});
meter.test(function(sample, time){
if (sample > 0){
expect(time).to.be.at.least(0.1);
}
});
meter.after(function(){
player.dispose();
done();
});
meter.run();
});
it("can be repitched", function(done){
var player;
var meter = new Meter(0.3);
meter.before(function(dest){
player = new MultiPlayer().add("buffer", buffer);
player.connect(dest);
player.start("buffer", 0, 0, 0.3, -1);
});
meter.test(function(value, time){
if (time > 0){
expect(value).to.be.at.least(0.1);
}
});
meter.after(function(){
player.dispose();
done();
});
meter.run();
});
it("can be played at a different gain", function(done){
var player;
var meter = new Meter(0.3);
meter.before(function(dest){
player = new MultiPlayer().add("buffer", buffer);
player.connect(dest);
player.start("buffer", 0, 0, 0.3, 0, 0.1);
});
meter.test(function(value){
expect(value).to.be.at.most(0.1);
});
meter.after(function(){
player.dispose();
done();
});
meter.run();
});
it("can be stopped", function(done){
var player;
var meter = new Meter(0.3);
meter.before(function(dest){
player = new MultiPlayer().add("buffer", buffer);
player.connect(dest);
player.start("buffer", 0).stop("buffer", 0.1);
});
meter.test(function(value, time){
if (time > 0 && time < 0.1){
expect(value).to.be.at.least(0.1);
} else if (time > 0.11){
expect(value).to.equal(0);
}
});
meter.after(function(){
player.dispose();
done();
});
meter.run();
});
it("can stop all sources", function(done){
var player;
var meter = new Meter(0.3);
meter.before(function(dest){
player = new MultiPlayer().add("buffer", buffer);
player.connect(dest);
player.start("buffer", 0).start("buffer", 0.02).stopAll(0.1);
});
meter.test(function(value, time){
if (time > 0 && time < 0.1){
expect(value).to.be.at.least(0.1);
} else if (time > 0.12){
expect(value).to.equal(0);
}
});
meter.after(function(){
player.dispose();
done();
});
meter.run();
});
it("can start and stop a loop", function(done){
var meter = new Meter2(function(dest, test, after){
var player = new MultiPlayer().add("buffer", buffer);
player.connect(dest);
var stopTime = buffer.duration * 1.1;
player.startLoop("buffer", 0).stop("buffer", stopTime);
test(function(value, time){
if (time > 0 && time < stopTime){
expect(value).to.be.at.least(0.1);
} else if (time > stopTime + 0.01){
expect(value).to.equal(0);
}, 0.3).then(function(buffer){
buffer.forEach(function(sample, time){
if (sample > 0){
expect(time).to.be.at.least(0.1);
}
});
});
});
after(function(){
player.dispose();
done();
it("can be repitched", function(){
return Meter(function(){
var player = new MultiPlayer().add("buffer", buffer).toMaster();
player.start("buffer", 0, 0, 0.3, -1);
}, 0.3).then(function(buffer){
buffer.forEach(function(level, time){
if (time > 0){
expect(level).to.be.at.least(0.1);
}
});
}, buffer.duration * 1.5);
});
});
it("can be played at a different gain", function(){
return Offline(function(){
var player = new MultiPlayer().add("buffer", buffer).toMaster();
player.start("buffer", 0, 0, 0.3, 0, 0.1);
}, 0.3).then(function(buffer){
expect(buffer.max()).to.be.at.most(0.1);
});
});
it("can be stopped", function(){
return Meter(function(){
var player = new MultiPlayer().add("buffer", buffer);
player.toMaster();
player.start("buffer", 0).stop("buffer", 0.1);
}, 0.3).then(function(rms){
rms.forEach(function(level, time){
if (time > 0 && time < 0.1){
expect(level).to.be.at.least(0.1);
} else if (time > 0.11){
expect(level).to.equal(0);
}
});
});
});
it("can stop all sources", function(){
return Meter(function(){
var player = new MultiPlayer().add("buffer", buffer);
player.toMaster();
player.start("buffer", 0).start("buffer", 0.02).stopAll(0.1);
}, 0.3).then(function(rms){
rms.forEach(function(level, time){
if (time > 0 && time < 0.1){
expect(level).to.be.at.least(0.1);
} else if (time > 0.12){
expect(level).to.equal(0);
}
});
});
});
it("can start and stop a loop", function(){
var stopTime = buffer.duration * 1.1;
return Meter(function(){
var player = new MultiPlayer().add("buffer", buffer);
player.toMaster();
player.startLoop("buffer", 0).stop("buffer", stopTime);
}, buffer.duration * 1.5).then(function(rms){
rms.forEach(function(level, time){
if (time > 0 && time < stopTime){
expect(level).to.be.at.least(0.1);
} else if (time > stopTime + 0.01){
expect(level).to.equal(0);
}
});
});
});

View file

@ -55,90 +55,29 @@ define(["helper/Basic", "Tone/source/Noise", "helper/SourceTests", "helper/Outpu
noise.dispose();
});
it("outputs white noise", function(done){
var noise;
OutputAudio(function(dest){
noise = new Noise("white");
noise.connect(dest);
it("outputs white noise", function(){
return OutputAudio(function(){
var noise = new Noise("white");
noise.toMaster();
noise.start();
}, function(){
noise.dispose();
done();
});
});
it("outputs pink noise", function(done){
var noise;
OutputAudio(function(dest){
noise = new Noise("pink");
noise.connect(dest);
it("outputs pink noise", function(){
return OutputAudio(function(){
var noise = new Noise("pink");
noise.toMaster();
noise.start();
}, function(){
noise.dispose();
done();
});
});
it("outputs brown noise", function(done){
var noise;
OutputAudio(function(dest){
noise = new Noise("brown");
noise.connect(dest);
it("outputs brown noise", function(){
return OutputAudio(function(){
var noise = new Noise("brown");
noise.toMaster();
noise.start();
}, function(){
noise.dispose();
done();
});
});
});
/*it("be scheduled to start in the future", function(done){
var noise;
var offline = new Offline();
Test.offlineTest(1, function(dest){
noise = new Noise();
noise.connect(dest);
noise.start("+0.1");
}, function(sample, time){
if (sample !== 0){
expect(time).to.be.at.least(0.1);
}
}, function(){
noise.dispose();
done();
});
});
it("can set the noise types", function(){
var noise = new Noise();
noise.type = "brown";
noise.type = "white";
noise.type = "pink";
//even after started
noise.start();
noise.type = "brown";
noise.type = "white";
noise.type = "pink";
noise.stop();
noise.dispose();
});
it("can be created with an options object", function(){
var noise = new Noise({
"type" : "brown"
});
expect(noise.type).to.equal("brown");
noise.dispose();
});
it("can be set with an options object", function(){
var noise = new Noise();
noise.set({
"type" : "pink"
});
expect(noise.type).to.equal("pink");
noise.dispose();
});*/
});
});

View file

@ -10,87 +10,59 @@ define(["helper/Basic", "Tone/source/OmniOscillator", "helper/Offline", "helper/
context("Sound", function(){
it("makes a sound", function(done){
var osc;
OutputAudio(function(dest){
osc = new OmniOscillator();
osc.connect(dest);
it("makes a sound", function(){
return OutputAudio(function(){
var osc = new OmniOscillator();
osc.toMaster();
osc.start();
}, function(){
osc.dispose();
done();
});
});
it("makes a sound when set to square", function(done){
var osc;
OutputAudio(function(dest){
osc = new OmniOscillator(440, "square");
osc.connect(dest);
it("makes a sound when set to square", function(){
return OutputAudio(function(){
var osc = new OmniOscillator(440, "square");
osc.toMaster();
osc.start();
}, function(){
osc.dispose();
done();
});
});
it("makes a sound when set to pulse", function(done){
var osc;
OutputAudio(function(dest){
osc = new OmniOscillator(440, "pulse");
osc.connect(dest);
it("makes a sound when set to pulse", function(){
return OutputAudio(function(){
var osc = new OmniOscillator(440, "pulse");
osc.toMaster();
osc.start();
}, function(){
osc.dispose();
done();
});
});
it("makes a sound when set to pwm", function(done){
var osc;
OutputAudio(function(dest){
osc = new OmniOscillator(440, "pwm");
osc.connect(dest);
it("makes a sound when set to pwm", function(){
return OutputAudio(function(){
var osc = new OmniOscillator(440, "pwm");
osc.toMaster();
osc.start();
}, function(){
osc.dispose();
done();
});
});
it("makes a sound when set to fm", function(done){
var osc;
OutputAudio(function(dest){
osc = new OmniOscillator(440, "fmsquare");
osc.connect(dest);
it("makes a sound when set to fm", function(){
return OutputAudio(function(){
var osc = new OmniOscillator(440, "fmsquare");
osc.toMaster();
osc.start();
}, function(){
osc.dispose();
done();
});
});
it("makes a sound when set to am", function(done){
var osc;
OutputAudio(function(dest){
osc = new OmniOscillator(440, "amsine");
osc.connect(dest);
it("makes a sound when set to am", function(){
return OutputAudio(function(){
var osc = new OmniOscillator(440, "amsine");
osc.toMaster();
osc.start();
}, function(){
osc.dispose();
done();
});
});
it("makes a sound when set to fat", function(done){
var osc;
OutputAudio(function(dest){
osc = new OmniOscillator(440, "fatsawtooth");
osc.connect(dest);
it("makes a sound when set to fat", function(){
return OutputAudio(function(){
var osc = new OmniOscillator(440, "fatsawtooth");
osc.toMaster();
osc.start();
}, function(){
osc.dispose();
done();
});
});

View file

@ -31,58 +31,45 @@ define(["helper/Basic", "Tone/source/Oscillator", "helper/Offline", "helper/Sour
osc.dispose();
});
});
context("Phase Rotation", function(){
it ("can change the phase to 90", function(done){
var instance;
var offline = new Offline(1);
offline.before(function(dest){
instance = new Oscillator({
it ("can change the phase to 90", function(){
return Offline(function(){
var instance = new Oscillator({
"phase" : 90,
"frequency" : 1
});
instance.connect(dest);
instance.toMaster();
instance.start(0);
}, 1).then(function(buffer){
buffer.forEach(function(sample, time){
if (time < 0.25){
expect(sample).to.be.within(-1, 0);
} else if (time < 0.5){
expect(sample).to.be.within(0, 1);
}
});
});
offline.test(function(sample, time){
if (time < 0.25){
expect(sample).to.be.within(-1, 0);
} else if (time < 0.5){
expect(sample).to.be.within(0, 1);
}
});
offline.after(function(){
instance.dispose();
done();
});
offline.run();
});
it ("can change the phase to -90", function(done){
var instance;
var offline = new Offline(1);
offline.before(function(dest){
instance = new Oscillator({
it ("can change the phase to -90", function(){
return Offline(function(){
var instance = new Oscillator({
"phase" : 270,
"frequency" : 1
});
instance.connect(dest);
instance.toMaster();
instance.start(0);
}, 1).then(function(buffer){
buffer.forEach(function(sample, time){
if (time < 0.25){
expect(sample).to.be.within(0, 1);
} else if (time < 0.5){
expect(sample).to.be.within(-1, 0);
}
});
});
offline.test(function(sample, time){
if (time < 0.25){
expect(sample).to.be.within(0, 1);
} else if (time < 0.5){
expect(sample).to.be.within(-1, 0);
}
});
offline.after(function(){
instance.dispose();
done();
});
offline.run();
});
});
@ -145,14 +132,10 @@ define(["helper/Basic", "Tone/source/Oscillator", "helper/Offline", "helper/Sour
osc.dispose();
});
it ("makes a sound with custom partials", function(done){
var osc;
OutputAudio(function(dest){
osc = new Oscillator().connect(dest).start();
it ("makes a sound with custom partials", function(){
return OutputAudio(function(){
var osc = new Oscillator().toMaster().start();
osc.partials = [1, 0.2, 0.2, 0.2];
}, function(){
osc.dispose();
done();
});
});
@ -172,47 +155,29 @@ define(["helper/Basic", "Tone/source/Oscillator", "helper/Offline", "helper/Sour
});
context("Synchronization", function(){
it("can sync the frequency to the Transport", function(done){
var osc;
var offline = new Offline(0.1);
offline.before(function(dest){
it("can sync the frequency to the Transport", function(){
return Offline(function(Transport){
Transport.bpm.value = 120;
osc = new Oscillator(2);
osc.frequency.connect(dest);
var osc = new Oscillator(2);
osc.frequency.toMaster();
osc.syncFrequency();
Transport.bpm.value = 240;
}).then(function(buffer){
expect(buffer.value()).to.be.closeTo(4, 0.001);
});
offline.test(function(freq){
expect(freq).to.be.closeTo(4, 0.001);
});
offline.after(function(){
Transport.bpm.value = 120;
osc.dispose();
done();
});
offline.run();
});
it("can unsync the frequency from the Transport", function(done){
var osc;
var offline = new Offline(0.1);
offline.before(function(dest){
it("can unsync the frequency from the Transport", function(){
return Offline(function(Transport){
Transport.bpm.value = 120;
osc = new Oscillator(2);
osc.frequency.connect(dest);
var osc = new Oscillator(2);
osc.frequency.toMaster();
osc.syncFrequency();
Transport.bpm.value = 240;
osc.unsyncFrequency();
}).then(function(buffer){
expect(buffer.value()).to.be.closeTo(2, 0.001);
});
offline.test(function(freq){
expect(freq).to.be.closeTo(2, 0.001);
});
offline.after(function(){
Transport.bpm.value = 120;
osc.dispose();
done();
});
offline.run();
});
});

View file

@ -1,6 +1,6 @@
define(["helper/Basic", "Tone/source/Player", "helper/Offline",
"helper/SourceTests", "Tone/core/Buffer", "helper/Meter", "helper/Offline2"],
function (BasicTests, Player, Offline, SourceTests, Buffer, Meter, Offline2) {
"helper/SourceTests", "Tone/core/Buffer", "helper/Meter2", "helper/Offline2", "Test"],
function (BasicTests, Player, Offline, SourceTests, Buffer, Meter, Offline2, Test) {
if (window.__karma__){
Buffer.baseUrl = "/base/test/";
@ -88,27 +88,17 @@ define(["helper/Basic", "Tone/source/Player", "helper/Offline",
context("Reverse", function(){
it("can be played in reverse", function(done){
var player;
var offline = new Offline();
it("can be played in reverse", function(){
var audioBuffer = buffer.get().getChannelData(0);
var lastSample = audioBuffer[audioBuffer.length - 1];
offline.before(function(dest){
player = new Player(buffer.get()).connect(dest);
return Offline(function(){
var player = new Player(buffer.get()).toMaster();
player.reverse = true;
player.start(0);
}).then(function(buffer){
var firstSample = buffer.toArray()[0];
expect(firstSample).to.equal(lastSample);
});
offline.test(function(sample, time){
if (time === 0){
expect(sample).to.equal(lastSample);
}
});
offline.after(function(){
player.dispose();
buffer.reverse = false;
done();
});
offline.run();
});
});
@ -140,25 +130,17 @@ define(["helper/Basic", "Tone/source/Player", "helper/Offline",
player.dispose();
});
it("loops the audio", function(done){
var player;
var meter = new Meter(buffer.duration * 2);
meter.before(function(dest){
player = new Player(buffer);
it("loops the audio", function(){
return Meter(function(){
var player = new Player(buffer);
player.loop = true;
player.connect(dest);
player.toMaster();
player.start(0);
}).then(function(rms){
rms.forEach(function(level){
expect(level).to.be.above(0);
});
});
meter.test(function(sample, time){
if (time > 0.01){
expect(sample).to.be.above(0);
}
});
meter.after(function(){
player.dispose();
done();
});
meter.run();
});
});
@ -203,210 +185,148 @@ define(["helper/Basic", "Tone/source/Player", "helper/Offline",
context("Start Scheduling", function(){
it("can be start with an offset", function(done){
var player;
var offline = new Offline(0.4, 1);
var audioBuffer = buffer.get().getChannelData(0);
var testSample = audioBuffer[Math.floor(0.1 * buffer.context.sampleRate)];
offline.before(function(dest){
player = new Player(buffer.get());
player.connect(dest);
it("can be start with an offset", function(){
var testSample = buffer.toArray()[Math.floor(0.1 * buffer.context.sampleRate)];
return Offline(function(){
var player = new Player(buffer.get());
player.toMaster();
player.start(0, 0.1);
}).then(function(buffer){
expect(buffer.toArray()[0]).to.equal(testSample);
});
offline.test(function(sample, time){
if (time === 0){
expect(sample).to.equal(testSample);
}
});
offline.after(function(){
player.dispose();
done();
});
offline.run();
});
it("is stopped and restarted if retrigger=false", function(done){
Offline2(function(output, test, after){
it("is stopped and restarted if retrigger=false", function(){
return Offline(function(){
//make a ramp between 0-1
var ramp = new Float32Array(Math.floor(44100 * 0.3));
for (var i = 0; i < ramp.length; i++){
ramp[i] = 1 - (i / (ramp.length)) * 0.3;
ramp[i] = (i / (ramp.length-1));
}
var buff = new Buffer().fromArray(ramp);
var player = new Player(buff).connect(output);
player.retrigger = false
var player = new Player(buff).toMaster();
player.retrigger = false;
player.start(0);
player.start(0.1);
test(function(sample, time){
if (sample > 1){
throw new Error("should not exceed 1")
}
});
after(function(){
buff.dispose();
player.dispose();
done();
});
}, 0.3);
}, 0.31).then(function(buffer){
expect(buffer.max()).to.be.lessThan(1);
});
});
it("can be retriggered", function(done){
Offline2(function(output, test, after){
it("can be retriggered", function(){
return Offline(function(){
//make a ramp between 0-1
var ramp = new Float32Array(Math.floor(44100 * 0.3));
for (var i = 0; i < ramp.length; i++){
ramp[i] = 1 - (i / (ramp.length)) * 0.3;
ramp[i] = (i / (ramp.length-1));
}
var buff = new Buffer().fromArray(ramp);
var player = new Player(buff).connect(output);
player.retrigger = true
var player = new Player(buff).toMaster();
player.retrigger = true;
player.start(0);
player.start(0.1);
var exceededOne = false;
test(function(sample, time){
if (sample > 1){
expect(time).to.be.gte(0.1);
exceededOne = true;
}
});
after(function(){
expect(exceededOne).to.be.true;
buff.dispose();
player.dispose();
done();
});
}, 0.3);
}, 0.31).then(function(buffer){
expect(buffer.max()).to.be.greaterThan(1);
});
});
it("can seek to a position at the given time", function(done){
Offline2(function(output, test, after){
it("can seek to a position at the given time", function(){
return Offline(function(){
//make a ramp between 0-1
var ramp = new Float32Array(Math.floor(44100 * 0.3));
for (var i = 0; i < ramp.length; i++){
ramp[i] = (i / (ramp.length)) * 0.3;
}
var buff = new Buffer().fromArray(ramp);
var player = new Player(buff).connect(output);
var player = new Player(buff).toMaster();
player.start(0);
player.seek(0.2, 0.1);
test(function(sample, time){
if (time < 0.1){
expect(sample).to.be.within(0, 0.1);
} else if (time > 0.1 && time < 0.2){
expect(sample).to.be.within(0.2, 0.3);
}
});
after(function(){
buff.dispose();
player.dispose();
done();
});
}, 0.3);
}, 0.3).then(function(buffer){
buffer.forEach(function(sample){
expect(sample).to.be.within(0, 0.1);
}, 0, 0.1);
buffer.forEach(function(sample){
expect(sample).to.be.within(0.2, 0.3);
}, 0.1, 0.2);
});
});
it ("correctly compensates if the offset is greater than the loopEnd", function(done){
Offline2(function(output, test, after){
it ("correctly compensates if the offset is greater than the loopEnd", function(){
return Offline(function(){
//make a ramp between 0-1
var ramp = new Float32Array(Math.floor(44100 * 0.3));
for (var i = 0; i < ramp.length; i++){
ramp[i] = (i / (ramp.length)) * 0.3;
}
var buff = new Buffer().fromArray(ramp);
var player = new Player(buff).connect(output);
player.loopStart = 0.1
player.loopEnd = 0.2
player.loop = true
var player = new Player(buff).toMaster();
player.loopStart = 0.1;
player.loopEnd = 0.2;
player.loop = true;
player.start(0, 0.35);
test(function(sample, time){
if (time < 0.05){
expect(sample).to.be.within(0.15, 0.2);
} else if (time > 0.05 && time < 0.1){
expect(sample).to.be.within(0.1, 0.15);
}
});
after(function(){
buff.dispose();
player.dispose();
done();
});
}, 0.3);
}, 0.3).then(function(buffer){
buffer.forEach(function(sample){
expect(sample).to.be.within(0.15, 0.2);
}, 0, 0.05);
buffer.forEach(function(sample){
expect(sample).to.be.within(0.1, 0.15);
}, 0.05, 0.1);
});
});
it("can be play for a specific duration", function(done){
var player;
var meter = new Meter(0.4);
meter.before(function(dest){
player = new Player(buffer);
player.connect(dest);
it("can be play for a specific duration", function(){
return Offline(function(){
var player = new Player(buffer);
player.toMaster();
player.start(0).stop(0.1);
return function(time){
Test.whenBetween(time, 0.1, Infinity, function(){
expect(player.state).to.equal("stopped");
});
Test.whenBetween(time, 0, 0.1, function(){
expect(player.state).to.equal("started");
});
};
}, 0.3).then(function(buffer){
buffer.forEach(function(sample){
expect(sample).to.equal(0);
}, 0.1, 0.15);
});
meter.test(function(sample, time){
if (sample < 0.001){
expect(time).to.at.least(0.1);
expect(player.state).to.equal("stopped");
}
});
meter.after(function(){
player.dispose();
done();
});
meter.run();
});
it("can be play for a specific duration passed in the 'start' method", function(done){
var player;
var meter = new Meter(0.4);
meter.before(function(dest){
player = new Player(buffer);
player.connect(dest);
player.start(0, 0.1);
it("can be play for a specific duration passed in the 'start' method", function(){
return Offline(function(){
var player = new Player(buffer);
player.toMaster();
player.start(0, 0, 0.1);
return function(time){
Test.whenBetween(time, 0.1, Infinity, function(){
expect(player.state).to.equal("stopped");
});
Test.whenBetween(time, 0, 0.1, function(){
expect(player.state).to.equal("started");
});
};
}, 0.3).then(function(buffer){
expect(buffer.getLastSoundTime()).to.be.closeTo(0.1, 0.02);
});
meter.test(function(sample, time){
if (sample < 0.001){
expect(time).to.at.least(0.1);
expect(player.state).to.equal("stopped");
}
});
meter.after(function(){
player.dispose();
done();
});
meter.run();
});
it("reports itself as stopped after a single iterations of the buffer", function(done){
var player = new Player("./audio/short_sine.wav", function(){
var duration = player.buffer.duration;
it("reports itself as stopped after a single iterations of the buffer", function(){
return Offline(function(){
var player = new Player(buffer).toMaster();
player.start();
setTimeout(function(){
expect(player.state).to.equal("stopped");
done();
}, duration * 1000 + 200);
return function(time){
Test.whenBetween(time, buffer.duration, Infinity, function(){
expect(player.state).to.equal("stopped");
});
Test.whenBetween(time, 0, buffer.duration, function(){
expect(player.state).to.equal("started");
});
};
});
});
});
});
});

View file

@ -9,54 +9,42 @@ define(["helper/Basic", "Tone/source/PulseOscillator", "helper/Offline", "helper
OscillatorTests(PulseOscillator);
context("Phase Rotation", function(){
it ("can change the phase to 90", function(done){
var instance;
var offline = new Offline(1);
offline.before(function(dest){
instance = new PulseOscillator({
it ("can change the phase to 90", function(){
return Offline(function(){
var osc = new PulseOscillator({
"phase" : 90,
"frequency" : 1
});
instance.connect(dest);
instance.start(0);
osc.toMaster();
osc.start(0);
}, 1).then(function(buffer){
buffer.forEach(function(sample, time){
if (time < 0.25){
expect(sample).to.be.within(-1, 0);
} else if (time < 0.5){
expect(sample).to.be.within(0, 1);
}
});
});
offline.test(function(sample, time){
if (time < 0.25){
expect(sample).to.be.within(-1, 0);
} else if (time < 0.5){
expect(sample).to.be.within(0, 1);
}
});
offline.after(function(){
instance.dispose();
done();
});
offline.run();
});
it ("can change the phase to -90", function(done){
var instance;
var offline = new Offline(1);
offline.before(function(dest){
instance = new PulseOscillator({
it ("can change the phase to -90", function(){
return Offline(function(){
var osc = new PulseOscillator({
"phase" : 270,
"frequency" : 1
});
instance.connect(dest);
instance.start(0);
osc.toMaster();
osc.start(0);
}, 1).then(function(buffer){
buffer.forEach(function(sample, time){
if (time < 0.25){
expect(sample).to.be.within(0, 1);
} else if (time < 0.5){
expect(sample).to.be.within(-1, 0);
}
});
});
offline.test(function(sample, time){
if (time < 0.25){
expect(sample).to.be.within(0, 1);
} else if (time < 0.5){
expect(sample).to.be.within(-1, 0);
}
});
offline.after(function(){
instance.dispose();
done();
});
offline.run();
});
});
@ -71,58 +59,42 @@ define(["helper/Basic", "Tone/source/PulseOscillator", "helper/Offline", "helper
osc.dispose();
});
it ("outputs correctly with a width of 0", function(done){
var osc;
var offline = new Offline(1);
offline.before(function(dest){
osc = new PulseOscillator({
it ("outputs correctly with a width of 0", function(){
return Offline(function(){
var osc = new PulseOscillator({
"width" : 0,
"frequency" : 1
});
osc.connect(dest);
osc.toMaster();
osc.start(0);
}, 1).then(function(buffer){
buffer.forEach(function(sample, time){
if (time > 0.5){
expect(sample).to.be.within(-1, 0);
}
});
});
var lastTime = 0;
offline.test(function(sample, time){
lastTime = time;
if (time > 0.5){
expect(sample).to.be.within(-1, 0);
}
});
offline.after(function(){
osc.dispose();
done();
});
offline.run();
});
it ("outputs correctly with a width of 0.5", function(done){
var osc;
var offline = new Offline(1);
offline.before(function(dest){
osc = new PulseOscillator({
it ("outputs correctly with a width of 0.5", function(){
return Offline(function(){
var osc = new PulseOscillator({
"width" : 0.5,
"frequency" : 1
});
osc.connect(dest);
osc.toMaster();
osc.start(0);
}, 1).then(function(buffer){
buffer.forEach(function(sample, time){
if (time <= 0.5){
expect(sample).to.be.within(0, 1);
} else if (time >= 0.51 && time <= 0.7){
expect(sample).to.be.within(-1, 0);
} else if (time > 0.71){
expect(sample).to.be.within(0, 1);
}
});
});
var lastTime = 0;
offline.test(function(sample, time){
lastTime = time;
if (time <= 0.5){
expect(sample).to.be.within(0, 1);
} else if (time >= 0.51 && time <= 0.7){
expect(sample).to.be.within(-1, 0);
} else if (time > 0.71){
expect(sample).to.be.within(0, 1);
}
});
offline.after(function(){
osc.dispose();
done();
});
offline.run();
});
});

View file

@ -1,5 +1,5 @@
define(["Test", "Tone/source/Source", "Tone/core/Transport", "helper/Offline2", "Tone/core/Tone"],
function (Test, Source, Transport, OfflineTest, Tone) {
define(["Test", "Tone/source/Source", "Tone/core/Transport", "helper/Offline", "Tone/core/Tone"],
function (Test, Source, Transport, Offline, Tone) {
describe("Source", function(){
@ -89,77 +89,71 @@ function (Test, Source, Transport, OfflineTest, Tone) {
source.dispose();
});
it ("correctly returns the scheduled play state", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("correctly returns the scheduled play state", function(){
return Offline(function(){
var source = new Source();
expect(source.state).to.equal("stopped");
source.start(0).stop(0.5);
testFn(function(sample, time){
return function(time){
if (time >= 0 && time < 0.5){
expect(source.state).to.equal("started");
} else if (time > 0.5){
expect(source.state).to.equal("stopped");
}
});
tearDown(function(){
source.dispose();
done();
});
};
}, 0.6);
});
context("sync", function(){
it ("can sync its start to the Transport", function(){
var source = new Source();
source.sync().start(0);
expect(source.state).to.equal("stopped");
Tone.Transport.start(Tone.now());
expect(source.state).to.equal("started");
source.dispose();
Tone.Transport.stop();
return Offline(function(Transport){
var source = new Source();
source.sync().start(0);
expect(source.state).to.equal("stopped");
Transport.start(Tone.now());
expect(source.state).to.equal("started");
source.dispose();
Transport.stop();
});
});
it ("can unsync after it was synced", function(){
var source = new Source();
source.sync().start(0);
source.unsync();
Tone.Transport.start();
expect(source.state).to.equal("stopped");
return Offline(function(Transport){
var source = new Source();
source.sync().start(0);
source.unsync();
Transport.start();
expect(source.state).to.equal("stopped");
});
});
it ("can sync its stop to the Transport", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("can sync its stop to the Transport", function(){
return Offline(function(Transport){
var source = new Source();
source.sync().start(0);
expect(source.state).to.equal("stopped");
Tone.Transport.start(0).stop(0.4);
Transport.start(0).stop(0.4);
expect(source.state).to.equal("started");
testFn(function(sample, time){
return function(time){
if (time > 0.4){
expect(source.state).to.equal("stopped");
}
});
tearDown(function(){
source.dispose();
done();
});
};
}, 0.5);
});
it ("can schedule multiple starts/stops", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("can schedule multiple starts/stops", function(){
return Offline(function(Transport){
var source = new Source();
source.sync().start(0.1).stop(0.2).start(0.3);
Tone.Transport.start(0).stop(0.4);
Transport.start(0).stop(0.4);
expect(source.state).to.equal("stopped");
testFn(function(sample, time){
return function(time){
if (time > 0.1 && time < 0.19){
expect(source.state).to.equal("started");
} else if (time > 0.2 && time < 0.29){
@ -169,87 +163,69 @@ function (Test, Source, Transport, OfflineTest, Tone) {
} else if (time > 0.4){
expect(source.state).to.equal("stopped");
}
});
tearDown(function(){
source.dispose();
done();
});
};
}, 0.6);
});
it ("has correct offset when the transport is started with an offset", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("has correct offset when the transport is started with an offset", function(){
return Offline(function(Transport){
var source = new Source();
source.sync().start(0.3).stop(0.4);
Tone.Transport.start(0, 0.1);
Transport.start(0, 0.1);
expect(source.state).to.equal("stopped");
testFn(function(sample, time){
return function(sample, time){
if (time > 0.21 && time < 0.29){
expect(source.state).to.equal("started");
} else if (time > 0.3){
expect(source.state).to.equal("stopped");
}
});
tearDown(function(){
source.dispose();
done();
});
};
}, 0.5);
});
it ("can start with an offset after the start time of the source", function(){
var source = new Source();
source.sync().start(0);
Tone.Transport.start(0, 0.1);
expect(source.state).to.equal("started");
source.dispose();
return Offline(function(Transport){
var source = new Source();
source.sync().start(0);
Transport.start(0, 0.1);
expect(source.state).to.equal("started");
source.dispose();
}, 0.1);
});
it ("can sync its start to the Tone.Transport after a delay", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("can sync its start to the Transport after a delay", function(){
return Offline(function(Transport){
var source = new Source();
source.sync().start(0.3);
Tone.Transport.start(0).stop(0.4);
Transport.start(0).stop(0.4);
expect(source.state).to.equal("stopped");
testFn(function(sample, time){
return function(time){
if (time > 0.3 && time < 0.39){
expect(source.state).to.equal("started");
} else if (time > 0.4){
expect(source.state).to.equal("stopped");
}
});
tearDown(function(){
source.dispose();
done();
});
};
}, 0.6);
});
it ("correct state when the Transport position is changed", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("correct state when the Transport position is changed", function(){
return Offline(function(Transport){
var source = new Source();
source.sync().start(0.3).stop(0.4);
Tone.Transport.start(0).stop(0.4);
Transport.start(0).stop(0.4);
expect(source.state).to.equal("stopped");
Tone.Transport.seconds = 0.305;
Transport.seconds = 0.305;
expect(source.state).to.equal("started");
Tone.Transport.seconds = 0.405;
Transport.seconds = 0.405;
expect(source.state).to.equal("stopped");
tearDown(function(){
source.dispose();
done();
});
}, 0.1);
});
it ("gives the correct offset on time on start/stop events", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("gives the correct offset on time on start/stop events", function(){
return Offline(function(Transport){
var source = new Source();
source._start = function(time, offset){
expect(time).to.be.closeTo(0.4, 0.05);
@ -261,17 +237,12 @@ function (Test, Source, Transport, OfflineTest, Tone) {
};
source.sync().start(0.2, 0.1).stop(0.3);
Tone.Transport.start(0.2);
tearDown(function(){
source.dispose();
done();
});
Transport.start(0.2);
}, 0.7);
});
it ("gives the correct offset on time on start/stop events invoked with an Transport offset", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("gives the correct offset on time on start/stop events invoked with an Transport offset", function(){
return Offline(function(Transport){
var source = new Source();
source._start = function(time, offset){
expect(time).to.be.closeTo(0.3, 0.05);
@ -283,18 +254,12 @@ function (Test, Source, Transport, OfflineTest, Tone) {
};
source.sync().start(0.2, 0.1).stop(0.3);
Tone.Transport.start(0.2, 0.1);
tearDown(function(){
source.dispose();
done();
});
Transport.start(0.2, 0.1);
}, 0.7);
});
it ("gives the correct offset on time on start/stop events invoked with an Transport offset that's in the middle of the event", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("gives the correct offset on time on start/stop events invoked with an Transport offset that's in the middle of the event", function(){
return Offline(function(Transport){
var source = new Source();
source._start = function(time, offset){
expect(time).to.be.closeTo(0.2, 0.05);
@ -307,17 +272,13 @@ function (Test, Source, Transport, OfflineTest, Tone) {
source.sync().start(0.2, 0.1).stop(0.3);
Tone.Transport.start(0.2, 0.25);
Transport.start(0.2, 0.25);
tearDown(function(){
source.dispose();
done();
});
}, 0.7);
});
it ("gives the correct duration when invoked with an Transport offset that's in the middle of the event", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("gives the correct duration when invoked with an Transport offset that's in the middle of the event", function(){
return Offline(function(){
var source = new Source();
source._start = function(time, offset, duration){
expect(time).to.be.closeTo(0, 0.05);
@ -330,18 +291,12 @@ function (Test, Source, Transport, OfflineTest, Tone) {
};
source.sync().start(0.2, 0.1, 0.4).stop(0.4);
Tone.Transport.start(0, 0.3);
tearDown(function(){
source.dispose();
done();
});
Transport.start(0, 0.3);
}, 0.7);
});
it ("stops at the right time when Transport.stop is invoked before the scheduled stop", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("stops at the right time when Transport.stop is invoked before the scheduled stop", function(){
return Offline(function(Transport){
var source = new Source();
source._stop = function(time){
@ -349,24 +304,19 @@ function (Test, Source, Transport, OfflineTest, Tone) {
};
source.sync().start(0.2).stop(0.4);
Tone.Transport.start(0).stop(0.3);
tearDown(function(){
source.dispose();
done();
});
Transport.start(0).stop(0.3);
}, 0.7);
});
it ("invokes the right methods and offsets when the transport is seeked", function(done){
OfflineTest(function(output, testFn, tearDown){
it ("invokes the right methods and offsets when the transport is seeked", function(){
var invoked = false;
return Offline(function(Transport){
var source = new Source();
var seeked = false;
source._start = function(time, offset){
if(seeked){
invoked = true;
expect(time).to.be.closeTo(0.1, 0.05);
expect(offset).to.be.closeTo(0.15, 0.05);
} else {
@ -381,21 +331,15 @@ function (Test, Source, Transport, OfflineTest, Tone) {
};
source.sync().start(0.2);
Transport.start(0, 0.3);
Tone.Transport.start(0, 0.3);
testFn(function(samples, time){
if (time === 0.1){
seeked = true;
Tone.Transport.seconds = 0.35;
}
return Test.atTime(0.1, function(){
seeked = true;
Transport.seconds = 0.35;
});
tearDown(function(){
source.dispose();
done();
});
}, 0.7);
}, 0.7).then(function(){
expect(invoked).to.be.true;
});
});
});
});