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

Return an integer for AudioFile.samplerate when possible. #236

Merged
merged 2 commits into from
Aug 1, 2023

Conversation

psobot
Copy link
Member

@psobot psobot commented Aug 1, 2023

Pedalboard internally represents sample rates as floating-point numbers; however, the vast majority of sample rates used in production are integers (like 44100, 48000, etc).

This PR changes the AudioFile class to return an integer for the samplerate property if the fractional part of the sample rate is 0. This will make it possible to do things like passing f.samplerate to the f.read method directly, without needing to cast to int first.

This PR also makes it possible to pass a floating-point number to AudioFile.read. An exception will be thrown if the provided number has a fractional part.

@psobot psobot added the enhancement New feature or request label Aug 1, 2023
@psobot psobot requested a review from drubinstein August 1, 2023 17:19
@psobot psobot merged commit fad61f8 into master Aug 1, 2023
25 checks passed
@psobot psobot deleted the psobot/sample-rate-int branch August 1, 2023 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants