53
53
//| :param bool mono: True when capturing a single channel of audio, captures two channels otherwise
54
54
//| :param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8
55
55
//|
56
- //| Simple record to buffer::
56
+ //| Record 8-bit unsigned samples to buffer::
57
57
//|
58
58
//| import audiobusio
59
59
//| import board
60
60
//|
61
61
//| # Prep a buffer to record into
62
62
//| 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:
64
78
//| mic.record(b, len(b))
65
79
//|
66
80
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 * pos_args ) {
@@ -70,7 +84,7 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar
70
84
static const mp_arg_t allowed_args [] = {
71
85
{ MP_QSTR_frequency , MP_ARG_INT , {.u_int = 8000 } },
72
86
{ 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 } },
74
88
{ MP_QSTR_oversample , MP_ARG_INT , {.u_int = 64 } },
75
89
};
76
90
mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
0 commit comments