8000 `audiodelays.Echo.freq_shift` panning issues with stereo sources · Issue #9874 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

audiodelays.Echo.freq_shift panning issues with stereo sources #9874

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

Open
relic-se opened this issue Dec 6, 2024 · 0 comments
Open

audiodelays.Echo.freq_shift panning issues with stereo sources #9874

relic-se opened this issue Dec 6, 2024 · 0 comments
Milestone

Comments

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

CircuitPython version

Adafruit CircuitPython 9.2.1-22-gb481f1fa8e on 2024-12-05; Pimoroni Pico Plus 2 with rp2350b

Code/REPL

import audiobusio
import audiodelays
import board, time
import synthio

audio = audiobusio.I2SOut(
    bit_clock=board.GP0,
    word_select=board.GP1,
    data=board.GP3,
)

synth = synthio.Synthesizer(
    sample_rate=22050,
    channel_count=2,
)

effect = audiodelays.Echo(
    max_delay_ms=200,
    delay_ms=500,
    decay=0.0,
    mix=0.5,
    sample_rate=22050,
    channel_count=2,
    freq_shift=True,
)

effect.play(synth)
audio.play(effect)

note = synthio.Note(
    frequency=synthio.midi_to_hz(65),
    panning=-1.0,
)
while True:
    synth.press(note)
    time.sleep(0.1)
    synth.release(note)
    time.sleep(0.9)
    note.panning = note.panning * -1.0 # alternate panning

Behavior

Note plays for 0.1 second every second alternating between the left and right channels (hard panned). The delayed effect plays in the center channel with distorted abnormalities.

Description

Code works as intended if max_delay_ms equals delay_ms. Otherwise, panning errors in the audio occur. This is due to the poor handling of the buffer pointer when freq_shift is enabled and multiple channels are present.

Additional information

The buffer pointers need to be limited to half the buffer size when channel_count=2 and freq_shift=True and the right channel pointer needs to be offset to the second half of the buffer. This will allow the two channels to be separated appropriately.

This is my fault due to a lack of understanding of the audiosample API when adding this feature.

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

Successfully merging a pull request may close this issue.

2 participants
0