Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

PDMIn and odd number of samples on CLUE
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

PDMIn and odd number of samples on CLUE

by kevinjwalters on Wed Oct 14, 2020 4:05 pm

The docs for PDMIn mention that record:

Returns: The number of samples recorded. If this is less than destination_length, some samples were missed due to processing time.


There looks to be an issue with an odd number of samples too, see example below from a CLUE's onboard microphone using 5.3.1:

Code: Select all | TOGGLE FULL SIZE
Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit CLUE nRF52840 Express with nRF52840
>>> import board
>>> import audiobusio
>>> import array
>>> mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA,
...                        sample_rate=16000, bit_depth=16)
>>> samples_mic = array.array('H', [123] * 1011)
>>> for s_len in range(1000, 1010 + 1):
...     print(s_len, mic.record(samples_mic, s_len))
...
...
...
1000 1000
1001 1000
1002 1002
1003 1002
1004 1004
1005 1004
1006 1006
1007 1006
1008 1008
1009 1008
1010 1010
>>> samples_mic[-1]  ### last entry expected to still be 123
123
>>> mic.record(samples_mic, len(samples_mic))
1010
>>> samples_mic[-1]  ### 1010 written to 1011 size buffer, last entry is...
32764


I've not seen any issue with this it just seems a bit odd?

kevinjwalters
 
Posts: 764
Joined: Sun Oct 01, 2017 3:15 pm

Please be positive and constructive with your questions and comments.