26
26
//| delay_ms: synthio.BlockInput = 250.0,
27
27
//| decay: synthio.BlockInput = 0.7,
28
28
//| mix: synthio.BlockInput = 0.25,
29
+ //| taps: Tuple[float|Tuple[float, float], ...] = None,
29
30
//| buffer_size: int = 512,
30
31
//| sample_rate: int = 8000,
31
32
//| bits_per_sample: int = 16,
46
47
//| :param float delay_ms: The current time of the echo delay in milliseconds. Must be less the max_delay_ms
47
48
//| :param synthio.BlockInput decay: The rate the echo fades. 0.0 = instant; 1.0 = never.
48
49
//| :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.
49
51
//| :param int buffer_size: The total size in bytes of each of the two playback buffers to use
50
52
//| :param int sample_rate: The sample rate to be used
51
53
//| :param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo.
75
77
//| ...
76
78
//|
77
79
static 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 , };
79
81
static const mp_arg_t allowed_args [] = {
80
82
{ MP_QSTR_max_delay_ms , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 500 } },
81
83
{ MP_QSTR_delay_ms , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (250 ) } },
82
84
{ MP_QSTR_decay , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_OBJ_NULL } },
83
85
{ 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 } },
84
87
{ MP_QSTR_buffer_size , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 512 } },
85
88
{ MP_QSTR_sample_rate , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 8000 } },
86
89
{ 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,
101
104
}
102
105
103
106
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 );
105
108
106
109
return MP_OBJ_FROM_PTR (self );
107
110
}
@@ -191,6 +194,29 @@ MP_PROPERTY_GETSET(audiodelays_multi_tap_delay_mix_obj,
191
194
(mp_obj_t )& audiodelays_multi_tap_delay_get_mix_obj ,
192
195
(mp_obj_t )& audiodelays_multi_tap_delay_set_mix_obj );
193
196
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
+
194
220
195
221
196
222
//| playing: bool
@@ -258,6 +284,7 @@ static const mp_rom_map_elem_t audiodelays_multi_tap_delay_locals_dict_table[] =
258
284
{ MP_ROM_QSTR (MP_QSTR_delay_ms ), MP_ROM_PTR (& audiodelays_multi_tap_delay_delay_ms_obj ) },
259
285
{ MP_ROM_QSTR (MP_QSTR_decay ), MP_ROM_PTR (& audiodelays_multi_tap_delay_decay_obj ) },
260
286
{ 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 ) },
261
288
AUDIOSAMPLE_FIELDS ,
262
289
};
263
290
static MP_DEFINE_CONST_DICT (audiodelays_multi_tap_delay_locals_dict , audiodelays_multi_tap_delay_locals_dict_table ) ;
0 commit comments