Skip to content

audiobusio.PDMIn.record hangs CPX (SAMD21) if a wav file has been played #4600

Closed
@kevinjwalters

Description

@kevinjwalters

I just noticed this on 6.2.0 on a CPX with fresh (20210413) libraries, mic.record() hangs in a reproducible way under some circumstances. I tried a few things based on my first discovery of this. It looks like playing a wav file to the speaker does it.

Adafruit CircuitPython 6.2.0 on 2021-04-05; Adafruit CircuitPlayground Express with samd21g18
>>>
>>> import board
>>> import audiobusio
>>> import array
>>> mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA,
...                        sample_rate=16000, bit_depth=16)
>>> NUM_SAMPLES = 160
>>> samples = array.array('H', [0] * NUM_SAMPLES)
>>> mic.record(samples, len(samples))
160
>>> mic.record(samples, len(samples))
160
>>> mic.record(samples, len(samples))
160
>>> mic.record(samples, len(samples))
160
>>> mic.record(samples, len(samples))
160
>>> from adafruit_circuitplayground import cp
>>> mic.record(samples, len(samples))
160
>>> mic.record(samples, len(samples))
160
>>> dir(cp)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_circuitplayground/express.py", line 82, in _unsupported
NotImplementedError: This feature is not supported on Circuit Playground Express.
>>> mic.record(samples, len(samples))
160
>>> mic.record(samples, len(samples))
160
>>> import gc
>>> gc.collect() ; print(gc.mem_free())
12944
>>> gc.collect() ; print(gc.mem_free())
12944
>>> mic.record(samples, len(samples))
160
>>> mic.record(samples, len(samples))
160
>>> cp.play_file("num/one.wav")  ### 16k 16-bit short mono sample
>>> mic.record(samples, len(samples))  ### CIRCUITPY drive no longer works, serial console non-responsive

I see another issue with record() reported in #4261

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions