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

Allow processing square buffers. #347

Merged
merged 4 commits into from
Jul 23, 2024

Conversation

psobot
Copy link
Member

@psobot psobot commented Jun 25, 2024

Fixes #336. (cc @mttbernardini)

This PR fixes the issue that occurs when passing a square (i.e.: (x, x)) buffer into a Plugin instance. Like #338, this PR adds caching of the last-detected channel layout to each Plugin instance, making the following example pass:

board = Pedalboard([Reverb(), Gain()])
with AudioFile("file_with_17_stereo_samples.wav") as f:
    while f.tell() < f.frames:
        # Read three frames at a time; but the last frame will
        # end up with only two samples in it.
        output = board(f.read(3), f.samplerate)

Prior to this PR, the above example would have failed as the last f.read(3) call would return an array of shape (2, 2).

@psobot psobot added the bug Something isn't working label Jun 25, 2024
@mttbernardini
Copy link

Hey @psobot, thank you for fixing this. Does this PR include the "memorization" feature as in the AudioFile scenario, i.e. process (n, 0) or (0, n) to hint the layout for the next buffer call?

@psobot psobot force-pushed the psobot/plugin-processing-square-buffers branch from ed61fc5 to 0987ed2 Compare July 2, 2024 14:09
@psobot psobot force-pushed the psobot/plugin-processing-square-buffers branch from 0987ed2 to 69ee312 Compare July 23, 2024 00:30
@psobot psobot merged commit 077e236 into master Jul 23, 2024
32 checks passed
@psobot psobot deleted the psobot/plugin-processing-square-buffers branch July 23, 2024 00:42
@psobot
Copy link
Member Author

psobot commented Jul 23, 2024

Sorry for the delay @mttbernardini! Yes, this PR includes memorization, just like AudioFile does.

@psobot psobot restored the psobot/plugin-processing-square-buffers branch July 23, 2024 02:53
psobot added a commit that referenced this pull request Jul 23, 2024
psobot added a commit that referenced this pull request Jul 23, 2024
psobot added a commit that referenced this pull request Jul 23, 2024
psobot added a commit that referenced this pull request Jul 29, 2024
@psobot
Copy link
Member Author

psobot commented Jul 30, 2024

This is now on PyPI in v0.9.12. Thanks @mttbernardini!

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.

Any Plugin cannot process stereo buffers containing only 2 samples
2 participants