2019-01-27 18:05:20 +00:00
|
|
|
import Convolver from "Tone/effect/Convolver";
|
|
|
|
import Basic from "helper/Basic";
|
|
|
|
import EffectTests from "helper/EffectTests";
|
|
|
|
import Buffer from "Tone/core/Buffer";
|
2016-08-09 18:25:20 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
if (window.__karma__){
|
|
|
|
Buffer.baseUrl = "/base/test/";
|
|
|
|
}
|
2016-08-09 18:25:20 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
describe("Convolver", function(){
|
2015-08-28 02:56:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Basic(Convolver);
|
2015-08-28 02:56:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
var ir = new Buffer();
|
2015-08-28 02:56:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
var testFile = "./audio/sineStereo.wav";
|
2016-03-05 05:07:17 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
before(function(done){
|
|
|
|
ir.load(testFile, function(){
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
context("API", function(){
|
|
|
|
|
|
|
|
it("can pass in options in the constructor", function(){
|
|
|
|
var convolver = new Convolver({
|
|
|
|
"url" : testFile,
|
|
|
|
"normalize" : false
|
|
|
|
});
|
|
|
|
expect(convolver.normalize).to.be.false;
|
|
|
|
convolver.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("can get set normalize", function(){
|
|
|
|
var convolver = new Convolver();
|
|
|
|
convolver.normalize = false;
|
|
|
|
expect(convolver.normalize).to.be.false;
|
|
|
|
convolver.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("invokes the onload function when loaded", function(done){
|
|
|
|
var convolver = new Convolver({
|
|
|
|
"url" : testFile,
|
|
|
|
"onload" : function(){
|
|
|
|
convolver.dispose();
|
2017-12-30 16:26:29 +00:00
|
|
|
done();
|
2019-01-27 18:05:20 +00:00
|
|
|
}
|
2015-08-28 02:56:35 +00:00
|
|
|
});
|
2019-01-27 18:05:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("load returns a Promise", function(done){
|
|
|
|
var convolver = new Convolver();
|
|
|
|
convolver.load(testFile).then(function(){
|
|
|
|
convolver.dispose();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2015-08-28 02:56:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("load invokes the second callback", function(done){
|
|
|
|
var convolver = new Convolver();
|
|
|
|
convolver.load(testFile, function(){
|
|
|
|
convolver.dispose();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2015-08-28 02:56:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can assign the buffer twice", function(){
|
|
|
|
var convolver = new Convolver(ir);
|
|
|
|
convolver.buffer = ir;
|
|
|
|
convolver.dispose();
|
|
|
|
});
|
2015-08-28 02:56:35 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can be constructed with a buffer", function(){
|
|
|
|
var convolver = new Convolver(ir);
|
|
|
|
expect(convolver.buffer.get()).to.equal(ir.get());
|
|
|
|
convolver.dispose();
|
|
|
|
});
|
2018-09-10 16:17:51 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can be constructed with loaded buffer", function(done){
|
|
|
|
var buffer = new Buffer({
|
|
|
|
"url" : testFile,
|
|
|
|
"onload" : function(){
|
|
|
|
var convolver = new Convolver(buffer);
|
|
|
|
expect(convolver.buffer).is.not.null;
|
|
|
|
buffer.dispose();
|
2017-12-30 16:26:29 +00:00
|
|
|
convolver.dispose();
|
2019-01-27 18:05:20 +00:00
|
|
|
done();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2016-11-22 18:31:06 +00:00
|
|
|
|
2019-01-27 18:05:20 +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.not.null;
|
2017-12-16 04:36:39 +00:00
|
|
|
convolver.dispose();
|
|
|
|
done();
|
2019-01-27 18:05:20 +00:00
|
|
|
}
|
|
|
|
})
|
2017-12-16 04:36:39 +00:00
|
|
|
});
|
2019-01-31 17:14:09 +00:00
|
|
|
//is null before then
|
|
|
|
expect(convolver.buffer).to.be.null;
|
2015-08-28 02:56:35 +00:00
|
|
|
});
|
|
|
|
});
|
2019-01-27 18:05:20 +00:00
|
|
|
});
|
|
|
|
|