mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-15 16:17:58 +00:00
parent
aa92ea6162
commit
bcd22b0463
2 changed files with 38 additions and 2 deletions
|
@ -358,7 +358,7 @@ Tone.Part.prototype._tick = function(time, value){
|
|||
* @private
|
||||
*/
|
||||
Tone.Part.prototype._testLoopBoundries = function(event){
|
||||
if (event.startOffset < this._loopStart || event.startOffset >= this._loopEnd){
|
||||
if (this._loop && (event.startOffset < this._loopStart || event.startOffset >= this._loopEnd)){
|
||||
event.cancel(0);
|
||||
} else if (event.state === Tone.State.Stopped){
|
||||
//reschedule it if it's stopped
|
||||
|
|
|
@ -422,7 +422,7 @@ describe("Part", function(){
|
|||
|
||||
context("Looping", function(){
|
||||
|
||||
it("can be set to loop", function(){
|
||||
it("can be set using a boolean as an argument when created", function(){
|
||||
var callCount = 0;
|
||||
return Offline(function(Transport){
|
||||
new Part({
|
||||
|
@ -439,6 +439,42 @@ describe("Part", function(){
|
|||
});
|
||||
});
|
||||
|
||||
it("can be toggled off using a boolean", function(){
|
||||
var callCount = 0;
|
||||
return Offline(function(Transport){
|
||||
var part = new Part({
|
||||
"loopEnd" : 0.2,
|
||||
"loop" : true,
|
||||
"callback" : function(){
|
||||
callCount++;
|
||||
},
|
||||
"events" : [[0, 1], [0.1, 2]]
|
||||
}).start(0);
|
||||
part.loop = false;
|
||||
Transport.start();
|
||||
}, 0.55).then(function(){
|
||||
expect(callCount).to.equal(2);
|
||||
});
|
||||
});
|
||||
|
||||
it("can be toggled on using a boolean", function(){
|
||||
var callCount = 0;
|
||||
return Offline(function(Transport){
|
||||
var part = new Part({
|
||||
"loopEnd" : 0.2,
|
||||
"loop" : false,
|
||||
"callback" : function(){
|
||||
callCount++;
|
||||
},
|
||||
"events" : [[0, 1], [0.1, 2]]
|
||||
}).start(0);
|
||||
part.loop = true;
|
||||
Transport.start();
|
||||
}, 0.55).then(function(){
|
||||
expect(callCount).to.equal(6);
|
||||
});
|
||||
});
|
||||
|
||||
it("can be set to loop at a specific interval", function(){
|
||||
var invoked = false;
|
||||
return Offline(function(Transport){
|
||||
|
|
Loading…
Reference in a new issue