File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -546,11 +546,11 @@ static microbit_audio_frame_obj_t *copy(microbit_audio_frame_obj_t *self) {
546
546
547
547
mp_obj_t copyfrom (mp_obj_t self_in, mp_obj_t other) {
548
548
microbit_audio_frame_obj_t *self = (microbit_audio_frame_obj_t *)self_in;
549
- if ( mp_obj_get_type (other) != µbit_audio_frame_type) {
550
- nlr_raise ( mp_obj_new_exception_msg (&mp_type_TypeError, " Must be an AudioBuffer " ) );
551
- }
552
- for (int i = 0 ; i < AUDIO_CHUNK_SIZE ; i++) {
553
- self->data [i] = ((microbit_audio_frame_obj_t *)other)-> data [i];
549
+ mp_buffer_info_t bufinfo;
550
+ mp_get_buffer_raise (other, &bufinfo, MP_BUFFER_READ );
551
+ uint32_t len = bufinfo. len > AUDIO_CHUNK_SIZE ? AUDIO_CHUNK_SIZE : bufinfo. len ;
552
+ for (uint32_t i = 0 ; i < len ; i++) {
553
+ self->data [i] = ((uint8_t *)bufinfo. buf ) [i];
554
554
}
555
555
return mp_const_none;
556
556
}
@@ -640,7 +640,7 @@ const mp_obj_type_t microbit_audio_frame_type = {
640
640
.buffer_p = { .get_buffer = audio_frame_get_buffer },
641
641
.stream_p = NULL ,
642
642
.bases_tuple = NULL ,
643
- .locals_dict = (mp_obj_dict_t *)µbit_audio_frame_locals_dict_table ,
643
+ .locals_dict = (mp_obj_dict_t *)µbit_audio_frame_locals_dict ,
644
644
};
645
645
646
646
microbit_audio_frame_obj_t *new_microbit_audio_frame (void ) {
You can’t perform that action at this time.
0 commit comments