@@ -187,7 +187,7 @@ static mp_obj_t microbit_microphone_record_into(mp_uint_t n_args, const mp_obj_t
187187 enum { ARG_buffer , ARG_rate , ARG_wait , };
188188 static const mp_arg_t allowed_args [] = {
189189 { MP_QSTR_buffer , MP_ARG_REQUIRED | MP_ARG_OBJ , {.u_obj = MP_OBJ_NULL } },
190- { MP_QSTR_rate , MP_ARG_INT , {.u_int = 7812 } },
190+ { MP_QSTR_rate , MP_ARG_INT , {.u_int = 0 } },
191191 { MP_QSTR_wait , MP_ARG_KW_ONLY | MP_ARG_BOOL , {.u_bool = true} },
192192 };
193193
@@ -201,8 +201,13 @@ static mp_obj_t microbit_microphone_record_into(mp_uint_t n_args, const mp_obj_t
201201 }
202202 microbit_audio_frame_obj_t * audio_frame = MP_OBJ_TO_PTR (args [ARG_buffer ].u_obj );
203203
204+ // Set the rate of the AudioFrame, if specified.
205+ if (args [ARG_rate ].u_int > 0 ) {
206+ audio_frame -> rate = args [ARG_rate ].u_int ;
207+ }
208+
204209 // Start the recording.
205- microbit_hal_microphone_start_recording (audio_frame -> data , audio_frame -> alloc_size , & audio_frame -> used_size , args [ ARG_rate ]. u_int );
210+ microbit_hal_microphone_start_recording (audio_frame -> data , audio_frame -> alloc_size , & audio_frame -> used_size , audio_frame -> rate );
206211
207212 return mp_const_none ;
208213}
0 commit comments