Skip to content

Commit 21ebcad

Browse files
committed
Add notch filter to BlockBiquad
1 parent e891bce commit 21ebcad

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

shared-bindings/synthio/BlockBiquad.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
MAKE_ENUM_VALUE(synthio_filter_mode_type, mode, LOW_PASS, SYNTHIO_LOW_PASS);
2525
MAKE_ENUM_VALUE(synthio_filter_mode_type, mode, HIGH_PASS, SYNTHIO_HIGH_PASS);
2626
MAKE_ENUM_VALUE(synthio_filter_mode_type, mode, BAND_PASS, SYNTHIO_BAND_PASS);
27+
MAKE_ENUM_VALUE(synthio_filter_mode_type, mode, NOTCH, SYNTHIO_NOTCH);
2728

2829
MAKE_ENUM_MAP(synthio_filter_mode) {
2930
MAKE_ENUM_MAP_ENTRY(mode, LOW_PASS),
3031
MAKE_ENUM_MAP_ENTRY(mode, HIGH_PASS),
3132
MAKE_ENUM_MAP_ENTRY(mode, BAND_PASS),
33+
MAKE_ENUM_MAP_ENTRY(mode, NOTCH),
3234
};
3335

3436
static MP_DEFINE_CONST_DICT(synthio_filter_mode_locals_dict, synthio_filter_mode_locals_table);

shared-bindings/synthio/BlockBiquad.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern const mp_obj_type_t synthio_filter_mode_type;
1313
typedef struct synthio_block_biquad synthio_block_biquad_t;
1414

1515
typedef enum {
16-
SYNTHIO_LOW_PASS, SYNTHIO_HIGH_PASS, SYNTHIO_BAND_PASS
16+
SYNTHIO_LOW_PASS, SYNTHIO_HIGH_PASS, SYNTHIO_BAND_PASS, SYNTHIO_NOTCH
1717
} synthio_filter_mode;
1818

1919

shared-module/synthio/BlockBiquad.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ void common_hal_synthio_block_biquad_tick(mp_obj_t self_in, biquad_filter_state
9595
b0 = alpha;
9696
b1 = 0;
9797
b2 = -b0;
98+
break;
99+
100+
case SYNTHIO_NOTCH:
101+
b0 = 1;
102+
b1 = -2 * sc.c;
103+
b2 = 1;
98104
}
99105

100106
mp_float_t recip_a0 = 1 / a0;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def synthesize(synth):
3939
synthio.BlockBiquad(synthio.FilterMode.LOW_PASS, freq_sweep),
4040
synthio.BlockBiquad(synthio.FilterMode.HIGH_PASS, freq_sweep),
4141
synthio.BlockBiquad(synthio.FilterMode.BAND_PASS, freq_sweep, Q=8),
42+
synthio.BlockBiquad(synthio.FilterMode.NOTCH, freq_sweep, Q=8),
4243
):
4344
n = synthio.Note(
4445
frequency=synthio.midi_to_hz(72),

0 commit comments

Comments
 (0)