Hi, I’m new to this community and p5 so forgive me if I ask something silly, but here is my problem.
I have a part with a phrase and I’m now trying to add the part to a score because I want to be able to play more parts later on. When I play the part by itself it works, but playing the score with that part does not work and triggers
Uncaught TypeError: Cannot read property 'start' of undefined (sketch: line 34)
I’m not sure what I do wrong, I initiate a new score with my part “preroll”:
So yes, if I understand correctly my part in score = new p5.Score(preroll); is not loaded at all. Looking at the main Score function p5.Score = function() { it does not seem to take any parameters to fill the this.parts = []; array, so we might just need to add a parameter for parts right? Something like:
p5.Score = function (parts) {
// for all of the arguments
this.parts = parts;
this.currentPart = 0;
var thisScore = this;
for (var i in arguments) {
if (arguments[i] && this.parts[i]) {
this.parts[i] = arguments[i];
this.parts[i].nextPart = this.parts[i + 1];
this.parts[i].onended = function () {
thisScore.resetPart(i);
playNextPart(thisScore);
};
}
}
this.looping = false;
};
well, yes and no, I’ve created an issue at the repository, but in the mean time, I just hack the p5.sound.js file myself with the above change and that works. I did run into more issues later on when I tried to do more complicated stuff so I ended up organising my own parts, but this should get you going if all you need is a container for your parts. Of course be aware that updating your package will overwrite your changes so you might want to either not update or self host.