Skip to content

Commit c06e6ee

Browse files
committed
BlockBiquad: Use Q as argument name
Synthesizer.lpf takes `Q` as the argument name, use the same convention here.
1 parent 6ff3860 commit c06e6ee

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

ports/raspberrypi/boards/raspberry_pi_pico2/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ CHIP_FAMILY = rp2
1010
EXTERNAL_FLASH_DEVICES = "W25Q32JVxQ"
1111

1212
CIRCUITPY__EVE = 1
13+
CIRCUITPY_SSL = 1

shared-bindings/synthio/BlockBiquad.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ static synthio_filter_mode validate_synthio_filter_mode(mp_obj_t obj, qstr arg_n
4848
//| self,
4949
//| mode: FilterMode,
5050
//| frequency: BlockInput,
51-
//| q_factor: BlockInput = 0.7071067811865475,
51+
//| Q: BlockInput = 0.7071067811865475,
5252
//| ) -> None:
5353
//| """Construct a biquad filter object with dynamic center frequency & q factor
5454
//|
55-
//| Since ``frequency`` and ``q_factor`` are `BlockInput` objects, they can
55+
//| Since ``frequency`` and ``Q`` are `BlockInput` objects, they can
5656
//| be varied dynamically. Internally, this is evaluated as "direct form 1"
5757
//| biquad filter.
5858
//|
@@ -115,29 +115,29 @@ MP_PROPERTY_GETSET(synthio_block_biquad_frequency_obj,
115115

116116

117117
//|
118-
//| q_factor: BlockInput
119-
//| """The sharpness (q_factor) of the filter"""
118+
//| Q: BlockInput
119+
//| """The sharpness (Q) of the filter"""
120120
//|
121-
static mp_obj_t synthio_block_biquad_get_q_factor(mp_obj_t self_in) {
121+
static mp_obj_t synthio_block_biquad_get_Q(mp_obj_t self_in) {
122122
synthio_block_biquad_t *self = MP_OBJ_TO_PTR(self_in);
123-
return common_hal_synthio_block_biquad_get_q_factor(self);
123+
return common_hal_synthio_block_biquad_get_Q(self);
124124
}
125-
MP_DEFINE_CONST_FUN_OBJ_1(synthio_block_biquad_get_q_factor_obj, synthio_block_biquad_get_q_factor);
125+
MP_DEFINE_CONST_FUN_OBJ_1(synthio_block_biquad_get_Q_obj, synthio_block_biquad_get_Q);
126126

127-
static mp_obj_t synthio_block_biquad_set_q_factor(mp_obj_t self_in, mp_obj_t arg) {
127+
static mp_obj_t synthio_block_biquad_set_Q(mp_obj_t self_in, mp_obj_t arg) {
128128
synthio_block_biquad_t *self = MP_OBJ_TO_PTR(self_in);
129-
common_hal_synthio_block_biquad_set_q_factor(self, arg);
129+
common_hal_synthio_block_biquad_set_Q(self, arg);
130130
return mp_const_none;
131131
}
132-
MP_DEFINE_CONST_FUN_OBJ_2(synthio_block_biquad_set_q_factor_obj, synthio_block_biquad_set_q_factor);
133-
MP_PROPERTY_GETSET(synthio_block_biquad_q_factor_obj,
134-
(mp_obj_t)&synthio_block_biquad_get_q_factor_obj,
135-
(mp_obj_t)&synthio_block_biquad_set_q_factor_obj);
132+
MP_DEFINE_CONST_FUN_OBJ_2(synthio_block_biquad_set_Q_obj, synthio_block_biquad_set_Q);
133+
MP_PROPERTY_GETSET(synthio_block_biquad_Q_obj,
134+
(mp_obj_t)&synthio_block_biquad_get_Q_obj,
135+
(mp_obj_t)&synthio_block_biquad_set_Q_obj);
136136

137137
static const mp_rom_map_elem_t synthio_block_biquad_locals_dict_table[] = {
138138
{ MP_ROM_QSTR(MP_QSTR_mode), MP_ROM_PTR(&synthio_block_biquad_mode_obj) },
139139
{ MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&synthio_block_biquad_frequency_obj) },
140-
{ MP_ROM_QSTR(MP_QSTR_q_factor), MP_ROM_PTR(&synthio_block_biquad_q_factor_obj) },
140+
{ MP_ROM_QSTR(MP_QSTR_Q), MP_ROM_PTR(&synthio_block_biquad_Q_obj) },
141141
};
142142
static MP_DEFINE_CONST_DICT(synthio_block_biquad_locals_dict, synthio_block_biquad_locals_dict_table);
143143

shared-bindings/synthio/BlockBiquad.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ typedef enum {
1717
} synthio_filter_mode;
1818

1919

20-
mp_obj_t common_hal_synthio_block_biquad_get_q_factor(synthio_block_biquad_t *self);
21-
void common_hal_synthio_block_biquad_set_q_factor(synthio_block_biquad_t *self, mp_obj_t Q);
20+
mp_obj_t common_hal_synthio_block_biquad_get_Q(synthio_block_biquad_t *self);
21+
void common_hal_synthio_block_biquad_set_Q(synthio_block_biquad_t *self, mp_obj_t Q);
2222

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);

shared-module/synthio/BlockBiquad.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ mp_obj_t common_hal_synthio_block_biquad_new(synthio_filter_mode mode, mp_obj_t
3434
synthio_block_biquad_t *self = mp_obj_malloc(synthio_block_biquad_t, &synthio_block_biquad_type_obj);
3535
self->mode = mode;
3636
synthio_block_assign_slot(f0, &self->f0, MP_QSTR_frequency);
37-
synthio_block_assign_slot(Q, &self->Q, MP_QSTR_q_factor);
37+
synthio_block_assign_slot(Q, &self->Q, MP_QSTR_Q);
3838
return MP_OBJ_FROM_PTR(self);
3939
}
4040

4141
synthio_filter_mode common_hal_synthio_block_biquad_get_mode(synthio_block_biquad_t *self) {
4242
return self->mode;
4343
}
4444

45-
mp_obj_t common_hal_synthio_block_biquad_get_q_factor(synthio_block_biquad_t *self) {
45+
mp_obj_t common_hal_synthio_block_biquad_get_Q(synthio_block_biquad_t *self) {
4646
return self->Q.obj;
4747
}
4848

49-
void common_hal_synthio_block_biquad_set_q_factor(synthio_block_biquad_t *self, mp_obj_t q_factor) {
50-
synthio_block_assign_slot(q_factor, &self->Q, MP_QSTR_q_factor);
49+
void common_hal_synthio_block_biquad_set_Q(synthio_block_biquad_t *self, mp_obj_t Q) {
50+
synthio_block_assign_slot(Q, &self->Q, MP_QSTR_Q);
5151
}
5252

5353
mp_obj_t common_hal_synthio_block_biquad_get_frequency(synthio_block_biquad_t *self) {

tests/circuitpython/synthio_block_biquad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
def gen(synth):
1111
l = LFO(sweep, offset=1440, scale=2880, rate=.025, once=True)
1212
yield [l]
13-
b = BlockBiquad(FilterMode.LOW_PASS, l)
13+
b = BlockBiquad(FilterMode.LOW_PASS, l, Q=.5**.5)
1414
n = Note(100, filter=b, waveform=white_noise)
1515
synth.press(n)
1616
yield 20

0 commit comments

Comments
 (0)