5353//| :param bool mono: True when capturing a single channel of audio, captures two channels otherwise
5454//| :param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8
5555//|
56- //| Simple record to buffer::
56+ //| Record 8-bit unsigned samples to buffer::
5757//|
5858//| import audiobusio
5959//| import board
6060//|
6161//| # Prep a buffer to record into
6262//| b = bytearray(200)
63- //| with audiobusio.PDMIn(board.MICROPHONE_DATA, board.MICROPHONE_CLOCK) as mic:
63+ //| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA) as mic:
64+ //| mic.record(b, len(b))
65+ //|
66+ //| Record 16-bit unsigned samples to buffer::
67+ //|
68+ //| import audiobusio
69+ //| import board
70+ //|
71+ //| # Prep a buffer to record into. The array interface doesn't allow for
72+ //| # constructing with a set size so we append to it until we have the size
73+ //| # we want.
74+ //| b = array.array("H")
75+ //| for i in range(200):
76+ //| b.append(0)
77+ //| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, bit_depth=16) as mic:
6478//| mic.record(b, len(b))
6579//|
6680STATIC 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 * pos_args ) {
@@ -70,7 +84,7 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar
7084 static const mp_arg_t allowed_args [] = {
7185 { MP_QSTR_frequency , MP_ARG_INT , {.u_int = 8000 } },
7286 { MP_QSTR_bit_depth , MP_ARG_INT , {.u_int = 8 } },
73- { MP_QSTR_mono , MP_ARG_BOOL ,{.u_bool = false } },
87+ { MP_QSTR_mono , MP_ARG_BOOL ,{.u_bool = true } },
7488 { MP_QSTR_oversample , MP_ARG_INT , {.u_int = 64 } },
7589 };
7690 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
0 commit comments