Skip to content

Commit aaf7b00

Browse files
committed
Use properties construct helper to simplify block biquad construction
1 parent 66794a7 commit aaf7b00

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

shared-bindings/synthio/BlockBiquad.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ static mp_obj_t synthio_block_biquad_make_new(const mp_obj_type_t *type_in, size
8181
}
8282

8383
synthio_filter_mode mode = validate_synthio_filter_mode(args[ARG_mode].u_obj, MP_QSTR_mode);
84-
return common_hal_synthio_block_biquad_new(mode, args[ARG_frequency].u_obj, args[ARG_Q].u_obj);
84+
mp_obj_t result = common_hal_synthio_block_biquad_new(mode);
85+
properties_construct_helper(result, block_biquad_properties + 1, args + 1, MP_ARRAY_SIZE(block_biquad_properties) - 1);
86+
return result;
8587
}
8688

8789
//|

shared-bindings/synthio/BlockBiquad.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ void common_hal_synthio_block_biquad_set_frequency(synthio_block_biquad_t *self,
2525

2626
synthio_filter_mode common_hal_synthio_block_biquad_get_mode(synthio_block_biquad_t *self);
2727

28-
mp_obj_t common_hal_synthio_block_biquad_new(synthio_filter_mode mode, mp_obj_t frequency, mp_obj_t Q);
28+
mp_obj_t common_hal_synthio_block_biquad_new(synthio_filter_mode mode);

shared-module/synthio/BlockBiquad.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ static void fast_sincos(mp_float_t theta, sincos_result_t *result) {
3030
result->s = evens - odds;
3131
}
3232

33-
mp_obj_t common_hal_synthio_block_biquad_new(synthio_filter_mode mode, mp_obj_t f0, mp_obj_t Q) {
33+
mp_obj_t common_hal_synthio_block_biquad_new(synthio_filter_mode mode) {
3434
synthio_block_biquad_t *self = mp_obj_malloc(synthio_block_biquad_t, &synthio_block_biquad_type_obj);
3535
self->mode = mode;
36-
synthio_block_assign_slot(f0, &self->f0, MP_QSTR_frequency);
37-
synthio_block_assign_slot(Q, &self->Q, MP_QSTR_Q);
3836
return MP_OBJ_FROM_PTR(self);
3937
}
4038

0 commit comments

Comments
 (0)