@@ -45,6 +45,8 @@ static const mp_arg_t note_properties[] = {
4545 { MP_QSTR_ring_frequency , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
4646 { MP_QSTR_ring_bend , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
4747 { 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 ) } },
4850};
4951//| class Note:
5052//| def __init__(
@@ -60,6 +62,8 @@ static const mp_arg_t note_properties[] = {
6062//| ring_frequency: float = 0.0,
6163//| ring_bend: float = 0.0,
6264//| ring_waveform: Optional[ReadableBuffer] = 0.0,
65+ //| loop_start: int = 0,
66+ //| loop_end: int = 0,
6367//| ) -> None:
6468//| """Construct a Note object, with a frequency in Hz, and optional panning, waveform, envelope, tremolo (volume change) and bend (frequency change).
6569//|
@@ -296,6 +300,43 @@ MP_PROPERTY_GETSET(synthio_note_ring_waveform_obj,
296300 (mp_obj_t )& synthio_note_get_ring_waveform_obj ,
297301 (mp_obj_t )& synthio_note_set_ring_waveform_obj );
298302
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 ) {
306+ 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 ));
308+ }
309+ MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_loop_start_obj , synthio_note_get_loop_start );
310+
311+ STATIC mp_obj_t synthio_note_set_loop_start (mp_obj_t self_in , mp_obj_t arg ) {
312+ 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 ));
314+ return mp_const_none ;
315+ }
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 );
320+
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."""
323+ //|
324+ STATIC mp_obj_t synthio_note_get_loop_end (mp_obj_t self_in ) {
325+ 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 ));
327+ }
328+ MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_loop_end_obj , synthio_note_get_loop_end );
329+
330+ STATIC mp_obj_t synthio_note_set_loop_end (mp_obj_t self_in , mp_obj_t arg ) {
331+ 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 ));
333+ return mp_const_none ;
334+ }
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 );
339+
299340
300341
301342static void note_print (const mp_print_t * print , mp_obj_t self_in , mp_print_kind_t kind ) {
@@ -314,6 +355,8 @@ STATIC const mp_rom_map_elem_t synthio_note_locals_dict_table[] = {
314355 { MP_ROM_QSTR (MP_QSTR_ring_frequency ), MP_ROM_PTR (& synthio_note_ring_frequency_obj ) },
315356 { MP_ROM_QSTR (MP_QSTR_ring_bend ), MP_ROM_PTR (& synthio_note_ring_bend_obj ) },
316357 { 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 ) },
317360};
318361STATIC MP_DEFINE_CONST_DICT (synthio_note_locals_dict , synthio_note_locals_dict_table );
319362
0 commit comments