|
65 | 65 | //| :param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8
|
66 | 66 | //| :param float startup_delay: seconds to wait after starting microphone clock
|
67 | 67 | //| to allow microphone to turn on. Most require only 0.01s; some require 0.1s. Longer is safer.
|
68 |
| -//| Must be in range 0.0-1.0 seconds.""" |
69 |
| - |
70 |
| -//| """Record 8-bit unsigned samples to buffer:: |
| 68 | +//| Must be in range 0.0-1.0 seconds. |
| 69 | +//| |
| 70 | +//| **Limitations:** On SAMD and RP2040, supports only 8 or 16 bit mono input, with 64x oversampling. |
| 71 | +//| On nRF52840, supports only 16 bit mono input at 16 kHz; oversampling is fixed at 64x. Not provided |
| 72 | +//| on nRF52833 for space reasons. Not available on Espressif. |
| 73 | +//| |
| 74 | +//| For example, to record 8-bit unsigned samples to a buffer:: |
71 | 75 | //|
|
72 |
| -//| import audiobusio |
73 |
| -//| import board |
| 76 | +//| import audiobusio |
| 77 | +//| import board |
74 | 78 | //|
|
75 |
| -//| # Prep a buffer to record into |
76 |
| -//| b = bytearray(200) |
77 |
| -//| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000) as mic: |
78 |
| -//| mic.record(b, len(b)) |
| 79 | +//| # Prep a buffer to record into |
| 80 | +//| b = bytearray(200) |
| 81 | +//| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000) as mic: |
| 82 | +//| mic.record(b, len(b)) |
79 | 83 | //|
|
80 |
| -//| Record 16-bit unsigned samples to buffer:: |
| 84 | +//| To record 16-bit unsigned samples to a buffer:: |
81 | 85 | //|
|
82 |
| -//| import audiobusio |
83 |
| -//| import board |
| 86 | +//| import audiobusio |
| 87 | +//| import board |
84 | 88 | //|
|
85 |
| -//| # Prep a buffer to record into. The array interface doesn't allow for |
86 |
| -//| # constructing with a set size so we append to it until we have the size |
87 |
| -//| # we want. |
88 |
| -//| b = array.array("H") |
89 |
| -//| for i in range(200): |
90 |
| -//| b.append(0) |
91 |
| -//| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) as mic: |
92 |
| -//| mic.record(b, len(b))""" |
| 89 | +//| # Prep a buffer to record into. |
| 90 | +//| b = array.array("H", [0] * 200) |
| 91 | +//| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) as mic: |
| 92 | +//| mic.record(b, len(b)) |
| 93 | +//| """ |
93 | 94 | //| ...
|
94 | 95 | STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
95 | 96 | #if !CIRCUITPY_AUDIOBUSIO_PDMIN
|
|
0 commit comments