Skip to content

Commit e891bce

Browse files
committed
Rename FilterType -> FilterMode
1 parent b03d396 commit e891bce

File tree

6 files changed

+43
-43
lines changed

6 files changed

+43
-43
lines changed

shared-bindings/synthio/BlockBiquad.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,41 @@
1010
#include "shared-bindings/synthio/BlockBiquad.h"
1111
#include "shared-bindings/util.h"
1212

13-
//| class FilterType:
13+
//| class FilterMode:
1414
//| """The type of filter"""
1515
//|
16-
//| LOW_PASS: FilterType
16+
//| LOW_PASS: FilterMode
1717
//| """A low-pass filter"""
18-
//| HIGH_PASS: FilterType
18+
//| HIGH_PASS: FilterMode
1919
//| """A high-pass filter"""
20-
//| BAND_PASS: FilterType
20+
//| BAND_PASS: FilterMode
2121
//| """A band-pass filter"""
2222
//|
2323

24-
MAKE_ENUM_VALUE(synthio_filter_type, kind, LOW_PASS, SYNTHIO_LOW_PASS);
25-
MAKE_ENUM_VALUE(synthio_filter_type, kind, HIGH_PASS, SYNTHIO_HIGH_PASS);
26-
MAKE_ENUM_VALUE(synthio_filter_type, kind, BAND_PASS, SYNTHIO_BAND_PASS);
24+
MAKE_ENUM_VALUE(synthio_filter_mode_type, mode, LOW_PASS, SYNTHIO_LOW_PASS);
25+
MAKE_ENUM_VALUE(synthio_filter_mode_type, mode, HIGH_PASS, SYNTHIO_HIGH_PASS);
26+
MAKE_ENUM_VALUE(synthio_filter_mode_type, mode, BAND_PASS, SYNTHIO_BAND_PASS);
2727

28-
MAKE_ENUM_MAP(synthio_filter) {
29-
MAKE_ENUM_MAP_ENTRY(kind, LOW_PASS),
30-
MAKE_ENUM_MAP_ENTRY(kind, HIGH_PASS),
31-
MAKE_ENUM_MAP_ENTRY(kind, BAND_PASS),
28+
MAKE_ENUM_MAP(synthio_filter_mode) {
29+
MAKE_ENUM_MAP_ENTRY(mode, LOW_PASS),
30+
MAKE_ENUM_MAP_ENTRY(mode, HIGH_PASS),
31+
MAKE_ENUM_MAP_ENTRY(mode, BAND_PASS),
3232
};
3333

34-
static MP_DEFINE_CONST_DICT(synthio_filter_locals_dict, synthio_filter_locals_table);
34+
static MP_DEFINE_CONST_DICT(synthio_filter_mode_locals_dict, synthio_filter_mode_locals_table);
3535

36-
MAKE_PRINTER(synthio, synthio_filter);
36+
MAKE_PRINTER(synthio, synthio_filter_mode);
3737

38-
MAKE_ENUM_TYPE(synthio, FilterType, synthio_filter);
38+
MAKE_ENUM_TYPE(synthio, FilterMode, synthio_filter_mode);
3939

40-
static synthio_filter_e validate_synthio_filter(mp_obj_t obj, qstr arg_name) {
41-
return cp_enum_value(&synthio_filter_type, obj, arg_name);
40+
static synthio_filter_mode validate_synthio_filter_mode(mp_obj_t obj, qstr arg_name) {
41+
return cp_enum_value(&synthio_filter_mode_type, obj, arg_name);
4242
}
4343

4444
//| class BlockBiquad:
4545
//| def __init__(
4646
//| self,
47-
//| kind: FilterType,
47+
//| mode: FilterMode,
4848
//| frequency: BlockInput,
4949
//| q_factor: BlockInput = 0.7071067811865475,
5050
//| ) -> None:
@@ -61,13 +61,13 @@ static synthio_filter_e validate_synthio_filter(mp_obj_t obj, qstr arg_name) {
6161
//| appears to work as you'd expect."""
6262

6363
static const mp_arg_t block_biquad_properties[] = {
64-
{ MP_QSTR_kind, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL } },
64+
{ MP_QSTR_mode, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL } },
6565
{ MP_QSTR_frequency, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL } },
6666
{ MP_QSTR_Q, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL } },
6767
};
6868

