-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
positionMillis() time units are not milliseconds #16
Comments
Yes, this is a known problem. Does not seem very important, the last few years no one missed this :) I know this is not a satisfying answer :) |
I understand, even after a cursory glance at the structure of AAC and MP3, getting even a roughly accurate duration or seek position value looks like quite a task! |
just stumbled opon the same issue. This works for me:
(Sample rate is samples per second, so we need to check how many seconds we already played and multiply with 1000 to convert to milliseconds) |
|
I observed the same issue in positionMillis() ... see also https://forum.pjrc.com/index.php?threads/frankbs-arduino-teensy-codec-lib-playing-mp3.73819/ lengthMillis() is definitely wrong because of possibly changing bitrate from one audio frame to the next. |
Firstly, this is a fantastic library and has worked straight out of the box to play AAC and MP3 files for my SD audio projects!
Delving a little deeper though, I'm trying to use the positionMillis() function to get the elapsed time of a playing track on a Teensy 4.1 using Arduino 1.8.16 and Teensyduino 1.55. In the standard Teensy Audio library, this is returns the elapsed time in milliseconds, however for the play_sd_aac library the value appears to be ~1950x greater than expected. What unit of time should be returned by positionMillis()?
This is a short example comparing the normal Arduino millis() and position.Millis(). The file did not start playing at millis() == 0, but this demonstrates the discrepancy in relative change between the two values:
These values were generated as part of a larger project thus:
songPos = playAac1.positionMillis()
Serial.print(millis());
Serial.print("...");
Serial.print(songPos);
Serial.print("...");
If need be, I can knock up a full test to replicate the issue.
The text was updated successfully, but these errors were encountered: