Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions shared-bindings/audiodelays/Echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
//| max_delay_ms: int = 500,
//| delay_ms: synthio.BlockInput = 250.0,
//| decay: synthio.BlockInput = 0.7,
//| filter: Optional[synthio.Biquad | Tuple[synthio.Biquad]] = None,
//| mix: synthio.BlockInput = 0.25,
//| buffer_size: int = 512,
//| sample_rate: int = 8000,
Expand All @@ -45,6 +46,7 @@
//| :param int max_delay_ms: The maximum time the echo can be in milliseconds
//| :param synthio.BlockInput delay_ms: The current time of the echo delay in milliseconds. Must be less the max_delay_ms
//| :param synthio.BlockInput decay: The rate the echo fades. 0.0 = instant; 1.0 = never.
//| :param Optional[synthio.Biquad|Tuple[synthio.Biquad]] filter: A normalized biquad filter object or tuple of normalized biquad filter objects. A copy of the samples are processed sequentially by each filter before writing into the echo buffer. The original samples are not affected by this argument.
//| :param synthio.BlockInput mix: The mix as a ratio of the sample (0.0) to the effect (1.0).
//| :param int buffer_size: The total size in bytes of each of the two playback buffers to use
//| :param int sample_rate: The sample rate to be used
Expand Down Expand Up @@ -76,11 +78,12 @@
//| ...
//|
static mp_obj_t audiodelays_echo_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
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, };
enum { ARG_max_delay_ms, ARG_delay_ms, ARG_decay, ARG_filter, ARG_mix, ARG_buffer_size, ARG_sample_rate, ARG_bits_per_sample, ARG_samples_signed, ARG_channel_count, ARG_freq_shift, };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_max_delay_ms, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 500 } },
{ MP_QSTR_delay_ms, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_decay, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_filter, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_ROM_NONE } },
{ MP_QSTR_mix, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_buffer_size, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 512} },
{ MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 8000} },
Expand All @@ -103,7 +106,7 @@ static mp_obj_t audiodelays_echo_make_new(const mp_obj_type_t *type, size_t n_ar
}

audiodelays_echo_obj_t *self = mp_obj_malloc(audiodelays_echo_obj_t, &audiodelays_echo_type);
common_hal_audiodelays_echo_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, args[ARG_freq_shift].u_bool);
common_hal_audiodelays_echo_construct(self, max_delay_ms, args[ARG_delay_ms].u_obj, args[ARG_decay].u_obj, 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, args[ARG_freq_shift].u_bool);

return MP_OBJ_FROM_PTR(self);
}
Expand Down Expand Up @@ -177,6 +180,29 @@ MP_PROPERTY_GETSET(audiodelays_echo_decay_obj,
(mp_obj_t)&audiodelays_echo_get_decay_obj,
(mp_obj_t)&audiodelays_echo_set_decay_obj);


//| filter: synthio.Biquad | Tuple[synthio.Biquad] | None
//| """A normalized biquad filter object or tuple of normalized biquad filter objects. A copy of the samples are processed sequentially by each filter before writing into the echo buffer. The original samples are not affected by this property."""
//|
static mp_obj_t audiodelays_echo_obj_get_filter(mp_obj_t self_in) {
audiodelays_echo_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
return common_hal_audiodelays_echo_get_filter(self);
}
MP_DEFINE_CONST_FUN_OBJ_1(audiodelays_echo_get_filter_obj, audiodelays_echo_obj_get_filter);

static mp_obj_t audiodelays_echo_obj_set_filter(mp_obj_t self_in, mp_obj_t filter_in) {
audiodelays_echo_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_audiodelays_echo_set_filter(self, filter_in);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(audiodelays_echo_set_filter_obj, audiodelays_echo_obj_set_filter);

MP_PROPERTY_GETSET(audiodelays_echo_filter_obj,
(mp_obj_t)&audiodelays_echo_get_filter_obj,
(mp_obj_t)&audiodelays_echo_set_filter_obj);


//| mix: synthio.BlockInput
//| """The rate the echo mix between 0 and 1 where 0 is only sample, 0.5 is an equal mix of the sample and the effect and 1 is all effect."""
static mp_obj_t audiodelays_echo_obj_get_mix(mp_obj_t self_in) {
Expand Down Expand Up @@ -285,6 +311,7 @@ static const mp_rom_map_elem_t audiodelays_echo_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_playing), MP_ROM_PTR(&audiodelays_echo_playing_obj) },
{ MP_ROM_QSTR(MP_QSTR_delay_ms), MP_ROM_PTR(&audiodelays_echo_delay_ms_obj) },
{ MP_ROM_QSTR(MP_QSTR_decay), MP_ROM_PTR(&audiodelays_echo_decay_obj) },
{ MP_ROM_QSTR(MP_QSTR_filter), MP_ROM_PTR(&audiodelays_echo_filter_obj) },
{ MP_ROM_QSTR(MP_QSTR_mix), MP_ROM_PTR(&audiodelays_echo_mix_obj) },
{ MP_ROM_QSTR(MP_QSTR_freq_shift), MP_ROM_PTR(&audiodelays_echo_freq_shift_obj) },
AUDIOSAMPLE_FIELDS,
Expand Down
5 changes: 4 additions & 1 deletion shared-bindings/audiodelays/Echo.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
extern const mp_obj_type_t audiodelays_echo_type;

void common_hal_audiodelays_echo_construct(audiodelays_echo_obj_t *self, uint32_t max_delay_ms,
mp_obj_t delay_ms, mp_obj_t decay, mp_obj_t mix,
mp_obj_t delay_ms, mp_obj_t decay, mp_obj_t filter, mp_obj_t mix,
uint32_t buffer_size, uint8_t bits_per_sample, bool samples_signed,
uint8_t channel_count, uint32_t sample_rate, bool freq_shift);

Expand All @@ -26,6 +26,9 @@ void common_hal_audiodelays_echo_set_freq_shift(audiodelays_echo_obj_t *self, bo
mp_obj_t common_hal_audiodelays_echo_get_decay(audiodelays_echo_obj_t *self);
void common_hal_audiodelays_echo_set_decay(audiodelays_echo_obj_t *self, mp_obj_t decay);

mp_obj_t common_hal_audiodelays_echo_get_filter(audiodelays_echo_obj_t *self);
void common_hal_audiodelays_echo_set_filter(audiodelays_echo_obj_t *self, mp_obj_t arg);

mp_obj_t common_hal_audiodelays_echo_get_mix(audiodelays_echo_obj_t *self);
void common_hal_audiodelays_echo_set_mix(audiodelays_echo_obj_t *self, mp_obj_t arg);

Expand Down
57 changes: 55 additions & 2 deletions shared-bindings/audiofreeverb/Freeverb.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
//| self,
//| roomsize: synthio.BlockInput = 0.5,
//| damp: synthio.BlockInput = 0.5,
//| pre_filter: Optional[synthio.Biquad | Tuple[synthio.Biquad]] = None,
//| post_filter: Optional[synthio.Biquad | Tuple[synthio.Biquad]] = None,
//| mix: synthio.BlockInput = 0.5,
//| buffer_size: int = 512,
//| sample_rate: int = 8000,
Expand All @@ -40,6 +42,8 @@
//|
//| :param synthio.BlockInput roomsize: The size of the room. 0.0 = smallest; 1.0 = largest.
//| :param synthio.BlockInput damp: How much the walls absorb. 0.0 = least; 1.0 = most.
//| :param Optional[synthio.Biquad|Tuple[synthio.Biquad]] pre_filter: A normalized biquad filter object or tuple of normalized biquad filter objects. The sample is processed sequentially by each "Pre-EQ" filter before being fed to the reverb effect.
//| :param Optional[synthio.Biquad|Tuple[synthio.Biquad]] post_filter: A normalized biquad filter object or tuple of normalized biquad filter objects. The output of the reverb effect is processed sequentially by each "Post-EQ" filter before being mixed with the original sample.
//| :param synthio.BlockInput mix: The mix as a ratio of the sample (0.0) to the effect (1.0).
//| :param int buffer_size: The total size in bytes of each of the two playback buffers to use
//| :param int sample_rate: The sample rate to be used
Expand Down Expand Up @@ -70,10 +74,12 @@
//| ...
//|
static mp_obj_t audiofreeverb_freeverb_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
enum { ARG_roomsize, ARG_damp, ARG_mix, ARG_buffer_size, ARG_sample_rate, ARG_bits_per_sample, ARG_samples_signed, ARG_channel_count, };
enum { ARG_roomsize, ARG_damp, ARG_pre_filter, ARG_post_filter, ARG_mix, ARG_buffer_size, ARG_sample_rate, ARG_bits_per_sample, ARG_samples_signed, ARG_channel_count, };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_roomsize, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_damp, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_pre_filter, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_ROM_NONE } },
{ MP_QSTR_post_filter, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_ROM_NONE } },
{ MP_QSTR_mix, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_buffer_size, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 512} },
{ MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 8000} },
Expand All @@ -96,7 +102,7 @@ static mp_obj_t audiofreeverb_freeverb_make_new(const mp_obj_type_t *type, size_
}

