2323//|
2424//| def __init__(
2525//| self,
26- //| filters : Optional[List [synthio.Biquad]] = None,
26+ //| filter : Optional[synthio.Biquad | Tuple [synthio.Biquad]] = None,
2727//| mix: synthio.BlockInput = 1.0,
2828//| buffer_size: int = 512,
2929//| sample_rate: int = 8000,
3838//| The mix parameter allows you to change how much of the unchanged sample passes through to
3939//| the output to how much of the effect audio you hear as the output.
4040//|
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 .
4242//| :param synthio.BlockInput mix: The mix as a ratio of the sample (0.0) to the effect (1.0).
4343//| :param int buffer_size: The total size in bytes of each of the two playback buffers to use
4444//| :param int sample_rate: The sample rate to be used
5757//| audio = audiobusio.I2SOut(bit_clock=board.GP20, word_select=board.GP21, data=board.GP22)
5858//| synth = synthio.Synthesizer(channel_count=1, sample_rate=44100)
5959//| 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)
6161//| effect.play(synth)
6262//| audio.play(effect)
6363//|
6969//| time.sleep(5)"""
7070//| ...
7171static 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 , };
7373 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 } },
7575 { MP_QSTR_mix , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_OBJ_NULL } },
7676 { MP_QSTR_buffer_size , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 512 } },
7777 { 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
9191 }
9292
9393 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 );
9595
9696 return MP_OBJ_FROM_PTR (self );
9797}
@@ -129,34 +129,34 @@ static mp_obj_t audiofilters_filter_obj___exit__(size_t n_args, const mp_obj_t *
129129static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (audiofilters_filter___exit___obj , 4 , 4 , audiofilters_filter_obj___exit__ ) ;
130130
131131
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 ."""
134134//|
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 ) {
136136 audiofilters_filter_obj_t * self = MP_OBJ_TO_PTR (self_in );
137137 check_for_deinit (self );
138- return common_hal_audiofilters_filter_get_filters (self );
138+ return common_hal_audiofilters_filter_get_filter (self );
139139}
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 );
141141
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 };
144144 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 , {} },
146146 };
147147 audiofilters_filter_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
148148 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
149149 mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
150150
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 );
152152
153153 return mp_const_none ;
154154}
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 );
156156
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 );
160160
161161
162162//| mix: synthio.BlockInput
@@ -245,7 +245,7 @@ static const mp_rom_map_elem_t audiofilters_filter_locals_dict_table[] = {
245245
246246 // Properties
247247 { 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 ) },
249249 { MP_ROM_QSTR (MP_QSTR_mix ), MP_ROM_PTR (& audiofilters_filter_mix_obj ) },
250250};
251251static MP_DEFINE_CONST_DICT (audiofilters_filter_locals_dict , audiofilters_filter_locals_dict_table ) ;
0 commit comments