Skip to content

audiobusio.I2SOut.play resets audiomixer.Mixer playing state #11021

@relic-se

Description

@relic-se

CircuitPython version and board name

Adafruit CircuitPython 10.3.0-alpha.2 on 2026-05-15; Raspberry Pi Pico 2 with rp2350a

Code/REPL

import audiobusio
import audiomixer
import board
import synthio
import time

audio = audiobusio.I2SOut(
    bit_clock=board.GP20,
    word_select=board.GP21,
    data=board.GP22,
)
mixer = audiomixer.Mixer(
    voice_count=1,
    sample_rate=44100,
    channel_count=1,
)
audio.play(mixer)

synth = synthio.Synthesizer(
    sample_rate=44100,
    channel_count=1,
)
mixer.play(synth)
mixer.voice[0].level = 0.1

print("Press")
synth.press(48)
time.sleep(1)

print(mixer.playing)  # True
time.sleep(1)

print("Stop")
audio.stop()
time.sleep(1)

print(mixer.playing)  # True
time.sleep(1)

print("Start")
audio.play(mixer)
# mixer.play(synth)
time.sleep(1)

print(mixer.playing)  # False (if `mixer.play(...)` is included above, will be True)
time.sleep(1)

print("Release")
synth.release_all()

Behavior

If additional mixer.play is omitted, synthesizer audio does not resume when audio.play is called:

Press
True
Stop
True
Start
False
Release

If mixer.play is included, synthesizer audio continues playing:

Press
True
Stop
True
Start
True
Release

Description

My expectation is that since I never disconnected the synthio.Synthesizer object from the audiomixer.Mixer, it would continue playing once the mixer is played again through the audiobusio.I2SOut object, and the additional audiomixer.Mixer.play would not be necessary.

Additional information

This isn't necessarily a big deal here in the above example, but if for instance you had a mixer with 8 populated voices (ie: wav file looping sampler controlled by audiomixer.MixerVoice.level), it wouldn't be ideal to have to reconnect all sources to the mixer if you just need to pause the audio output temporarily.

In my case, I need to pause audio output in order to save data to my filesystem or else audible pops might occur due to not being able to keep up with background tasks while saving. I assumed that I wouldn't need to reassign all of my mixer voices during this process.

I believe this is related to #10154.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions