@@ -45,6 +45,8 @@ static const mp_arg_t note_properties[] = {
45
45
{ MP_QSTR_ring_frequency , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
46
46
{ MP_QSTR_ring_bend , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
47
47
{ 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 ) } },
48
50
};
49
51
//| class Note:
50
52
//| def __init__(
@@ -60,6 +62,8 @@ static const mp_arg_t note_properties[] = {
60
62
//| ring_frequency: float = 0.0,
61
63
//| ring_bend: float = 0.0,
62
64
//| ring_waveform: Optional[ReadableBuffer] = 0.0,
65
+ //| loop_start: int = 0,
66
+ //| loop_end: int = 0,
63
67
//| ) -> None:
64
68
//| """Construct a Note object, with a frequency in Hz, and optional panning, waveform, envelope, tremolo (volume change) and bend (frequency change).
65
69
//|
@@ -296,6 +300,43 @@ MP_PROPERTY_GETSET(synthio_note_ring_waveform_obj,
296
300
(mp_obj_t )& synthio_note_get_ring_waveform_obj ,
297
301
(mp_obj_t )& synthio_note_set_ring_waveform_obj );
298
302
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
+
299
340
300
341
301
342
static 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[] = {
314
355
{ MP_ROM_QSTR (MP_QSTR_ring_frequency ), MP_ROM_PTR (& synthio_note_ring_frequency_obj ) },
315
356
{ MP_ROM_QSTR (MP_QSTR_ring_bend ), MP_ROM_PTR (& synthio_note_ring_bend_obj ) },
316
357
{ 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 ) },
317
360
};
318
361
STATIC MP_DEFINE_CONST_DICT (synthio_note_locals_dict , synthio_note_locals_dict_table );
319
362
0 commit comments