Fix handling of stereo audio within audiodelays.Delay when freq_shift=True#10252
Conversation
…`echo_buffer_write_pos`, and split buffer for stereo output when `freq_shift=True`.
gamblor21
left a comment
There was a problem hiding this comment.
Code looked good to me, but when I tried it and set the channels to one I lose the echo effect for freq_shift=True. It works for stereo.
I believe there's an issue with how the buffer index is updated in mono. I fixed it within the |
|
@gamblor21 I began to encounter issues with buffer positions when using a |
gamblor21
left a comment
There was a problem hiding this comment.
Works great now. Thanks so much!
@gamblor21 @dhalbert for interest.
This has been an issue that I've been aware of since the inclusion of
audiodelaysin 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 supportsingle_channel_outputas 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.Echowithdelay_ms <= 0 || delay_ms > max_delay_mswhereecho_buffer_lengthwould 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 settingecho_buffer_lengthduringrecalculate_delayand limiting it to the acceptable range.Because each
freq_shiftmode handles the buffer differently now, I've added it so that the fullecho_bufferand 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_msvalues, and the frequency shifting works with full channel separation.Fixes #9874.