audiofreeverb_freeverb_obj_t *self = mp_obj_malloc(audiofreeverb_freeverb_obj_t, &audiofreeverb_freeverb_type);
common_hal_audiofreeverb_freeverb_construct(self, args[ARG_roomsize].u_obj, args[ARG_damp].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);
common_hal_audiofreeverb_freeverb_construct(self, args[ARG_roomsize].u_obj, args[ARG_damp].u_obj, args[ARG_pre_filter].u_obj, args[ARG_post_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);

return MP_OBJ_FROM_PTR(self);
}
Expand Down Expand Up @@ -165,6 +171,51 @@ MP_PROPERTY_GETSET(audiofreeverb_freeverb_damp_obj,
(mp_obj_t)&audiofreeverb_freeverb_get_damp_obj,
(mp_obj_t)&audiofreeverb_freeverb_set_damp_obj);


//| pre_filter: synthio.Biquad | Tuple[synthio.Biquad] | None
//| """A normalized biquad filter object or tuple of normalized biquad filter objects. The sample is processed sequentially by each "Pre-EQ" filter before being fed to the reverb effect."""
//|
static mp_obj_t audiofreeverb_freeverb_obj_get_pre_filter(mp_obj_t self_in) {
audiofreeverb_freeverb_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
return common_hal_audiofreeverb_freeverb_get_pre_filter(self);
}
MP_DEFINE_CONST_FUN_OBJ_1(audiofreeverb_freeverb_get_pre_filter_obj, audiofreeverb_freeverb_obj_get_pre_filter);

