Skip to content

Starting one audiopwmio.PWMAudioOut on one pin stop another on another pin #4266

@dglaude

Description

@dglaude

This is on the Pico RP2040 (and using the pico demo board from Pimoroni, that board follow the reference design from Raspberry) and using 6.2.0-beta.2-137-ge41137c74

In the following code (just a copy of https://circuitpython.readthedocs.io/en/latest/shared-bindings/audiopwmio/index.html but with one sound on GP28 and one sound on GP27 for left and right channel), when after one second the sound start on GP27, it stop on GP28. And reverse way if you inverse GP27 and GP28.

So two independant audiopwmio.PWMAudioOut seems to interact with each other in unexpected way.

Expected result:
27: silence (1s) beeep (2s) silence (3s)
28: beeep (1s) beeep (2s) beeep (3s)

Effective result:
27: silence (1s) beeep (2s) silence (3s)
28: beeep (1s) silence (2s) silence (3s)

Here is the code:

import audiocore
import audiopwmio
import board
import array
import time
import math

# Generate one period of sine wav.
length = 8000 // 440
sine_wave0 = array.array("H", [0] * length)
for i in range(length):
    sine_wave0[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15) + 2 ** 15)
sine_wave1 = array.array("H", [0] * length)
for i in range(length):
    sine_wave1[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15) + 2 ** 15)

dac0 = audiopwmio.PWMAudioOut(board.GP28)
sine0 = audiocore.RawSample(sine_wave0, sample_rate=8000)
dac0.play(sine0, loop=True)
time.sleep(1)
if True:
    dac1 = audiopwmio.PWMAudioOut(board.GP27)
    sine1 = audiocore.RawSample(sine_wave1, sample_rate=8000)
    dac1.play(sine1, loop=True)
    time.sleep(1)
    dac1.stop()
time.sleep(1)
dac0.stop()

So maybe it is a bug.
Also GP27 and GP28 are not on the same slice (if that matter).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions