41
41
//| :param int max_delay_ms: The maximum time the chorus can be in milliseconds
42
42
//| :param synthio.BlockInput delay_ms: The current time of the chorus delay in milliseconds. Must be less the max_delay_ms.
43
43
//| :param synthio.BlockInput voices: The number of voices playing split evenly over the delay buffer.
44
+ //| :param synthio.BlockInput mix: How much of the wet audio to include along with the original signal.
44
45
//| :param int buffer_size: The total size in bytes of each of the two playback buffers to use
45
46
//| :param int sample_rate: The sample rate to be used
46
47
//| :param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo.
70
71
//| ...
71
72
//|
72
73
static mp_obj_t audiodelays_chorus_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
73
- enum { ARG_max_delay_ms , ARG_delay_ms , ARG_voices , ARG_buffer_size , ARG_sample_rate , ARG_bits_per_sample , ARG_samples_signed , ARG_channel_count , };
74
+ enum { ARG_max_delay_ms , ARG_delay_ms , ARG_voices , ARG_mix , ARG_buffer_size , ARG_sample_rate , ARG_bits_per_sample , ARG_samples_signed , ARG_channel_count , };
74
75
static const mp_arg_t allowed_args [] = {
75
76
{ MP_QSTR_max_delay_ms , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 50 } },
76
77
{ MP_QSTR_delay_ms , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_OBJ_NULL } },
77
78
{ MP_QSTR_voices , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_OBJ_NULL } },
79
+ { MP_QSTR_mix , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_OBJ_NULL } },
78
80
{ MP_QSTR_buffer_size , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 512 } },
79
81
{ MP_QSTR_sample_rate , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 8000 } },
80
82
{ MP_QSTR_bits_per_sample , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 16 } },
@@ -95,7 +97,7 @@ static mp_obj_t audiodelays_chorus_make_new(const mp_obj_type_t *type, size_t n_
95
97
}
96
98
97
99
audiodelays_chorus_obj_t * self = mp_obj_malloc (audiodelays_chorus_obj_t , & audiodelays_chorus_type );
98
- common_hal_audiodelays_chorus_construct (self , max_delay_ms , args [ARG_delay_ms ].u_obj , args [ARG_voices ].u_obj , args [ARG_buffer_size ].u_int , bits_per_sample , args [ARG_samples_signed ].u_bool , channel_count , sample_rate );
100
+ common_hal_audiodelays_chorus_construct (self , max_delay_ms , args [ARG_delay_ms ].u_obj , args [ARG_voices ].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 );
99
101
100
102
return MP_OBJ_FROM_PTR (self );
101
103
}
@@ -173,6 +175,24 @@ MP_PROPERTY_GETSET(audiodelays_chorus_voices_obj,
173
175
(mp_obj_t )& audiodelays_chorus_get_voices_obj ,
174
176
(mp_obj_t )& audiodelays_chorus_set_voices_obj );
175
177
178
+ //| mix: synthio.BlockInput
179
+ //| """The rate the echo mix between 0 and 1 where 0 is only sample and 1 is all effect."""
180
+ static mp_obj_t audiodelays_chorus_obj_get_mix (mp_obj_t self_in ) {
181
+ return common_hal_audiodelays_chorus_get_mix (self_in );
182
+ }
183
+ MP_DEFINE_CONST_FUN_OBJ_1 (audiodelays_chorus_get_mix_obj , audiodelays_chorus_obj_get_mix );
184
+
185
+ static mp_obj_t audiodelays_chorus_obj_set_mix (mp_obj_t self_in , mp_obj_t mix_in ) {
186
+ audiodelays_chorus_obj_t * self = MP_OBJ_TO_PTR (self_in );
187
+ common_hal_audiodelays_chorus_set_mix (self , mix_in );
188
+ return mp_const_none ;
189
+ }
190
+ MP_DEFINE_CONST_FUN_OBJ_2 (audiodelays_chorus_set_mix_obj , audiodelays_chorus_obj_set_mix );
191
+
192
+ MP_PROPERTY_GETSET (audiodelays_chorus_mix_obj ,
193
+ (mp_obj_t )& audiodelays_chorus_get_mix_obj ,
194
+ (mp_obj_t )& audiodelays_chorus_set_mix_obj );
195
+
176
196
//| playing: bool
177
197
//| """True when the effect is playing a sample. (read-only)"""
178
198
//|
@@ -237,6 +257,7 @@ static const mp_rom_map_elem_t audiodelays_chorus_locals_dict_table[] = {
237
257
{ MP_ROM_QSTR (MP_QSTR_playing ), MP_ROM_PTR (& audiodelays_chorus_playing_obj ) },
238
258
{ MP_ROM_QSTR (MP_QSTR_delay_ms ), MP_ROM_PTR (& audiodelays_chorus_delay_ms_obj ) },
239
259
{ MP_ROM_QSTR (MP_QSTR_voices ), MP_ROM_PTR (& audiodelays_chorus_voices_obj ) },
260
+ { MP_ROM_QSTR (MP_QSTR_mix ), MP_ROM_PTR (& audiodelays_chorus_mix_obj ) },
240
261
AUDIOSAMPLE_FIELDS ,
241
262
};
242
263
static MP_DEFINE_CONST_DICT (audiodelays_chorus_locals_dict , audiodelays_chorus_locals_dict_table ) ;
0 commit comments