Skip to content
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

Fix parsing of low-sample-rate MP3 files. #196

Merged
merged 4 commits into from
Jan 29, 2023

Conversation

psobot
Copy link
Member

@psobot psobot commented Jan 29, 2023

Fixes #192.

Another bug in JUCE's MP3AudioFormat: when reading MP3 files, some files with low sample rates have their durations incorrectly estimated. Reading frames from these files works just fine, but Pedalboard reports that they're longer than they actually are, resulting in RuntimeErrors when trying to read the f.frames.

This PR fixes the issue by properly implementing the part of the MP3 spec that specifies the number of samples per MP3 frame:
image

The parser is also changed slightly to not throw an error if the stream runs out of MP3 frames while parsing is still in progress, but instead to pad the end of the stream (from f.tell() through f.frames) with zeroes, as is the convention in JUCE.

@psobot psobot added the bug Something isn't working label Jan 29, 2023
@psobot psobot merged commit d55322a into master Jan 29, 2023
@psobot psobot deleted the psobot/fix-low-sample-rate-mp3-duration branch January 29, 2023 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to read() AudioFile of an MP3 in remote environment
1 participant