23
23
//|
24
24
//| def __init__(
25
25
//| self,
26
- //| filters : Optional[List [synthio.Biquad]] = None,
26
+ //| filter : Optional[synthio.Biquad | Tuple [synthio.Biquad]] = None,
27
27
//| mix: synthio.BlockInput = 1.0,
28
28
//| buffer_size: int = 512,
29
29
//| sample_rate: int = 8000,
38
38
//| The mix parameter allows you to change how much of the unchanged sample passes through to
39
39
//| the output to how much of the effect audio you hear as the output.
40
40
//|
41
- //| :param Optional[List [synthio.Biquad]] filters : A list of normalized biquad filter objects used to process the signal .
41
+ //| :param Optional[synthio.Biquad|Tuple [synthio.Biquad]] filter : A normalized biquad filter object or tuple of normalized biquad filter objects. The sample is processed sequentially by each filter to produce the output samples .
42
42
//| :param synthio.BlockInput mix: The mix as a ratio of the sample (0.0) to the effect (1.0).
43
43
//| :param int buffer_size: The total size in bytes of each of the two playback buffers to use
44
44
//| :param int sample_rate: The sample rate to be used
57
57
//| audio = audiobusio.I2SOut(bit_clock=board.GP20, word_select=board.GP21, data=board.GP22)
58
58
//| synth = synthio.Synthesizer(channel_count=1, sample_rate=44100)
59
59
//| effect = audiofilters.Filter(buffer_size=1024, channel_count=1, sample_rate=44100, mix=1.0)
60
- //| effect.filters.append( synth.low_pass_filter(frequency=2000, Q=1.25) )
60
+ //| effect.filter = synth.low_pass_filter(frequency=2000, Q=1.25)
61
61
//| effect.play(synth)
62
62
//| audio.play(effect)
63
63
//|
69
69
//| time.sleep(5)"""
70
70
//| ...
71
71
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 ) {
72
- enum { ARG_filters , ARG_mix , ARG_buffer_size , ARG_sample_rate , ARG_bits_per_sample , ARG_samples_signed , ARG_channel_count , };
72
+ enum { ARG_filter , ARG_mix , ARG_buffer_size , ARG_sample_rate , ARG_bits_per_sample , ARG_samples_signed , ARG_channel_count , };
73
73
static const mp_arg_t allowed_args [] = {
74
- { MP_QSTR_filters , 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_OBJ_NULL } },
75
75
{ MP_QSTR_mix , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_OBJ_NULL } },
76
76
{ MP_QSTR_buffer_size , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 512 } },
77
77
{ MP_QSTR_sample_rate , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 8000 } },
@@ -91,7 +91,7 @@ static mp_obj_t audiofilters_filter_make_new(const mp_obj_type_t *type, size_t n
91
91
}
92
92
93
93
audiofilters_filter_obj_t * self = mp_obj_malloc (audiofilters_filter_obj_t , & audiofilters_filter_type );
94
- common_hal_audiofilters_filter_construct (self , args [ARG_filters ].u_obj , args [ARG_mix ].u_obj , args [ARG_buffer_size ].u_int , bits_per_sample , args [ARG_samples_signed ].u_bool , channel_count , sample_rate );
94
+ common_hal_audiofilters_filter_construct (self , args [ARG_filter ].u_obj , args [ARG_mix ].u_obj , args [ARG_buffer_size ].u_int , bits_per_sample , args [ARG_samples_signed ].u_bool , channel_count , sample_rate );
95
95
96
96
return MP_OBJ_FROM_PTR (self );
97
97
}
@@ -129,34 +129,34 @@ static mp_obj_t audiofilters_filter_obj___exit__(size_t n_args, const mp_obj_t *
129
129
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (audiofilters_filter___exit___obj , 4 , 4 , audiofilters_filter_obj___exit__ ) ;
130
130
131
131
132
- //| filters: List [synthio.Biquad]
133
- //| """A list of normalized biquad filter objects used to process the signal ."""
132
+ //| filter: synthio.Biquad | Tuple [synthio.Biquad] | None
133
+ //| """A normalized biquad filter object or tuple of normalized biquad filter objects. The sample is processed sequentially by each filter to produce the output samples ."""
134
134
//|
135
- static mp_obj_t audiofilters_filter_obj_get_filters (mp_obj_t self_in ) {
135
+ static mp_obj_t audiofilters_filter_obj_get_filter (mp_obj_t self_in ) {
136
136
audiofilters_filter_obj_t * self = MP_OBJ_TO_PTR (self_in );
137
137
check_for_deinit (self );
138
- return common_hal_audiofilters_filter_get_filters (self );
138
+ return common_hal_audiofilters_filter_get_filter (self );
139
139
}
140
- MP_DEFINE_CONST_FUN_OBJ_1 (audiofilters_filter_get_filters_obj , audiofilters_filter_obj_get_filters );
140
+ MP_DEFINE_CONST_FUN_OBJ_1 (audiofilters_filter_get_filter_obj , audiofilters_filter_obj_get_filter );
141
141
142
- static mp_obj_t audiofilters_filter_obj_set_filters (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
143
- enum { ARG_filters };
142
+ static mp_obj_t audiofilters_filter_obj_set_filter (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
143
+ enum { ARG_filter };
144
144
static const mp_arg_t allowed_args [] = {
145
- { MP_QSTR_filters , MP_ARG_OBJ | MP_ARG_REQUIRED , {} },
145
+ { MP_QSTR_filter , MP_ARG_OBJ | MP_ARG_REQUIRED , {} },
146
146
};
147
147
audiofilters_filter_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
148
148
mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
149
149
mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
150
150
151
- common_hal_audiofilters_filter_set_filters (self , args [ARG_filters ].u_obj );
151
+ common_hal_audiofilters_filter_set_filter (self , args [ARG_filter ].u_obj );
152
152
153
153
return mp_const_none ;
154
154
}
155
- MP_DEFINE_CONST_FUN_OBJ_KW (audiofilters_filter_set_filters_obj , 1 , audiofilters_filter_obj_set_filters );
155
+ MP_DEFINE_CONST_FUN_OBJ_KW (audiofilters_filter_set_filter_obj , 1 , audiofilters_filter_obj_set_filter );
156
156
157
- MP_PROPERTY_GETSET (audiofilters_filter_filters_obj ,
158
- (mp_obj_t )& audiofilters_filter_get_filters_obj ,
159
- (mp_obj_t )& audiofilters_filter_set_filters_obj );
157
+ MP_PROPERTY_GETSET (audiofilters_filter_filter_obj ,
158
+ (mp_obj_t )& audiofilters_filter_get_filter_obj ,
159
+ (mp_obj_t )& audiofilters_filter_set_filter_obj );
160
160
161
161
162
162
//| mix: synthio.BlockInput
@@ -245,7 +245,7 @@ static const mp_rom_map_elem_t audiofilters_filter_locals_dict_table[] = {
245
245
246
246
// Properties
247
247
{ MP_ROM_QSTR (MP_QSTR_playing ), MP_ROM_PTR (& audiofilters_filter_playing_obj ) },
248
- { MP_ROM_QSTR (MP_QSTR_filters ), MP_ROM_PTR (& audiofilters_filter_filters_obj ) },
248
+ { MP_ROM_QSTR (MP_QSTR_filter ), MP_ROM_PTR (& audiofilters_filter_filter_obj ) },
249
249
{ MP_ROM_QSTR (MP_QSTR_mix ), MP_ROM_PTR (& audiofilters_filter_mix_obj ) },
250
250
};
251
251
static MP_DEFINE_CONST_DICT (audiofilters_filter_locals_dict , audiofilters_filter_locals_dict_table ) ;
0 commit comments