static mp_obj_t audiofreeverb_freeverb_obj_set_pre_filter(mp_obj_t self_in, mp_obj_t filter_in) {
audiofreeverb_freeverb_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_audiofreeverb_freeverb_set_pre_filter(self, filter_in);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(audiofreeverb_freeverb_set_pre_filter_obj, audiofreeverb_freeverb_obj_set_pre_filter);

MP_PROPERTY_GETSET(audiofreeverb_freeverb_pre_filter_obj,
(mp_obj_t)&audiofreeverb_freeverb_get_pre_filter_obj,
(mp_obj_t)&audiofreeverb_freeverb_set_pre_filter_obj);


//| post_filter: synthio.Biquad | Tuple[synthio.Biquad] | None
//| """A normalized biquad filter object or tuple of normalized biquad filter objects. The output of the reverb effect is processed sequentially by each "Post-EQ" filter before being mixed with the original sample."""
//|
static mp_obj_t audiofreeverb_freeverb_obj_get_post_filter(mp_obj_t self_in) {
audiofreeverb_freeverb_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
return common_hal_audiofreeverb_freeverb_get_post_filter(self);
}
MP_DEFINE_CONST_FUN_OBJ_1(audiofreeverb_freeverb_get_post_filter_obj, audiofreeverb_freeverb_obj_get_post_filter);

static mp_obj_t audiofreeverb_freeverb_obj_set_post_filter(mp_obj_t self_in, mp_obj_t filter_in) {
audiofreeverb_freeverb_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_audiofreeverb_freeverb_set_post_filter(self, filter_in);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(audiofreeverb_freeverb_set_post_filter_obj, audiofreeverb_freeverb_obj_set_post_filter);

MP_PROPERTY_GETSET(audiofreeverb_freeverb_post_filter_obj,
(mp_obj_t)&audiofreeverb_freeverb_get_post_filter_obj,
(mp_obj_t)&audiofreeverb_freeverb_set_post_filter_obj);


//| mix: synthio.BlockInput
//| """The rate the reverb mix between 0 and 1 where 0 is only sample and 1 is all effect."""
static mp_obj_t audiofreeverb_freeverb_obj_get_mix(mp_obj_t self_in) {
Expand Down Expand Up @@ -251,6 +302,8 @@ static const mp_rom_map_elem_t audiofreeverb_freeverb_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_playing), MP_ROM_PTR(&audiofreeverb_freeverb_playing_obj) },
{ MP_ROM_QSTR(MP_QSTR_roomsize), MP_ROM_PTR(&audiofreeverb_freeverb_roomsize_obj) },
{ MP_ROM_QSTR(MP_QSTR_damp), MP_ROM_PTR(&audiofreeverb_freeverb_damp_obj) },
{ MP_ROM_QSTR(MP_QSTR_pre_filter), MP_ROM_PTR(&audiofreeverb_freeverb_pre_filter_obj) },
{ MP_ROM_QSTR(MP_QSTR_post_filter), MP_ROM_PTR(&audiofreeverb_freeverb_post_filter_obj) },
{ MP_ROM_QSTR(MP_QSTR_mix), MP_ROM_PTR(&audiofreeverb_freeverb_mix_obj) },
AUDIOSAMPLE_FIELDS,
};
Expand Down
8 changes: 7 additions & 1 deletion shared-bindings/audiofreeverb/Freeverb.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
extern const mp_obj_type_t audiofreeverb_freeverb_type;

void common_hal_audiofreeverb_freeverb_construct(audiofreeverb_freeverb_obj_t *self,
mp_obj_t roomsize, mp_obj_t damp, mp_obj_t mix,
mp_obj_t roomsize, mp_obj_t damp, mp_obj_t pre_filter, mp_obj_t post_filter, mp_obj_t mix,
uint32_t buffer_size, uint8_t bits_per_sample, bool samples_signed,
uint8_t channel_count, uint32_t sample_rate);

Expand All @@ -24,6 +24,12 @@ void common_hal_audiofreeverb_freeverb_set_roomsize(audiofreeverb_freeverb_obj_t
mp_obj_t common_hal_audiofreeverb_freeverb_get_damp(audiofreeverb_freeverb_obj_t *self);
void common_hal_audiofreeverb_freeverb_set_damp(audiofreeverb_freeverb_obj_t *self, mp_obj_t damp);

mp_obj_t common_hal_audiofreeverb_freeverb_get_pre_filter(audiofreeverb_freeverb_obj_t *self);
void common_hal_audiofreeverb_freeverb_set_pre_filter(audiofreeverb_freeverb_obj_t *self, mp_obj_t arg);

mp_obj_t common_hal_audiofreeverb_freeverb_get_post_filter(audiofreeverb_freeverb_obj_t *self);
void common_hal_audiofreeverb_freeverb_set_post_filter(audiofreeverb_freeverb_obj_t *self, mp_obj_t arg);

mp_obj_t common_hal_audiofreeverb_freeverb_get_mix(audiofreeverb_freeverb_obj_t *self);
void common_hal_audiofreeverb_freeverb_set_mix(audiofreeverb_freeverb_obj_t *self, mp_obj_t mix);

Expand Down
Loading
Loading