6
6
7
7
#include <stdint.h>
8
8
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"
11
11
12
12
#include "shared/runtime/context_manager_helpers.h"
13
13
#include "py/binary.h"
20
20
//| class Echo:
21
21
//| """An Echo effect"""
22
22
//|
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 ) {
24
24
enum { ARG_delay_ms , ARG_decay , ARG_buffer_size , ARG_sample_rate , ARG_bits_per_sample , ARG_samples_signed , ARG_channel_count , };
25
25
static const mp_arg_t allowed_args [] = {
26
26
{ 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
49
49
mp_raise_ValueError (MP_ERROR_TEXT ("bits_per_sample must be 8 or 16" ));
50
50
}
51
51
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 );
54
54
55
55
return MP_OBJ_FROM_PTR (self );
56
56
}
57
57
58
58
//| def deinit(self) -> None:
59
59
//| """Deinitialises the Echo and releases any hardware resources for reuse."""
60
60
//| ...
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 );
64
64
return mp_const_none ;
65
65
}
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 ) ;
67
67
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 )) {
70
70
raise_deinited_error ();
71
71
}
72
72
}
@@ -80,61 +80,61 @@ static void check_for_deinit(audioeffects_echo_obj_t *self) {
80
80
//| """Automatically deinitializes the hardware when exiting a context. See
81
81
//| :ref:`lifetime-and-contextmanagers` for more info."""
82
82
//| ...
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 ) {
84
84
(void )n_args ;
85
- common_hal_audioeffects_echo_deinit (args [0 ]);
85
+ common_hal_audiodelays_echo_deinit (args [0 ]);
86
86
return mp_const_none ;
87
87
}
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__ ) ;
89
89
90
90
91
91
//| delay_ms: int
92
92
//| """Delay of the echo in microseconds. (read-only)"""
93
93
//|
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 );
96
96
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 ));
98
98
99
99
}
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 );
101
101
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 ) {
103
103
enum { ARG_delay_ms };
104
104
static const mp_arg_t allowed_args [] = {
105
105
{ MP_QSTR_delay_ms , MP_ARG_INT | MP_ARG_REQUIRED , {} },
106
106
};
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 ]);
108
108
mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
109
109
mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
110
110
111
111
mp_int_t delay_ms = mp_arg_validate_int_range (args [ARG_delay_ms ].u_int , 1 , 4000 , MP_QSTR_delay_ms );
112
112
113
- common_hal_audioeffects_echo_set_delay_ms (self , delay_ms );
113
+ common_hal_audiodelays_echo_set_delay_ms (self , delay_ms );
114
114
115
115
return mp_const_none ;
116
116
}
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 );
118
118
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 );
122
122
123
123
124
124
125
125
//| decay: float
126
126
//| """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 ));
129
129
}
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 );
131
131
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 ) {
133
133
enum { ARG_decay };
134
134
static const mp_arg_t allowed_args [] = {
135
135
{ MP_QSTR_decay , MP_ARG_OBJ | MP_ARG_REQUIRED , {} },
136
136
};
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 ]);
138
138
mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
139
139
mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
140
140
@@ -144,28 +144,28 @@ static mp_obj_t audioeffects_echo_obj_set_decay(size_t n_args, const mp_obj_t *p
144
144
mp_raise_ValueError (MP_ERROR_TEXT ("decay must be between 0 and 1" ));
145
145
}
146
146
147
- common_hal_audioeffects_echo_set_decay (self , decay );
147
+ common_hal_audiodelays_echo_set_decay (self , decay );
148
148
149
149
return mp_const_none ;
150
150
}
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 );
152
152
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 );
156
156
157
157
158
158
//| playing: bool
159
159
//| """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 );
162
162
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 ));
164
164
}
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 );
166
166
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 );
169
169
170
170
//| def play(
171
171
//| self, sample: circuitpython_typing.AudioSample, *, voice: int = 0, loop: bool = False
@@ -177,69 +177,69 @@ MP_PROPERTY_GETTER(audioeffects_echo_playing_obj,
177
177
//|
178
178
//| The sample must match the Effect's encoding settings given in the constructor."""
179
179
//| ...
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 ) {
181
181
enum { ARG_sample , ARG_loop };
182
182
static const mp_arg_t allowed_args [] = {
183
183
{ MP_QSTR_sample , MP_ARG_OBJ | MP_ARG_REQUIRED , {} },
184
184
{ MP_QSTR_loop , MP_ARG_BOOL | MP_ARG_KW_ONLY , {.u_bool = false} },
185
185
};
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 ]);
187
187
check_for_deinit (self );
188
188
mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
189
189
mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
190
190
191
191
192
192
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 );
194
194
195
195
return mp_const_none ;
196
196
}
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 );
198
198
199
199
//| def stop_voice(self, voice: int = 0) -> None:
200
200
//| """Stops playback of the sample."""
201
201
//| ...
202
202
//|
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 );
205
205
206
- common_hal_audioeffects_echo_stop (self );
206
+ common_hal_audiodelays_echo_stop (self );
207
207
return mp_const_none ;
208
208
}
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 );
210
210
211
211
212
212
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 [] = {
214
214
// 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 ) },
216
216
{ 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 ) },
220
220
221
221
// 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 ) },
225
225
};
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 ) ;
227
227
228
- static const audiosample_p_t audioeffects_echo_proto = {
228
+ static const audiosample_p_t audiodelays_echo_proto = {
229
229
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 ,
236
236
};
237
237
238
238
MP_DEFINE_CONST_OBJ_TYPE (
239
- audioeffects_echo_type ,
239
+ audiodelays_echo_type ,
240
240
MP_QSTR_Echo ,
241
241
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
245
245
);
0 commit comments