mirror of
https://github.com/Tonejs/Tone.js
synced 2025-01-20 07:43:54 +00:00
64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
|
define(["Tone/instrument/Sampler", "helper/Basic", "helper/InstrumentTests", "Tone/core/Buffer"],
|
||
|
function (Sampler, Basic, InstrumentTest, Buffer) {
|
||
|
|
||
|
describe("Sampler", function(){
|
||
|
|
||
|
var buffer = new Buffer();
|
||
|
|
||
|
beforeEach(function(done){
|
||
|
buffer.load("./audio/sine.wav", function(){
|
||
|
done();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
Basic(Sampler);
|
||
|
InstrumentTest(Sampler, 1, buffer);
|
||
|
|
||
|
context("API", function(){
|
||
|
|
||
|
it ("invokes the callback with the constructor", function(done){
|
||
|
var sampler = new Sampler("./audio/sine.wav", function(){
|
||
|
sampler.dispose();
|
||
|
done();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
it ("can get and set envelope attributes", function(){
|
||
|
var sampler = new Sampler();
|
||
|
sampler.envelope.attack = 0.24;
|
||
|
expect(sampler.envelope.attack).to.equal(0.24);
|
||
|
sampler.dispose();
|
||
|
});
|
||
|
|
||
|
it ("can be constructed with an options object", function(){
|
||
|
var sampler = new Sampler({
|
||
|
"envelope" : {
|
||
|
"sustain" : 0.3
|
||
|
}
|
||
|
});
|
||
|
expect(sampler.envelope.sustain).to.equal(0.3);
|
||
|
sampler.dispose();
|
||
|
});
|
||
|
|
||
|
it ("can get/set attributes", function(){
|
||
|
var sampler = new Sampler();
|
||
|
sampler.set({
|
||
|
"envelope.decay" : 0.24
|
||
|
});
|
||
|
expect(sampler.get().envelope.decay).to.equal(0.24);
|
||
|
sampler.dispose();
|
||
|
});
|
||
|
|
||
|
it ("can be set to loop and reverse", function(){
|
||
|
var sampler = new Sampler({
|
||
|
loop : true,
|
||
|
reverse : true,
|
||
|
});
|
||
|
expect(sampler.reverse).to.be.true;
|
||
|
expect(sampler.loop).to.be.true;
|
||
|
sampler.dispose();
|
||
|
});
|
||
|
|
||
|
});
|
||
|
});
|
||
|
});
|