-
Notifications
You must be signed in to change notification settings - Fork 269
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
Added an optional audio file parameter to the AudioStream class (issue #264) #317
Conversation
Enhance the AudioStream class by introducing an optional parameter to accept an audio file. This enhancement allows users to initiate audio streaming directly from a specified file, facilitating more flexible usage scenarios.
Hi @jnitsun! Thanks for this PR - I always appreciate it when folks send in new code to review. I know this is your first pull request, so forgive the amount of detail below - these are all friendly notes that I hope will be helpful.
I haven't spent much time thinking about a design for this API, but if I were to apply the design principles used for the rest of Pedalboard, I'd suggest a design that allows users to pass audio buffers (i.e.:
Here's an example of how someone might use this API, showing how it would be consistent with the existing Pedalboard API: with AudioFile("my_file.mp3") as f:
with AudioStream(output_device_name="MacBook Pro Speakers") as stream:
while f.tell() < f.frames:
# Read audio from the file, decode it, and write it to the AudioStream for playback in chunks:
while stream.samples_buffered < 8192:
stream.write(f.read(1024))
# Before this print() is called, stream.close() will implicitly be called,
# which will block until all audio has been played back.
print("Playback done!") I know that the Pull Request you've made here will technically work (and has tests - thank you for that!) - but merging it as-is would create an API that is likely to confuse users and doesn't align with the design principles of the existing API. The API I've proposed here is probably going to be a lot of work to implement, so I don't expect you to make all of those changes in this PR unless you're feeling particularly ambitious. 😅 |
This has been added as part of #363, which will be released with Pedalboard v0.9.12. |
Enhanced the AudioStream class by introducing an optional parameter to accept an audio file.
Fixed #294.
Made alterations to the AudioStream class that now takes in an optional audio file parameter. If the parameter is not specific, it works as it did before.