Skip to content

AudioMixer reversed play order results in silent output #10154

Open
@relic-se

Description

@relic-se

CircuitPython version and board name

Adafruit CircuitPython 9.2.5 on 2025-03-19; Pimoroni Pico Plus 2 with rp2350b

Code/REPL

import audiobusio
import audiomixer
import board
import synthio

TEST = False

synth = synthio.Synthesizer()

mixer = audiomixer.Mixer(
    voice_count=1,
    channel_count=1,
    sample_rate=11025,
)

dac = audiobusio.I2SOut(
    bit_clock=board.GP0,
    word_select=board.GP1,
    data=board.GP2,
)

if TEST:
    mixer.voice[0].play(synth)
    dac.play(mixer)
else:
    dac.play(mixer)
    mixer.voice[0].play(synth)

synth.press(40)

print(dac.playing)  # Always prints "True"

Behavior

If TEST = False, the DAC outputs the note played by the synthesizer and reports the following REPL output:

dac.playing=True
mixer.playing=True

If TEST = True, no sound is output from the DAC and it reports the following REPL output:

dac.playing=True
mixer.playing=False

Description

If audiomixer.Mixer is played by an audio output object before the audiomixer.MixerVoice object has been loaded with a sample, the output audio is silent. Toggle the TEST constant to flip the order of play and demonstrate this error.

Additional information

This is an aside, but it would also be really nice to allow for chaining, ie: dac.play(mixer.play(synth, voice=0)). I know in the past other users have referenced this style of chaining, but it is definitely not supported. I think all that would be necessary to do this is to return an instance of self (return MP_OBJ_FROM_PTR(self);) on each implementation of play in shared-bindings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions