Open francescosoave opened 6 years ago
have any solutions?
not from me I'm afraid
it should work, but might be file-specific. i realize i've taken a very long time to respond to this, but if you could provide me with an example problem file, that'd be great.
It would also be helpful to know which class sound
is in this case.
Hello, thanks for the reply. I was using mp3 files. I can't attach them here but I'm happy to send them over in whatever way is good for you.
sound is just sound = minim.loadFile("/data/samples/sample1.mp3");
If you could possibly share them via Dropbox or something similar, that'd be fantastic.
in order to have it working I was doing something like
if(sound.position() >= sound.length()-200){ //do stuff }
Thanks, I was able to reproduce the issue with these files and should be able to dig into it later today or tomorrow.
Ok, after looking into this for a bit, I've determined that the problem is that the length()
of the files is being misreported due to how it is determined by Minim. In all cases the length is longer than it should be. This means that when playing normally, the end of the file is reached before position()
is equal to length()
.
Attempting to fix this properly is going to take a while, I think, due to the fact that Minim still contains a hacky workaround for how it deals with mp3 metadata. It may also turn out that it's unfixable (or require a patched version of mp3spi), since my attempt at a quick fix is essentially the same as what mp3spi does internally, which means it might be the case that the mp3spi library will also report an incorrect length()
for these files. It's not clear to me yet whether or not this is a bug, however.
In the meantime, if all you are doing is calling play()
and then want to poll for when the file finishes playing, it should suffice to check isPlaying()
, which will switch to false
when it reaches the end of the file. At least this is what happens with current code.
Also, is it OK if I include the mp3 files you shared in this repo as part of a test case?
hi, thanks for the reply. yes you can include 2 of them (I don't own the rights for the percussion track)
Hi, I'm not sure if this is a bug of if I missed something however I see that the sound.position() value never reaches the sound.length(). Is this normal or not? I'm using Processing 3.1.1
basically I was trying to do the following but the condition will never become true
for instance these are the final values I get if I run
println(sound.position() + " - " + (sound.length()))