66
77#include <stdint.h>
88
9- #include "shared-bindings/audioeffects /Echo.h"
10- #include "shared-module/audioeffects /Echo.h"
9+ #include "shared-bindings/audiodelays /Echo.h"
10+ #include "shared-module/audiodelays /Echo.h"
1111
1212#include "shared/runtime/context_manager_helpers.h"
1313#include "py/binary.h"
2020//| class Echo:
2121//| """An Echo effect"""
2222//|
23- static mp_obj_t audioeffects_echo_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
23+ 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 ) {
2424 enum { ARG_delay_ms , ARG_decay , ARG_buffer_size , ARG_sample_rate , ARG_bits_per_sample , ARG_samples_signed , ARG_channel_count , };
2525 static const mp_arg_t allowed_args [] = {
2626 { MP_QSTR_delay_ms , MP_ARG_INT | MP_ARG_KW_ONLY , {.u_int = 50 } },
@@ -49,24 +49,24 @@ static mp_obj_t audioeffects_echo_make_new(const mp_obj_type_t *type, size_t n_a
4949 mp_raise_ValueError (MP_ERROR_TEXT ("bits_per_sample must be 8 or 16" ));
5050 }
5151
52- audioeffects_echo_obj_t * self = mp_obj_malloc (audioeffects_echo_obj_t , & audioeffects_echo_type );
53- common_hal_audioeffects_echo_construct (self , delay_ms , decay , args [ARG_buffer_size ].u_int , bits_per_sample , args [ARG_samples_signed ].u_bool , channel_count , sample_rate );
52+ audiodelays_echo_obj_t * self = mp_obj_malloc (audiodelays_echo_obj_t , & audiodelays_echo_type );
53+ common_hal_audiodelays_echo_construct (self , delay_ms , decay , args [ARG_buffer_size ].u_int , bits_per_sample , args [ARG_samples_signed ].u_bool , channel_count , sample_rate );
5454
5555 return MP_OBJ_FROM_PTR (self );
5656}
5757
5858//| def deinit(self) -> None:
5959//| """Deinitialises the Echo and releases any hardware resources for reuse."""
6060//| ...
61- static mp_obj_t audioeffects_echo_deinit (mp_obj_t self_in ) {
62- audioeffects_echo_obj_t * self = MP_OBJ_TO_PTR (self_in );
63- common_hal_audioeffects_echo_deinit (self );
61+ static mp_obj_t audiodelays_echo_deinit (mp_obj_t self_in ) {
62+ audiodelays_echo_obj_t * self = MP_OBJ_TO_PTR (self_in );
63+ common_hal_audiodelays_echo_deinit (self );
6464 return mp_const_none ;
6565}
66- static MP_DEFINE_CONST_FUN_OBJ_1 (audioeffects_echo_deinit_obj , audioeffects_echo_deinit ) ;
66+ static MP_DEFINE_CONST_FUN_OBJ_1 (audiodelays_echo_deinit_obj , audiodelays_echo_deinit ) ;
6767
68- static void check_for_deinit (audioeffects_echo_obj_t * self ) {
69- if (common_hal_audioeffects_echo_deinited (self )) {
68+ static void check_for_deinit (audiodelays_echo_obj_t * self ) {
69+ if (common_hal_audiodelays_echo_deinited (self )) {
7070 raise_deinited_error ();
7171 }
7272}
@@ -80,61 +80,61 @@ static void check_for_deinit(audioeffects_echo_obj_t *self) {
8080//| """Automatically deinitializes the hardware when exiting a context. See
8181//| :ref:`lifetime-and-contextmanagers` for more info."""
8282//| ...
83- static mp_obj_t audioeffects_echo_obj___exit__ (size_t n_args , const mp_obj_t * args ) {
83+ static mp_obj_t audiodelays_echo_obj___exit__ (size_t n_args , const mp_obj_t * args ) {
8484 (void )n_args ;
85- common_hal_audioeffects_echo_deinit (args [0 ]);
85+ common_hal_audiodelays_echo_deinit (args [0 ]);
8686 return mp_const_none ;
8787}
88- static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (audioeffects_echo___exit___obj , 4 , 4 , audioeffects_echo_obj___exit__ ) ;
88+ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (audiodelays_echo___exit___obj , 4 , 4 , audiodelays_echo_obj___exit__ ) ;
8989
9090
9191//| delay_ms: int
9292//| """Delay of the echo in microseconds. (read-only)"""
9393//|
94- static mp_obj_t audioeffects_echo_obj_get_delay_ms (mp_obj_t self_in ) {
95- audioeffects_echo_obj_t * self = MP_OBJ_TO_PTR (self_in );
94+ static mp_obj_t audiodelays_echo_obj_get_delay_ms (mp_obj_t self_in ) {
95+ audiodelays_echo_obj_t * self = MP_OBJ_TO_PTR (self_in );
9696
97- return mp_obj_new_float (common_hal_audioeffects_echo_get_delay_ms (self ));
97+ return mp_obj_new_float (common_hal_audiodelays_echo_get_delay_ms (self ));
9898
9999}
100- MP_DEFINE_CONST_FUN_OBJ_1 (audioeffects_echo_get_delay_ms_obj , audioeffects_echo_obj_get_delay_ms );
100+ MP_DEFINE_CONST_FUN_OBJ_1 (audiodelays_echo_get_delay_ms_obj , audiodelays_echo_obj_get_delay_ms );
101101
102- static mp_obj_t audioeffects_echo_obj_set_delay_ms (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
102+ static mp_obj_t audiodelays_echo_obj_set_delay_ms (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
103103 enum { ARG_delay_ms };
104104 static const mp_arg_t allowed_args [] = {
105105 { MP_QSTR_delay_ms , MP_ARG_INT | MP_ARG_REQUIRED , {} },
106106 };
107- audioeffects_echo_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
107+ audiodelays_echo_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
108108 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
109109 mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
110110
111111 mp_int_t delay_ms = mp_arg_validate_int_range (args [ARG_delay_ms ].u_int , 1 , 4000 , MP_QSTR_delay_ms );
112112
113- common_hal_audioeffects_echo_set_delay_ms (self , delay_ms );
113+ common_hal_audiodelays_echo_set_delay_ms (self , delay_ms );
114114
115115 return mp_const_none ;
116116}
117- MP_DEFINE_CONST_FUN_OBJ_KW (audioeffects_echo_set_delay_ms_obj , 1 , audioeffects_echo_obj_set_delay_ms );
117+ MP_DEFINE_CONST_FUN_OBJ_KW (audiodelays_echo_set_delay_ms_obj , 1 , audiodelays_echo_obj_set_delay_ms );
118118
119- MP_PROPERTY_GETSET (audioeffects_echo_delay_ms_obj ,
120- (mp_obj_t )& audioeffects_echo_get_delay_ms_obj ,
121- (mp_obj_t )& audioeffects_echo_set_delay_ms_obj );
119+ MP_PROPERTY_GETSET (audiodelays_echo_delay_ms_obj ,
120+ (mp_obj_t )& audiodelays_echo_get_delay_ms_obj ,
121+ (mp_obj_t )& audiodelays_echo_set_delay_ms_obj );
122122
123123
124124
125125//| decay: float
126126//| """The rate the echo decays between 0 and 1."""
127- static mp_obj_t audioeffects_echo_obj_get_decay (mp_obj_t self_in ) {
128- return mp_obj_new_float (common_hal_audioeffects_echo_get_decay (self_in ));
127+ static mp_obj_t audiodelays_echo_obj_get_decay (mp_obj_t self_in ) {
128+ return mp_obj_new_float (common_hal_audiodelays_echo_get_decay (self_in ));
129129}
130- MP_DEFINE_CONST_FUN_OBJ_1 (audioeffects_echo_get_decay_obj , audioeffects_echo_obj_get_decay );
130+ MP_DEFINE_CONST_FUN_OBJ_1 (audiodelays_echo_get_decay_obj , audiodelays_echo_obj_get_decay );
131131
132- static mp_obj_t audioeffects_echo_obj_set_decay (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
132+ static mp_obj_t audiodelays_echo_obj_set_decay (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
133133 enum { ARG_decay };
134134 static const mp_arg_t allowed_args [] = {
135135 { MP_QSTR_decay , MP_ARG_OBJ | MP_ARG_REQUIRED , {} },
136136 };
137- audioeffects_echo_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
137+ audiodelays_echo_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
138138 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
139139 mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
140140
@@ -144,28 +144,28 @@ static mp_obj_t audioeffects_echo_obj_set_decay(size_t n_args, const mp_obj_t *p
144144 mp_raise_ValueError (MP_ERROR_TEXT ("decay must be between 0 and 1" ));
145145 }
146146
147- common_hal_audioeffects_echo_set_decay (self , decay );
147+ common_hal_audiodelays_echo_set_decay (self , decay );
148148
149149 return mp_const_none ;
150150}
151- MP_DEFINE_CONST_FUN_OBJ_KW (audioeffects_echo_set_decay_obj , 1 , audioeffects_echo_obj_set_decay );
151+ MP_DEFINE_CONST_FUN_OBJ_KW (audiodelays_echo_set_decay_obj , 1 , audiodelays_echo_obj_set_decay );
152152
153- MP_PROPERTY_GETSET (audioeffects_echo_decay_obj ,
154- (mp_obj_t )& audioeffects_echo_get_decay_obj ,
155- (mp_obj_t )& audioeffects_echo_set_decay_obj );
153+ MP_PROPERTY_GETSET (audiodelays_echo_decay_obj ,
154+ (mp_obj_t )& audiodelays_echo_get_decay_obj ,
155+ (mp_obj_t )& audiodelays_echo_set_decay_obj );
156156
157157
158158//| playing: bool
159159//| """True when any voice is being output. (read-only)"""
160- static mp_obj_t audioeffects_echo_obj_get_playing (mp_obj_t self_in ) {
161- audioeffects_echo_obj_t * self = MP_OBJ_TO_PTR (self_in );
160+ static mp_obj_t audiodelays_echo_obj_get_playing (mp_obj_t self_in ) {
161+ audiodelays_echo_obj_t * self = MP_OBJ_TO_PTR (self_in );
162162 check_for_deinit (self );
163- return mp_obj_new_bool (common_hal_audioeffects_echo_get_playing (self ));
163+ return mp_obj_new_bool (common_hal_audiodelays_echo_get_playing (self ));
164164}
165- MP_DEFINE_CONST_FUN_OBJ_1 (audioeffects_echo_get_playing_obj , audioeffects_echo_obj_get_playing );
165+ MP_DEFINE_CONST_FUN_OBJ_1 (audiodelays_echo_get_playing_obj , audiodelays_echo_obj_get_playing );
166166
167- MP_PROPERTY_GETTER (audioeffects_echo_playing_obj ,
168- (mp_obj_t )& audioeffects_echo_get_playing_obj );
167+ MP_PROPERTY_GETTER (audiodelays_echo_playing_obj ,
168+ (mp_obj_t )& audiodelays_echo_get_playing_obj );
169169
170170//| def play(
171171//| self, sample: circuitpython_typing.AudioSample, *, voice: int = 0, loop: bool = False
@@ -177,69 +177,69 @@ MP_PROPERTY_GETTER(audioeffects_echo_playing_obj,
177177//|
178178//| The sample must match the Effect's encoding settings given in the constructor."""
179179//| ...
180- static mp_obj_t audioeffects_echo_obj_play (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
180+ static mp_obj_t audiodelays_echo_obj_play (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
181181 enum { ARG_sample , ARG_loop };
182182 static const mp_arg_t allowed_args [] = {
183183 { MP_QSTR_sample , MP_ARG_OBJ | MP_ARG_REQUIRED , {} },
184184 { MP_QSTR_loop , MP_ARG_BOOL | MP_ARG_KW_ONLY , {.u_bool = false} },
185185 };
186- audioeffects_echo_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
186+ audiodelays_echo_obj_t * self = MP_OBJ_TO_PTR (pos_args [0 ]);
187187 check_for_deinit (self );
188188 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
189189 mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
190190
191191
192192 mp_obj_t sample = args [ARG_sample ].u_obj ;
193- common_hal_audioeffects_echo_play (self , sample , args [ARG_loop ].u_bool );
193+ common_hal_audiodelays_echo_play (self , sample , args [ARG_loop ].u_bool );
194194
195195 return mp_const_none ;
196196}
197- MP_DEFINE_CONST_FUN_OBJ_KW (audioeffects_echo_play_obj , 1 , audioeffects_echo_obj_play );
197+ MP_DEFINE_CONST_FUN_OBJ_KW (audiodelays_echo_play_obj , 1 , audiodelays_echo_obj_play );
198198
199199//| def stop_voice(self, voice: int = 0) -> None:
200200//| """Stops playback of the sample."""
201201//| ...
202202//|
203- static mp_obj_t audioeffects_echo_obj_stop (mp_obj_t self_in ) {
204- audioeffects_echo_obj_t * self = MP_OBJ_TO_PTR (self_in );
203+ static mp_obj_t audiodelays_echo_obj_stop (mp_obj_t self_in ) {
204+ audiodelays_echo_obj_t * self = MP_OBJ_TO_PTR (self_in );
205205
206- common_hal_audioeffects_echo_stop (self );
206+ common_hal_audiodelays_echo_stop (self );
207207 return mp_const_none ;
208208}
209- MP_DEFINE_CONST_FUN_OBJ_1 (audioeffects_echo_stop_obj , audioeffects_echo_obj_stop );
209+ MP_DEFINE_CONST_FUN_OBJ_1 (audiodelays_echo_stop_obj , audiodelays_echo_obj_stop );
210210
211211
212212
213- static const mp_rom_map_elem_t audioeffects_echo_locals_dict_table [] = {
213+ static const mp_rom_map_elem_t audiodelays_echo_locals_dict_table [] = {
214214 // Methods
215- { MP_ROM_QSTR (MP_QSTR_deinit ), MP_ROM_PTR (& audioeffects_echo_deinit_obj ) },
215+ { MP_ROM_QSTR (MP_QSTR_deinit ), MP_ROM_PTR (& audiodelays_echo_deinit_obj ) },
216216 { MP_ROM_QSTR (MP_QSTR___enter__ ), MP_ROM_PTR (& default___enter___obj ) },
217- { MP_ROM_QSTR (MP_QSTR___exit__ ), MP_ROM_PTR (& audioeffects_echo___exit___obj ) },
218- { MP_ROM_QSTR (MP_QSTR_play ), MP_ROM_PTR (& audioeffects_echo_play_obj ) },
219- { MP_ROM_QSTR (MP_QSTR_stop ), MP_ROM_PTR (& audioeffects_echo_stop_obj ) },
217+ { MP_ROM_QSTR (MP_QSTR___exit__ ), MP_ROM_PTR (& audiodelays_echo___exit___obj ) },
218+ { MP_ROM_QSTR (MP_QSTR_play ), MP_ROM_PTR (& audiodelays_echo_play_obj ) },
219+ { MP_ROM_QSTR (MP_QSTR_stop ), MP_ROM_PTR (& audiodelays_echo_stop_obj ) },
220220
221221 // Properties
222- { MP_ROM_QSTR (MP_QSTR_playing ), MP_ROM_PTR (& audioeffects_echo_playing_obj ) },
223- { MP_ROM_QSTR (MP_QSTR_delay_ms ), MP_ROM_PTR (& audioeffects_echo_delay_ms_obj ) },
224- { MP_ROM_QSTR (MP_QSTR_decay ), MP_ROM_PTR (& audioeffects_echo_decay_obj ) },
222+ { MP_ROM_QSTR (MP_QSTR_playing ), MP_ROM_PTR (& audiodelays_echo_playing_obj ) },
223+ { MP_ROM_QSTR (MP_QSTR_delay_ms ), MP_ROM_PTR (& audiodelays_echo_delay_ms_obj ) },
224+ { MP_ROM_QSTR (MP_QSTR_decay ), MP_ROM_PTR (& audiodelays_echo_decay_obj ) },
225225};
226- static MP_DEFINE_CONST_DICT (audioeffects_echo_locals_dict , audioeffects_echo_locals_dict_table ) ;
226+ static MP_DEFINE_CONST_DICT (audiodelays_echo_locals_dict , audiodelays_echo_locals_dict_table ) ;
227227
228- static const audiosample_p_t audioeffects_echo_proto = {
228+ static const audiosample_p_t audiodelays_echo_proto = {
229229 MP_PROTO_IMPLEMENT (MP_QSTR_protocol_audiosample )
230- .sample_rate = (audiosample_sample_rate_fun )common_hal_audioeffects_echo_get_sample_rate ,
231- .bits_per_sample = (audiosample_bits_per_sample_fun )common_hal_audioeffects_echo_get_bits_per_sample ,
232- .channel_count = (audiosample_channel_count_fun )common_hal_audioeffects_echo_get_channel_count ,
233- .reset_buffer = (audiosample_reset_buffer_fun )audioeffects_echo_reset_buffer ,
234- .get_buffer = (audiosample_get_buffer_fun )audioeffects_echo_get_buffer ,
235- .get_buffer_structure = (audiosample_get_buffer_structure_fun )audioeffects_echo_get_buffer_structure ,
230+ .sample_rate = (audiosample_sample_rate_fun )common_hal_audiodelays_echo_get_sample_rate ,
231+ .bits_per_sample = (audiosample_bits_per_sample_fun )common_hal_audiodelays_echo_get_bits_per_sample ,
232+ .channel_count = (audiosample_channel_count_fun )common_hal_audiodelays_echo_get_channel_count ,
233+ .reset_buffer = (audiosample_reset_buffer_fun )audiodelays_echo_reset_buffer ,
234+ .get_buffer = (audiosample_get_buffer_fun )audiodelays_echo_get_buffer ,
235+ .get_buffer_structure = (audiosample_get_buffer_structure_fun )audiodelays_echo_get_buffer_structure ,
236236};
237237
238238MP_DEFINE_CONST_OBJ_TYPE (
239- audioeffects_echo_type ,
239+ audiodelays_echo_type ,
240240 MP_QSTR_Echo ,
241241 MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS ,
242- make_new , audioeffects_echo_make_new ,
243- locals_dict , & audioeffects_echo_locals_dict ,
244- protocol , & audioeffects_echo_proto
242+ make_new , audiodelays_echo_make_new ,
243+ locals_dict , & audiodelays_echo_locals_dict ,
244+ protocol , & audiodelays_echo_proto
245245 );
0 commit comments