4141//| :param int max_delay_ms: The maximum time the chorus can be in milliseconds
4242//| :param synthio.BlockInput delay_ms: The current time of the chorus delay in milliseconds. Must be less the max_delay_ms.
4343//| :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.
4445//| :param int buffer_size: The total size in bytes of each of the two playback buffers to use
4546//| :param int sample_rate: The sample rate to be used
4647//| :param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo.
7071//| ...
7172//|
7273static 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 , };
7475 static const mp_arg_t allowed_args [] = {
7576 { MP_QSTR_max_delay_ms , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 50 } },
7677 { MP_QSTR_delay_ms , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_OBJ_NULL } },
7778 { 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 } },
7880 { MP_QSTR_buffer_size , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 512 } },
7981 { MP_QSTR_sample_rate , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 8000 } },
8082 { 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_
9597 }
9698
9799 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 );
99101
100102 return MP_OBJ_FROM_PTR (self );
101103}
@@ -173,6 +175,24 @@ MP_PROPERTY_GETSET(audiodelays_chorus_voices_obj,
173175 (mp_obj_t )& audiodelays_chorus_get_voices_obj ,
174176 (mp_obj_t )& audiodelays_chorus_set_voices_obj );
175177
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+
176196//| playing: bool
177197//| """True when the effect is playing a sample. (read-only)"""
178198//|
@@ -237,6 +257,7 @@ static const mp_rom_map_elem_t audiodelays_chorus_locals_dict_table[] = {
237257 { MP_ROM_QSTR (MP_QSTR_playing ), MP_ROM_PTR (& audiodelays_chorus_playing_obj ) },
238258 { MP_ROM_QSTR (MP_QSTR_delay_ms ), MP_ROM_PTR (& audiodelays_chorus_delay_ms_obj ) },
239259 { 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 ) },
240261 AUDIOSAMPLE_FIELDS ,
241262};
242263static MP_DEFINE_CONST_DICT (audiodelays_chorus_locals_dict , audiodelays_chorus_locals_dict_table ) ;
0 commit comments