@@ -181,7 +181,7 @@ STATIC mp_obj_t microbit_microphone_record_into(mp_uint_t n_args, const mp_obj_t
181181 enum { ARG_buffer , ARG_rate , ARG_wait , };
182182 static const mp_arg_t allowed_args [] = {
183183 { MP_QSTR_buffer , MP_ARG_REQUIRED | MP_ARG_OBJ , {.u_obj = MP_OBJ_NULL } },
184- { MP_QSTR_rate , MP_ARG_INT , {.u_int = 7812 } },
184+ { MP_QSTR_rate , MP_ARG_INT , {.u_int = 0 } },
185185 { MP_QSTR_wait , MP_ARG_KW_ONLY | MP_ARG_BOOL , {.u_bool = true} },
186186 };
187187
@@ -195,8 +195,13 @@ STATIC mp_obj_t microbit_microphone_record_into(mp_uint_t n_args, const mp_obj_t
195195 }
196196 microbit_audio_frame_obj_t * audio_frame = MP_OBJ_TO_PTR (args [ARG_buffer ].u_obj );
197197
198+ // Set the rate of the AudioFrame, if specified.
199+ if (args [ARG_rate ].u_int > 0 ) {
200+ audio_frame -> rate = args [ARG_rate ].u_int ;
201+ }
202+
198203 // Start the recording.
199- microbit_hal_microphone_start_recording (audio_frame -> data , audio_frame -> alloc_size , & audio_frame -> used_size , args [ ARG_rate ]. u_int );
204+ microbit_hal_microphone_start_recording (audio_frame -> data , audio_frame -> alloc_size , & audio_frame -> used_size , audio_frame -> rate );
200205
201206 return mp_const_none ;
202207}
0 commit comments