Skip to content

positionMillis() time units are not milliseconds #16

@thecomfychair2

Description

@thecomfychair2

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:

millis() positionMillis()
16843 19694706
16853 19717286
16863 19734220
16873 19751154
16883 19773734
16893 19790668
16903 19813248
16913 19830182
16923 19852760
16933 19869696
16943 19892274
16953 19909208
16963 19931788
16973 19948722
16983 19965656
16993 19988236
17003 20005170
17013 20027750
17023 20044684
17033 20067264
17043 20084198
17054 20106776
17064 20123712
17074 20146290
17084 20163224
17094 20180160
17104 20202738
17114 20219672
17124 20242252
17134 20259186
17144 20281766
17154 20298700
17164 20321280
17174 20338214
17184 20355148
17194 20377728
17204 20394662
17214 20417240

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions