Skip to content

Commit 282274a

Browse files
authored
fixed issue with p5.Score that prevented 'parts' from being passed as argument (#543)
This is related to an issue here: #529 It doesn't look like p5.Score is currently functional because it fails to fill the 'parts' array with the function arguments, due to a conditional that doesn't seem to be necessary. With this said, is there a way to provide a better error message to provide when p5.Score is missing phrases? Currently when p5.Score is provided no arguments, it returns Cannot read property 'start' of undefined. I imagine just checking if the function call has any arguments would be enough, but not sure if there is a case where that needs to be allowed. Also, I would be happy to work on converting this to es6 and writing out some tests, if that would be helpful for this class.
1 parent 22d3ea5 commit 282274a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/looper.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -387,18 +387,16 @@ class Score {
387387
constructor() {
388388
// for all of the arguments
389389
this.parts = [];
390-
this.currentPart = 0;
390+
this.currentPart = new Array(arguments.length);;
391391

392392
var thisScore = this;
393393
for (var i in arguments) {
394-
if (arguments[i] && this.parts[i]) {
395-
this.parts[i] = arguments[i];
396-
this.parts[i].nextPart = this.parts[i + 1];
397-
this.parts[i].onended = function () {
398-
thisScore.resetPart(i);
399-
playNextPart(thisScore);
400-
};
401-
}
394+
this.parts[i] = arguments[i];
395+
this.parts[i].nextPart = this.parts[i + 1];
396+
this.parts[i].onended = function () {
397+
thisScore.resetPart(i);
398+
playNextPart(thisScore);
399+
};
402400
}
403401
this.looping = false;
404402
}

0 commit comments

Comments
 (0)