Skip to content

Commit 155f197

Browse files
committed
Convert default float values from null checks to MP_ROM_INT.
1 parent 31c9095 commit 155f197

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

shared-bindings/audiofilters/Distortion.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ static audiofilters_distortion_mode validate_distortion_mode(mp_obj_t obj, qstr
113113
static mp_obj_t audiofilters_distortion_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
114114
enum { ARG_drive, ARG_pre_gain, ARG_post_gain, ARG_mode, ARG_mix, ARG_buffer_size, ARG_sample_rate, ARG_bits_per_sample, ARG_samples_signed, ARG_channel_count, };
115115
static const mp_arg_t allowed_args[] = {
116-
{ MP_QSTR_drive, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
117-
{ MP_QSTR_pre_gain, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
118-
{ MP_QSTR_post_gain, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
116+
{ MP_QSTR_drive, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_ROM_INT(0)} },
117+
{ MP_QSTR_pre_gain, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_ROM_INT(0)} },
118+
{ MP_QSTR_post_gain, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_ROM_INT(0)} },
119119
{ MP_QSTR_mode, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
120-
{ MP_QSTR_mix, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
120+
{ MP_QSTR_mix, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_ROM_INT(1)} },
121121
{ MP_QSTR_buffer_size, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 512} },
122122
{ MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 8000} },
123123
{ MP_QSTR_bits_per_sample, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 16} },

shared-module/audiofilters/Distortion.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,31 +62,12 @@ void common_hal_audiofilters_distortion_construct(audiofilters_distortion_obj_t
6262

6363
// The below section sets up the effect's starting values.
6464

65-
// If we did not receive a BlockInput we need to create a default float value
66-
if (drive == MP_OBJ_NULL) {
67-
drive = mp_obj_new_float(0.0);
68-
}
6965
synthio_block_assign_slot(drive, &self->drive, MP_QSTR_drive);
70-
71-
// If we did not receive a BlockInput we need to create a default float value
72-
if (pre_gain == MP_OBJ_NULL) {
73-
pre_gain = mp_obj_new_float(0.0);
74-
}
7566
synthio_block_assign_slot(pre_gain, &self->pre_gain, MP_QSTR_pre_gain);
76-
77-
// If we did not receive a BlockInput we need to create a default float value
78-
if (post_gain == MP_OBJ_NULL) {
79-
post_gain = mp_obj_new_float(0.0);
80-
}
8167
synthio_block_assign_slot(post_gain, &self->post_gain, MP_QSTR_post_gain);
68+
synthio_block_assign_slot(mix, &self->mix, MP_QSTR_mix);
8269

8370
self->mode = mode;
84-
85-
// If we did not receive a BlockInput we need to create a default float value
86-
if (mix == MP_OBJ_NULL) {
87-
mix = mp_obj_new_float(1.0);
88-
}
89-
synthio_block_assign_slot(mix, &self->mix, MP_QSTR_mix);
9071
}
9172

9273
bool common_hal_audiofilters_distortion_deinited(audiofilters_distortion_obj_t *self) {

0 commit comments

Comments
 (0)