6969
static mp_obj_t synthio_block_biquad_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
70-
enum { ARG_kind, ARG_frequency, ARG_Q };
70+
enum { ARG_mode, ARG_frequency, ARG_Q };
7171

7272
mp_arg_val_t args[MP_ARRAY_SIZE(block_biquad_properties)];
7373
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(block_biquad_properties), block_biquad_properties, args);
@@ -76,21 +76,21 @@ static mp_obj_t synthio_block_biquad_make_new(const mp_obj_type_t *type_in, size
7676
args[ARG_Q].u_obj = mp_obj_new_float(MICROPY_FLOAT_CONST(0.7071067811865475));
7777
}
7878

79-
synthio_filter_e kind = validate_synthio_filter(args[ARG_kind].u_obj, MP_QSTR_kind);
80-
return common_hal_synthio_block_biquad_new(kind, args[ARG_frequency].u_obj, args[ARG_Q].u_obj);
79+
synthio_filter_mode mode = validate_synthio_filter_mode(args[ARG_mode].u_obj, MP_QSTR_mode);
80+
return common_hal_synthio_block_biquad_new(mode, args[ARG_frequency].u_obj, args[ARG_Q].u_obj);
8181
}
8282

8383
//|
84-
//| kind: FilterType
85-
//| """The kind of filter (read-only)"""
86-
static mp_obj_t synthio_block_biquad_get_kind(mp_obj_t self_in) {
84+
//| mode: FilterMode
85+
//| """The mode of filter (read-only)"""
86+
static mp_obj_t synthio_block_biquad_get_mode(mp_obj_t self_in) {
8787
synthio_block_biquad_t *self = MP_OBJ_TO_PTR(self_in);
88-
return cp_enum_find(&synthio_filter_type, common_hal_synthio_block_biquad_get_kind(self));
88+
return cp_enum_find(&synthio_filter_mode_type, common_hal_synthio_block_biquad_get_mode(self));
8989
}
90-
MP_DEFINE_CONST_FUN_OBJ_1(synthio_block_biquad_get_kind_obj, synthio_block_biquad_get_kind);
90+
MP_DEFINE_CONST_FUN_OBJ_1(synthio_block_biquad_get_mode_obj, synthio_block_biquad_get_mode);
9191

92-
MP_PROPERTY_GETTER(synthio_block_biquad_kind_obj,
93-
(mp_obj_t)&synthio_block_biquad_get_kind_obj);
92+
MP_PROPERTY_GETTER(synthio_block_biquad_mode_obj,
93+
(mp_obj_t)&synthio_block_biquad_get_mode_obj);
9494

9595
//|
9696
//| frequency: BlockInput
@@ -133,7 +133,7 @@ MP_PROPERTY_GETSET(synthio_block_biquad_q_factor_obj,
133133
(mp_obj_t)&synthio_block_biquad_set_q_factor_obj);
134134

135135
static const mp_rom_map_elem_t synthio_block_biquad_locals_dict_table[] = {
136-
{ MP_ROM_QSTR(MP_QSTR_kind), MP_ROM_PTR(&synthio_block_biquad_kind_obj) },
136+
{ MP_ROM_QSTR(MP_QSTR_mode), MP_ROM_PTR(&synthio_block_biquad_mode_obj) },
137137
{ MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&synthio_block_biquad_frequency_obj) },
138138
{ MP_ROM_QSTR(MP_QSTR_q_factor), MP_ROM_PTR(&synthio_block_biquad_q_factor_obj) },
139139
};

shared-bindings/synthio/BlockBiquad.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
#include "py/obj.h"
1010

1111
extern const mp_obj_type_t synthio_block_biquad_type_obj;
12-
extern const mp_obj_type_t synthio_filter_type;
12+
extern const mp_obj_type_t synthio_filter_mode_type;
1313
typedef struct synthio_block_biquad synthio_block_biquad_t;
1414

1515
typedef enum {
1616
SYNTHIO_LOW_PASS, SYNTHIO_HIGH_PASS, SYNTHIO_BAND_PASS
17-
} synthio_filter_e;
17+
} synthio_filter_mode;
1818

1919

