Tone.js/test/effect/Convolver.js

89 lines
2.1 KiB
JavaScript
Raw Normal View History

define(["Tone/effect/Convolver", "helper/Basic", "helper/EffectTests", "Tone/core/Buffer"],
2017-12-30 16:26:29 +00:00
function (Convolver, Basic, EffectTests, Buffer) {
2017-12-30 16:26:29 +00:00
if (window.__karma__){
Buffer.baseUrl = "/base/test/";
}
2017-12-30 16:26:29 +00:00
describe("Convolver", function(){
2017-12-30 16:26:29 +00:00
Basic(Convolver);
2017-12-30 16:26:29 +00:00
var ir = new Buffer();
2017-12-30 16:26:29 +00:00
var testFile = "./audio/sineStereo.wav";
2016-03-05 05:07:17 +00:00
2017-12-30 16:26:29 +00:00
before(function(done){
ir.load(testFile, function(){
done();
});
});
2017-12-30 16:26:29 +00:00
// the buffers are set to 44.1 Khz, but i always get this error:
// Error: Failed to set the 'buffer' property on 'ConvolverNode': The buffer sample rate of 48000 does not match the context rate of 44100 Hz.
// EffectTests(Convolver, ir);
2017-12-30 16:26:29 +00:00
context("API", function(){
2017-12-30 16:26:29 +00:00
it("can pass in options in the constructor", function(){
var convolver = new Convolver({
"url" : testFile,
});
convolver.dispose();
});
2016-11-22 18:31:06 +00:00
2017-12-30 16:26:29 +00:00
it("invokes the onload function when loaded", function(done){
var convolver = new Convolver({
"url" : testFile,
"onload" : function(){
convolver.dispose();
done();
}
});
2016-11-22 18:31:06 +00:00
});
2017-12-30 16:26:29 +00:00
it("load returns a Promise", function(done){
var convolver = new Convolver();
convolver.load(testFile).then(function(){
convolver.dispose();
done();
});
2016-11-22 18:31:06 +00:00
});
2017-12-30 16:26:29 +00:00
it("load invokes the second callback", function(done){
var convolver = new Convolver();
convolver.load(testFile, function(){
convolver.dispose();
done();
2017-12-30 16:26:29 +00:00
});
});
2017-12-30 16:26:29 +00:00
it("can be constructed with loaded buffer", function(done){
var buffer = new Buffer({
"url" : testFile,
"onload" : function(){
2017-12-30 16:26:29 +00:00
var convolver = new Convolver(buffer);
expect(convolver.buffer).is.instanceOf(AudioBuffer);
2017-12-30 16:26:29 +00:00
buffer.dispose();
convolver.dispose();
done();
}
2017-12-30 16:26:29 +00:00
});
});
it("can be constructed with unloaded buffer", function(done){
var convolver = new Convolver({
"url" : new Buffer({
"url" : testFile,
"onload" : function(){
expect(convolver.buffer).is.instanceOf(AudioBuffer);
convolver.dispose();
done();
}
})
});
});
});
});
});