currentTime resets to 0
When I play the file, currentTime() increases as normal, but when I call pause() it resets to 0, but when I play it again, it goes back to whatever time you called pause at.
I've noticed this too, but I can't tell if it is intended or not. My guess is that maybe it is p5.sound's current way of eliminating DC in the signal when paused.
What I have done to circumvent it in a sound file player where I want the playhead to maintain the position point when paused, is to store a snapshot of currentTime() into a variable right before calling pause(), and using that variable to draw the playhead in the case that the soundfile is paused.
//inside event listener
if (!mySound.isPlaying()) {
mySound.play();
} else {
pausedSoundTimePoint = mySound.currentTime(); // <- snapshot currentTime() before pausing
mySound.pause();
}
then when drawing the playhead, toggle between using pausedSoundTimePoint and currentTime() based on whether or not the soundfile is playing...
//inside draw function
if (!mySound.isPlaying()) {
soundCurrentTime = pausedSoundTimePoint;
} else {
soundCurrentTime = mySound.currentTime();
}
line(soundCurrentTime*width/soundDuration, 0, soundCurrentTime*width/grooveDuration, height);
VM4 315bf5aa-9268-4520-8629-6fd178e08add:75 Uncaught TypeError: Cannot read property 'length' of undefined
at RingBuffer.push (VM4 315bf5aa-9268-4520-8629-6fd178e08add:75)
at AudioWorkletProcessor.process (VM4 315bf5aa-9268-4520-8629-6fd178e08add:170)
It seems there's a bug in p5sound.
I get the above in the console when trying to getCurrentTime(). I only ever get zero back
Here's my example: https://editor.p5js.org/everythingability/sketches/cp7Csqzid
Fixed by #542, but not released I think - current release of p5 doesn't have this fix.