Tone.js/test/component/Waveform.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-05-18 16:07:20 +00:00
define(["Tone/component/Waveform", "helper/Test", "helper/Basic", "Tone/source/Noise"],
function(Waveform, Test, Basic, Noise){
2017-12-30 16:26:29 +00:00
describe("Waveform", function(){
2017-12-30 16:26:29 +00:00
Basic(Waveform);
2017-12-30 16:26:29 +00:00
it("handles input connection", function(){
var anl = new Waveform();
Test.connect(anl);
anl.dispose();
});
2017-12-30 16:26:29 +00:00
it("can get and set properties", function(){
var anl = new Waveform();
anl.set({
"size" : 128
});
var values = anl.get();
expect(values.size).to.equal(128);
anl.dispose();
});
2017-12-30 16:26:29 +00:00
it("can correctly set the size", function(){
var anl = new Waveform(512);
expect(anl.size).to.equal(512);
anl.size = 1024;
expect(anl.size).to.equal(1024);
anl.dispose();
});
2017-12-30 16:26:29 +00:00
it("can run waveform analysis", function(done){
var noise = new Noise();
var anl = new Waveform(256);
noise.connect(anl);
noise.start();
setTimeout(function(){
analysis = anl.getValue();
expect(analysis.length).to.equal(256);
for (i = 0; i < analysis.length; i++){
expect(analysis[i]).is.within(-1, 1);
}
anl.dispose();
noise.dispose();
done();
}, 300);
});
});
});