Skip to content

AudioMixer bad on Pygamer / SAMD51 on CirPy 10.x #10867

@todbot

Description

@todbot

CircuitPython version and board name

Adafruit CircuitPython 10.1.2-14-gf75864d25f on 2026-03-03; Adafruit PyGamer with samd51j19
Adafruit CircuitPython 10.1.3 on 2026-02-20; Adafruit PyGamer with samd51j19
Adafruit CircuitPython 10.0.1 on 2025-10-09; Adafruit PyGamer with samd51j19

Code/REPL

import time
import board, digitalio
import displayio
import audiocore, audiomixer, audioio
displayio.release_displays()  # just in case

SAMPLE_RATE = 22050 
CHANNEL_COUNT = 1
BUFFER_SIZE = 4096

spkr_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
spkr_enable.switch_to_output(value=True)

audio = audioio.AudioOut(left_channel=board.A0) 
mixer = audiomixer.Mixer(sample_rate=SAMPLE_RATE, buffer_size=BUFFER_SIZE,
                         channel_count=CHANNEL_COUNT, voice_count=1)
audio.play(mixer)
mixer.voice[0].level = 0.25

wav1 = audiocore.WaveFile("amen1_22k_s16.wav") 
mixer.voice[0].play(wav1, loop=True)  # does not work on PyGamer / SAMD51, bare whisper of distorted audio

# audio.play(wav1, loop=True)   # this works

while True:
    print("hi", time.monotonic())
    time.sleep(0.3)

Behavior

On CircuitPython 9.2.9 and before, using AudioMixer works as expected.
As of 10.0.1, it outputs a barely-audible distorted version of the audio.
Bypassing AudioMixer with audio.play(wav) works as expected on all versions of CirPy.

Description

I'm currently thinking it's related to this commit fd2627c that added the very nice mono-to-stereo conversion.

I don't see any changes to "atmel-samd/common-hal/audioio" in the last two years, so I don't think it's port-specific, but rather < 16-bit audio destinations are giving AudioMixer issues?

Additional information

Works on Adafruit CircuitPython 9.2.9 on 2025-09-07; Adafruit PyGamer with samd51j19

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions