Skip to content

Commit 7f74061

Browse files
committed
Simplify audiofilter construction through better default parameters
1 parent aaf7b00 commit 7f74061

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

shared-bindings/audiofilters/Filter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
static mp_obj_t audiofilters_filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
7272
enum { ARG_filter, ARG_mix, ARG_buffer_size, ARG_sample_rate, ARG_bits_per_sample, ARG_samples_signed, ARG_channel_count, };
7373
static const mp_arg_t allowed_args[] = {
74-
{ MP_QSTR_filter, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
75-
{ MP_QSTR_mix, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
74+
{ MP_QSTR_filter, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_ROM_NONE} },
75+
{ MP_QSTR_mix, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_ROM_INT(1)} },
7676
{ MP_QSTR_buffer_size, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 512} },
7777
{ MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 8000} },
7878
{ MP_QSTR_bits_per_sample, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 16} },

shared-module/audiofilters/Filter.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,8 @@ void common_hal_audiofilters_filter_construct(audiofilters_filter_obj_t *self,
4848

4949
// The below section sets up the effect's starting values.
5050

51-
if (filter == MP_OBJ_NULL) {
52-
filter = mp_const_none;
53-
}
5451
common_hal_audiofilters_filter_set_filter(self, filter);
5552

56-
// If we did not receive a BlockInput we need to create a default float value
57-
if (mix == MP_OBJ_NULL) {
58-
mix = mp_obj_new_float(1.0);
59-
}
6053
synthio_block_assign_slot(mix, &self->mix, MP_QSTR_mix);
6154
}
6255

0 commit comments

Comments
 (0)