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 handling of stereo audio within audiodelays when freq_shift=True #9876

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

relic-se
Copy link

@relic-se relic-se commented Dec 6, 2024

@gamblor21 @jepler for interest.

This has been an issue that I've been aware of since the inclusion of audiodelays in 9.2.0. Echo buffer positions weren't being properly managed when handling stereo input/output. I've resolved this issue by separating the echo buffer into two halves (left + right) and offsetting the buffer where necessary. I've done my best to support single_channel_output as well, but I'm not exactly sure how to test that (I2SOut uses left/right pairs).

I've also found a minor bug when constructing audiodelays.Echo with delay_ms <= 0 || delay_ms > max_delay_ms where echo_buffer_length would not be set and remain as the default of 0. The effect of this issue wasn't too major, but I've resolved it by always setting echo_buffer_length during recalculate_delay and limiting it to the acceptable range.

Because each freq_shift mode handles the buffer differently now, I've added it so that the full echo_buffer and buffer positions are reset whenever the mode is changed to avoid potential audio abnormalities.

The example in #9874 now does not exhibit any issues. I've also tested this code with variable delay_ms values, and the frequency shifting works with full channel separation.

Fixes #9874.

@jepler
Copy link
Member

jepler commented Dec 6, 2024

I feel your pain about single_channel_output. As far as I can tell from source code searches this was needed by samd51 analog AudioOut but not any other audio output, and we should restructure things so that not every audio source has to bear a code size and complication cost for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

audiodelays.Echo.freq_shift panning issues with stereo sources
2 participants