I am a relative newbie to coding but I have been working really hard on a project that uses the p5.Sound library in p5.js. The problem was that the stop() method was not working the way it said it should on the documentation. So I started analyzing the p5.Sound library and discovered a very simple, very tiny fix.
This is the way it is currently in the code:
p5.Part.prototype.stop = function (time) {
this.partStep = 0;
this.pause(time);
};
This is the fix:
p5.Part.prototype.stop = function (time) {
this.partStep = 0;
this.metro.metroTicks = 0;
this.pause(time);
};
I’ve tried it out with a few different projects on a local proxy server and it works a charm.
How does one go about making this change in the main library?
Again, I am just resetting the partStep to 0. The issue was that if you used the stop() method before in a p5.Part instance it would reset the metroticks, essentially placing a new start/end point for your phrase, but it would not bring you back to the beginning of the phrase. This is not a fix for the oscillator feature in p5. Sound, but for Part. See reference below.
Even on the reference, it says that it will “Stop the part and cue it to step 0. Playback will resume from the begining of the Part when it is played again.”, but again, it won’t do this unless you include: this.partStep = 0
I hope that makes things more clear. I don’t know how or who could actually change this in the p5.Sound library file, but it would make the program I am currently working on in the web editor much better. Thanks