@@ -40,13 +40,15 @@ static const mp_arg_t note_properties[] = {
4040 { MP_QSTR_amplitude , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (1 ) } },
4141 { MP_QSTR_bend , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (0 ) } },
4242 { MP_QSTR_waveform , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_NONE } },
43+ { MP_QSTR_waveform_loop_start , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
44+ { MP_QSTR_waveform_loop_end , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (SYNTHIO_WAVEFORM_SIZE ) } },
4345 { MP_QSTR_envelope , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_NONE } },
4446 { MP_QSTR_filter , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_NONE } },
4547 { MP_QSTR_ring_frequency , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
4648 { MP_QSTR_ring_bend , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
4749 { MP_QSTR_ring_waveform , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_NONE } },
48- { MP_QSTR_loop_start , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
49- { MP_QSTR_loop_end , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
50+ { MP_QSTR_ring_waveform_loop_start , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
51+ { MP_QSTR_ring_waveform_loop_end , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (SYNTHIO_WAVEFORM_SIZE ) } },
5052};
5153//| class Note:
5254//| def __init__(
@@ -55,15 +57,17 @@ static const mp_arg_t note_properties[] = {
5557//| frequency: float,
5658//| panning: BlockInput = 0.0,
5759//| waveform: Optional[ReadableBuffer] = None,
60+ //| waveform_loop_start: int = 0,
61+ //| waveform_loop_end: int = 0,
5862//| envelope: Optional[Envelope] = None,
5963//| amplitude: BlockInput = 0.0,
6064//| bend: BlockInput = 0.0,
6165//| filter: Optional[Biquad] = None,
6266//| ring_frequency: float = 0.0,
6367//| ring_bend: float = 0.0,
6468//| ring_waveform: Optional[ReadableBuffer] = 0.0,
65- //| loop_start : int = 0,
66- //| loop_end : int = 0,
69+ //| ring_waveform_loop_start : int = 0,
70+ //| ring_waveform_loop_end : int = 0,
6771//| ) -> None:
6872//| """Construct a Note object, with a frequency in Hz, and optional panning, waveform, envelope, tremolo (volume change) and bend (frequency change).
6973//|
@@ -214,6 +218,43 @@ MP_PROPERTY_GETSET(synthio_note_waveform_obj,
214218 (mp_obj_t )& synthio_note_get_waveform_obj ,
215219 (mp_obj_t )& synthio_note_set_waveform_obj );
216220
221+ //| waveform_loop_start: int
222+ //| """The index of where to begin looping waveform data. Must be greater than or equal to 0 and less than the total size of the waveform data."""
223+ STATIC mp_obj_t synthio_note_get_waveform_loop_start (mp_obj_t self_in ) {
224+ synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
225+ return mp_obj_new_int (common_hal_synthio_note_get_waveform_loop_start (self ));
226+ }
227+ MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_waveform_loop_start_obj , synthio_note_get_waveform_loop_start );
228+
229+ STATIC mp_obj_t synthio_note_set_waveform_loop_start (mp_obj_t self_in , mp_obj_t arg ) {
230+ synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
231+ common_hal_synthio_note_set_waveform_loop_start (self , mp_obj_get_int (arg ));
232+ return mp_const_none ;
233+ }
234+ MP_DEFINE_CONST_FUN_OBJ_2 (synthio_note_set_waveform_loop_start_obj , synthio_note_set_waveform_loop_start );
235+ MP_PROPERTY_GETSET (synthio_note_waveform_loop_start_obj ,
236+ (mp_obj_t )& synthio_note_get_waveform_loop_start_obj ,
237+ (mp_obj_t )& synthio_note_set_waveform_loop_start_obj );
238+
239+ //| waveform_loop_end: int
240+ //| """The index of where to end looping waveform data. Must be greater than 0 or ``waveform_loop_start`` and less than or equal to the total size of the waveform data. If the value of the index does not match these parameters, the loop will occur at the end of the waveform."""
241+ //|
242+ STATIC mp_obj_t synthio_note_get_waveform_loop_end (mp_obj_t self_in ) {
243+ synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
244+ return mp_obj_new_int (common_hal_synthio_note_get_waveform_loop_end (self ));
245+ }
246+ MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_waveform_loop_end_obj , synthio_note_get_waveform_loop_end );
247+
248+ STATIC mp_obj_t synthio_note_set_waveform_loop_end (mp_obj_t self_in , mp_obj_t arg ) {
249+ synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
250+ common_hal_synthio_note_set_waveform_loop_end (self , mp_obj_get_int (arg ));
251+ return mp_const_none ;
252+ }
253+ MP_DEFINE_CONST_FUN_OBJ_2 (synthio_note_set_waveform_loop_end_obj , synthio_note_set_waveform_loop_end );
254+ MP_PROPERTY_GETSET (synthio_note_waveform_loop_end_obj ,
255+ (mp_obj_t )& synthio_note_get_waveform_loop_end_obj ,
256+ (mp_obj_t )& synthio_note_set_waveform_loop_end_obj );
257+
217258
218259//| envelope: Envelope
219260//| """The envelope of this note"""
@@ -300,42 +341,42 @@ MP_PROPERTY_GETSET(synthio_note_ring_waveform_obj,
300341 (mp_obj_t )& synthio_note_get_ring_waveform_obj ,
301342 (mp_obj_t )& synthio_note_set_ring_waveform_obj );
302343
303- //| loop_start : int
304- //| """The index of where to begin looping waveform data. Must be greater than 0 and less than the total size of the waveform data."""
305- STATIC mp_obj_t synthio_note_get_loop_start (mp_obj_t self_in ) {
344+ //| ring_waveform_loop_start : int
345+ //| """The index of where to begin looping waveform data. Must be greater than or equal to 0 and less than the total size of the waveform data."""
346+ STATIC mp_obj_t synthio_note_get_ring_waveform_loop_start (mp_obj_t self_in ) {
306347 synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
307- return mp_obj_new_int (common_hal_synthio_note_get_loop_start (self ));
348+ return mp_obj_new_int (common_hal_synthio_note_get_ring_waveform_loop_start (self ));
308349}
309- MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_loop_start_obj , synthio_note_get_loop_start );
350+ MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_ring_waveform_loop_start_obj , synthio_note_get_ring_waveform_loop_start );
310351
311- STATIC mp_obj_t synthio_note_set_loop_start (mp_obj_t self_in , mp_obj_t arg ) {
352+ STATIC mp_obj_t synthio_note_set_ring_waveform_loop_start (mp_obj_t self_in , mp_obj_t arg ) {
312353 synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
313- common_hal_synthio_note_set_loop_start (self , mp_obj_get_int (arg ));
354+ common_hal_synthio_note_set_ring_waveform_loop_start (self , mp_obj_get_int (arg ));
314355 return mp_const_none ;
315356}
316- MP_DEFINE_CONST_FUN_OBJ_2 (synthio_note_set_loop_start_obj , synthio_note_set_loop_start );
317- MP_PROPERTY_GETSET (synthio_note_loop_start_obj ,
318- (mp_obj_t )& synthio_note_get_loop_start_obj ,
319- (mp_obj_t )& synthio_note_set_loop_start_obj );
357+ MP_DEFINE_CONST_FUN_OBJ_2 (synthio_note_set_ring_waveform_loop_start_obj , synthio_note_set_ring_waveform_loop_start );
358+ MP_PROPERTY_GETSET (synthio_note_ring_waveform_loop_start_obj ,
359+ (mp_obj_t )& synthio_note_get_ring_waveform_loop_start_obj ,
360+ (mp_obj_t )& synthio_note_set_ring_waveform_loop_start_obj );
320361
321- //| loop_end : int
322- //| """The index of where to end looping waveform data. Must be greater than 0 or ``loop_start `` and less than the total size of the waveform data."""
362+ //| ring_waveform_loop_end : int
363+ //| """The index of where to end looping waveform data. Must be greater than 0 or ``waveform_loop_start `` and less than or equal to the total size of the waveform data. If the value of the index does not match these parameters, the loop will occur at the end of the waveform ."""
323364//|
324- STATIC mp_obj_t synthio_note_get_loop_end (mp_obj_t self_in ) {
365+ STATIC mp_obj_t synthio_note_get_ring_waveform_loop_end (mp_obj_t self_in ) {
325366 synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
326- return mp_obj_new_int (common_hal_synthio_note_get_loop_end (self ));
367+ return mp_obj_new_int (common_hal_synthio_note_get_ring_waveform_loop_end (self ));
327368}
328- MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_loop_end_obj , synthio_note_get_loop_end );
369+ MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_ring_waveform_loop_end_obj , synthio_note_get_ring_waveform_loop_end );
329370
330- STATIC mp_obj_t synthio_note_set_loop_end (mp_obj_t self_in , mp_obj_t arg ) {
371+ STATIC mp_obj_t synthio_note_set_ring_waveform_loop_end (mp_obj_t self_in , mp_obj_t arg ) {
331372 synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
332- common_hal_synthio_note_set_loop_end (self , mp_obj_get_int (arg ));
373+ common_hal_synthio_note_set_ring_waveform_loop_end (self , mp_obj_get_int (arg ));
333374 return mp_const_none ;
334375}
335- MP_DEFINE_CONST_FUN_OBJ_2 (synthio_note_set_loop_end_obj , synthio_note_set_loop_end );
336- MP_PROPERTY_GETSET (synthio_note_loop_end_obj ,
337- (mp_obj_t )& synthio_note_get_loop_end_obj ,
338- (mp_obj_t )& synthio_note_set_loop_end_obj );
376+ MP_DEFINE_CONST_FUN_OBJ_2 (synthio_note_set_ring_waveform_loop_end_obj , synthio_note_set_ring_waveform_loop_end );
377+ MP_PROPERTY_GETSET (synthio_note_ring_waveform_loop_end_obj ,
378+ (mp_obj_t )& synthio_note_get_ring_waveform_loop_end_obj ,
379+ (mp_obj_t )& synthio_note_set_ring_waveform_loop_end_obj );
339380
340381
341382
@@ -349,14 +390,16 @@ STATIC const mp_rom_map_elem_t synthio_note_locals_dict_table[] = {
349390 { MP_ROM_QSTR (MP_QSTR_filter ), MP_ROM_PTR (& synthio_note_filter_obj ) },
350391 { MP_ROM_QSTR (MP_QSTR_panning ), MP_ROM_PTR (& synthio_note_panning_obj ) },
351392 { MP_ROM_QSTR (MP_QSTR_waveform ), MP_ROM_PTR (& synthio_note_waveform_obj ) },
393+ { MP_ROM_QSTR (MP_QSTR_waveform_loop_start ), MP_ROM_PTR (& synthio_note_waveform_loop_start_obj ) },
394+ { MP_ROM_QSTR (MP_QSTR_waveform_loop_end ), MP_ROM_PTR (& synthio_note_waveform_loop_end_obj ) },
352395 { MP_ROM_QSTR (MP_QSTR_envelope ), MP_ROM_PTR (& synthio_note_envelope_obj ) },
353396 { MP_ROM_QSTR (MP_QSTR_amplitude ), MP_ROM_PTR (& synthio_note_amplitude_obj ) },
354397 { MP_ROM_QSTR (MP_QSTR_bend ), MP_ROM_PTR (& synthio_note_bend_obj ) },
355398 { MP_ROM_QSTR (MP_QSTR_ring_frequency ), MP_ROM_PTR (& synthio_note_ring_frequency_obj ) },
356399 { MP_ROM_QSTR (MP_QSTR_ring_bend ), MP_ROM_PTR (& synthio_note_ring_bend_obj ) },
357400 { MP_ROM_QSTR (MP_QSTR_ring_waveform ), MP_ROM_PTR (& synthio_note_ring_waveform_obj ) },
358- { MP_ROM_QSTR (MP_QSTR_loop_start ), MP_ROM_PTR (& synthio_note_loop_start_obj ) },
359- { MP_ROM_QSTR (MP_QSTR_loop_end ), MP_ROM_PTR (& synthio_note_loop_end_obj ) },
401+ { MP_ROM_QSTR (MP_QSTR_ring_waveform_loop_start ), MP_ROM_PTR (& synthio_note_ring_waveform_loop_start_obj ) },
402+ { MP_ROM_QSTR (MP_QSTR_ring_waveform_loop_end ), MP_ROM_PTR (& synthio_note_ring_waveform_loop_end_obj ) },
360403};
361404STATIC MP_DEFINE_CONST_DICT (synthio_note_locals_dict , synthio_note_locals_dict_table );
362405
0 commit comments