2020
mp_obj_t common_hal_synthio_block_biquad_get_q_factor(synthio_block_biquad_t *self);
@@ -23,6 +23,6 @@ void common_hal_synthio_block_biquad_set_q_factor(synthio_block_biquad_t *self,
2323
mp_obj_t common_hal_synthio_block_biquad_get_frequency(synthio_block_biquad_t *self);
2424
void common_hal_synthio_block_biquad_set_frequency(synthio_block_biquad_t *self, mp_obj_t frequency);
2525

26-
synthio_filter_e common_hal_synthio_block_biquad_get_kind(synthio_block_biquad_t *self);
26+
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_e kind, mp_obj_t frequency, mp_obj_t Q);
28+
mp_obj_t common_hal_synthio_block_biquad_new(synthio_filter_mode mode, mp_obj_t frequency, mp_obj_t Q);

shared-bindings/synthio/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static const mp_rom_map_elem_t synthio_module_globals_table[] = {
309309
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_synthio) },
310310
{ MP_ROM_QSTR(MP_QSTR_Biquad), MP_ROM_PTR(&synthio_biquad_type_obj) },
311311
{ MP_ROM_QSTR(MP_QSTR_BlockBiquad), MP_ROM_PTR(&synthio_block_biquad_type_obj) },
312-
{ MP_ROM_QSTR(MP_QSTR_FilterType), MP_ROM_PTR(&synthio_filter_type) },
312+
{ MP_ROM_QSTR(MP_QSTR_FilterMode), MP_ROM_PTR(&synthio_filter_mode_type) },
313313
{ MP_ROM_QSTR(MP_QSTR_Math), MP_ROM_PTR(&synthio_math_type) },
314314
{ MP_ROM_QSTR(MP_QSTR_MathOperation), MP_ROM_PTR(&synthio_math_operation_type) },
315315
{ MP_ROM_QSTR(MP_QSTR_MidiTrack), MP_ROM_PTR(&synthio_miditrack_type) },

shared-module/synthio/BlockBiquad.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ 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_e kind, mp_obj_t f0, mp_obj_t Q) {
33+
mp_obj_t common_hal_synthio_block_biquad_new(synthio_filter_mode mode, mp_obj_t f0, mp_obj_t Q) {
3434
synthio_block_biquad_t *self = mp_obj_malloc(synthio_block_biquad_t, &synthio_block_biquad_type_obj);
35-
self->kind = kind;
35+
self->mode = mode;
3636
synthio_block_assign_slot(f0, &self->f0, MP_QSTR_frequency);
3737
synthio_block_assign_slot(Q, &self->Q, MP_QSTR_q_factor);
3838
return MP_OBJ_FROM_PTR(self);
3939
}
4040

41-
synthio_filter_e common_hal_synthio_block_biquad_get_kind(synthio_block_biquad_t *self) {
42-
return self->kind;
41+
synthio_filter_mode common_hal_synthio_block_biquad_get_mode(synthio_block_biquad_t *self) {
42+
return self->mode;
4343
}
4444

4545
mp_obj_t common_hal_synthio_block_biquad_get_q_factor(synthio_block_biquad_t *self) {
@@ -79,7 +79,7 @@ void common_hal_synthio_block_biquad_tick(mp_obj_t self_in, biquad_filter_state
7979
a1 = -2 * sc.c;
8080
a2 = 1 - alpha;
8181

82-
switch (self->kind) {
82+
switch (self->mode) {
8383
default:
8484
case SYNTHIO_LOW_PASS:
8585
b2 = b0 = (1 - sc.c) * .5;

shared-module/synthio/BlockBiquad.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
typedef struct synthio_block_biquad {
1515
mp_obj_base_t base;
16-
synthio_filter_e kind;
16+
synthio_filter_mode mode;
1717
synthio_block_slot_t f0, Q;
1818
} synthio_block_biquad_t;
1919

tests/circuitpython-manual/synthio/note/blockfilter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def synthesize(synth):
3636

3737
for biquad in (
3838
None,
39-
synthio.BlockBiquad(synthio.FilterType.LOW_PASS, freq_sweep),
40-
synthio.BlockBiquad(synthio.FilterType.HIGH_PASS, freq_sweep),
41-
synthio.BlockBiquad(synthio.FilterType.BAND_PASS, freq_sweep, Q=8),
39+
synthio.BlockBiquad(synthio.FilterMode.LOW_PASS, freq_sweep),
40+
synthio.BlockBiquad(synthio.FilterMode.HIGH_PASS, freq_sweep),
41+
synthio.BlockBiquad(synthio.FilterMode.BAND_PASS, freq_sweep, Q=8),
4242
):
4343
n = synthio.Note(
4444
frequency=synthio.midi_to_hz(72),

0 commit comments

Comments
 (0)