Skip to content

Commit cd321fe

Browse files
committed
Use properties construct helper to simplify block biquad construction
1 parent 4ba61d0 commit cd321fe

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
@@ -83,7 +83,9 @@ static mp_obj_t synthio_block_biquad_make_new(const mp_obj_type_t *type_in, size
8383
}
8484

8585
synthio_filter_mode mode = validate_synthio_filter_mode(args[ARG_mode].u_obj, MP_QSTR_mode);
86-
return common_hal_synthio_block_biquad_new(mode, args[ARG_frequency].u_obj, args[ARG_Q].u_obj);
86+
mp_obj_t result = common_hal_synthio_block_biquad_new(mode);
87+
properties_construct_helper(result, block_biquad_properties + 1, args + 1, MP_ARRAY_SIZE(block_biquad_properties) - 1);
88+
return result;
8789
}
8890

8991
//|

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)