2626//| delay_ms: synthio.BlockInput = 250.0,
2727//| decay: synthio.BlockInput = 0.7,
2828//| mix: synthio.BlockInput = 0.25,
29+ //| taps: Tuple[float|Tuple[float, float], ...] = None,
2930//| buffer_size: int = 512,
3031//| sample_rate: int = 8000,
3132//| bits_per_sample: int = 16,
4647//| :param float delay_ms: The current time of the echo delay in milliseconds. Must be less the max_delay_ms
4748//| :param synthio.BlockInput decay: The rate the echo fades. 0.0 = instant; 1.0 = never.
4849//| :param synthio.BlockInput mix: The mix as a ratio of the sample (0.0) to the effect (1.0).
50+ //| :param tuple taps: The positions and levels to tap into the delay buffer.
4951//| :param int buffer_size: The total size in bytes of each of the two playback buffers to use
5052//| :param int sample_rate: The sample rate to be used
5153//| :param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo.
7577//| ...
7678//|
7779static mp_obj_t audiodelays_multi_tap_delay_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
78- enum { ARG_max_delay_ms , ARG_delay_ms , ARG_decay , ARG_mix , ARG_buffer_size , ARG_sample_rate , ARG_bits_per_sample , ARG_samples_signed , ARG_channel_count , ARG_freq_shift , };
80+ enum { ARG_max_delay_ms , ARG_delay_ms , ARG_decay , ARG_mix , ARG_taps , ARG_buffer_size , ARG_sample_rate , ARG_bits_per_sample , ARG_samples_signed , ARG_channel_count , };
7981 static const mp_arg_t allowed_args [] = {
8082 { MP_QSTR_max_delay_ms , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 500 } },
8183 { MP_QSTR_delay_ms , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (250 ) } },
8284 { MP_QSTR_decay , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_OBJ_NULL } },
8385 { MP_QSTR_mix , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_OBJ_NULL } },
86+ { MP_QSTR_taps , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = mp_const_none } },
8487 { MP_QSTR_buffer_size , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 512 } },
8588 { MP_QSTR_sample_rate , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 8000 } },
8689 { MP_QSTR_bits_per_sample , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 16 } },
@@ -101,7 +104,7 @@ static mp_obj_t audiodelays_multi_tap_delay_make_new(const mp_obj_type_t *type,
101104 }
102105
103106 audiodelays_multi_tap_delay_obj_t * self = mp_obj_malloc (audiodelays_multi_tap_delay_obj_t , & audiodelays_multi_tap_delay_type );
104- common_hal_audiodelays_multi_tap_delay_construct (self , max_delay_ms , args [ARG_delay_ms ].u_obj , args [ARG_decay ].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 );
107+ common_hal_audiodelays_multi_tap_delay_construct (self , max_delay_ms , args [ARG_delay_ms ].u_obj , args [ARG_decay ].u_obj , args [ARG_mix ].u_obj , args [ARG_taps ]. u_obj , args [ ARG_buffer_size ].u_int , bits_per_sample , args [ARG_samples_signed ].u_bool , channel_count , sample_rate );
105108
106109 return MP_OBJ_FROM_PTR (self );
107110}
@@ -191,6 +194,29 @@ MP_PROPERTY_GETSET(audiodelays_multi_tap_delay_mix_obj,
191194 (mp_obj_t )& audiodelays_multi_tap_delay_get_mix_obj ,
192195 (mp_obj_t )& audiodelays_multi_tap_delay_set_mix_obj );
193196
197+ //| taps: Tuple[float|Tuple[float, float], ...]
198+ //| """The position or position and level of delay taps.
199+ //| The position is a number from 0.0 (start) to 1.0 (end) as a relative position in the delay buffer.
200+ //| The level is a number from 0.0 (silence) to 1.0 (full volume).
201+ //| If only a float is provided as an element of the tuple, the level is assumed to be 1.0.
202+ //| When retrieving the value of this property, the level will always be included."""
203+ //|
204+ static mp_obj_t audiodelays_multi_tap_delay_obj_get_taps (mp_obj_t self_in ) {
205+ return common_hal_audiodelays_multi_tap_delay_get_taps (self_in );
206+ }
207+ MP_DEFINE_CONST_FUN_OBJ_1 (audiodelays_multi_tap_delay_get_taps_obj , audiodelays_multi_tap_delay_obj_get_taps );
208+
209+ static mp_obj_t audiodelays_multi_tap_delay_obj_set_taps (mp_obj_t self_in , mp_obj_t taps_in ) {
210+ audiodelays_multi_tap_delay_obj_t * self = MP_OBJ_TO_PTR (self_in );
211+ common_hal_audiodelays_multi_tap_delay_set_taps (self , taps_in );
212+ return mp_const_none ;
213+ }
214+ MP_DEFINE_CONST_FUN_OBJ_2 (audiodelays_multi_tap_delay_set_taps_obj , audiodelays_multi_tap_delay_obj_set_taps );
215+
216+ MP_PROPERTY_GETSET (audiodelays_multi_tap_delay_taps_obj ,
217+ (mp_obj_t )& audiodelays_multi_tap_delay_get_taps_obj ,
218+ (mp_obj_t )& audiodelays_multi_tap_delay_set_taps_obj );
219+
194220
195221
196222//| playing: bool
@@ -258,6 +284,7 @@ static const mp_rom_map_elem_t audiodelays_multi_tap_delay_locals_dict_table[] =
258284 { MP_ROM_QSTR (MP_QSTR_delay_ms ), MP_ROM_PTR (& audiodelays_multi_tap_delay_delay_ms_obj ) },
259285 { MP_ROM_QSTR (MP_QSTR_decay ), MP_ROM_PTR (& audiodelays_multi_tap_delay_decay_obj ) },
260286 { MP_ROM_QSTR (MP_QSTR_mix ), MP_ROM_PTR (& audiodelays_multi_tap_delay_mix_obj ) },
287+ { MP_ROM_QSTR (MP_QSTR_taps ), MP_ROM_PTR (& audiodelays_multi_tap_delay_taps_obj ) },
261288 AUDIOSAMPLE_FIELDS ,
262289};
263290static MP_DEFINE_CONST_DICT (audiodelays_multi_tap_delay_locals_dict , audiodelays_multi_tap_delay_locals_dict_table ) ;
0 commit comments