I2S audio popping playing samples

Hi, I’ve bought a Pimoroni Audio Pack for the Raspberry Pico, and made some tests in CircuitPython with audio as a drum sampler.

I’ve noticed audio popping very frequently, ie. playing at default 16-bit 44100Khz kick and hi-hat sample. Feels like something about audio buffering issues, it happens 10% of the hits, which is a lot.

Do you have any guess? Can I help providing more info?

Here’s the kick.wav, and hat.wav

The code is pretty straightforward,

audio = audiobusio.I2SOut(board.GP10, board.GP11, board.GP9)
mixer = audiomixer.Mixer(voice_count=8, sample_rate=44100, channel_count=1)
audio.play(mixer)

kick = audiocore.WaveFile(open("dr55/kick.wav", "rb"))
hh = audiocore.WaveFile(open("dr55/hat.wav", "rb"))

while True
    tick = 0

    if tick % 2 == 0:
        mixer.voice[1].level = 0.1
        mixer.voice[1].play(hh)

    if tick % 8 == 0:
        mixer.voice[0].level = 0.1
        mixer.voice[0].play(kick)

    tick += 1

    time.sleep(0.05)

EDIT: that code snippet is part of another bigger code.

solved the issue by adding gc.collect() before playing, seems like that helps free the memory before the audiomixer does its stuff

however, something strange is happening: if one sample plays at all steps (~120bpm), some hits are not audible, it’s random; however if both samples plays at all steps no issues… poor wire connections