@@ -40,13 +40,15 @@ static const mp_arg_t note_properties[] = {
40
40
{ MP_QSTR_amplitude , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (1 ) } },
41
41
{ MP_QSTR_bend , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (0 ) } },
42
42
{ 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 ) } },
43
45
{ MP_QSTR_envelope , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_NONE } },
44
46
{ MP_QSTR_filter , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_NONE } },
45
47
{ MP_QSTR_ring_frequency , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
46
48
{ MP_QSTR_ring_bend , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
47
49
{ 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 ) } },
50
52
};
51
53
//| class Note:
52
54
//| def __init__(
@@ -55,15 +57,17 @@ static const mp_arg_t note_properties[] = {
55
57
//| frequency: float,
56
58
//| panning: BlockInput = 0.0,
57
59
//| waveform: Optional[ReadableBuffer] = None,
60
+ //| waveform_loop_start: int = 0,
61
+ //| waveform_loop_end: int = 0,
58
62
//| envelope: Optional[Envelope] = None,
59
63
//| amplitude: BlockInput = 0.0,
60
64
//| bend: BlockInput = 0.0,
61
65
//| filter: Optional[Biquad] = None,
62
66
//| ring_frequency: float = 0.0,
63
67
//| ring_bend: float = 0.0,
64
68
//| 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,
67
71
//| ) -> None:
68
72
//| """Construct a Note object, with a frequency in Hz, and optional panning, waveform, envelope, tremolo (volume change) and bend (frequency change).
69
73
//|
@@ -214,6 +218,43 @@ MP_PROPERTY_GETSET(synthio_note_waveform_obj,
214
218
(mp_obj_t )& synthio_note_get_waveform_obj ,
215
219
(mp_obj_t )& synthio_note_set_waveform_obj );
216
220
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
+
217
258
218
259
//| envelope: Envelope
219
260
//| """The envelope of this note"""
@@ -300,42 +341,42 @@ MP_PROPERTY_GETSET(synthio_note_ring_waveform_obj,
300
341
(mp_obj_t )& synthio_note_get_ring_waveform_obj ,
301
342
(mp_obj_t )& synthio_note_set_ring_waveform_obj );
302
343
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 ) {
306
347
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 ));
308
349
}
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 );
310
351
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 ) {
312
353
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 ));
314
355
return mp_const_none ;
315
356
}
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 );
320
361
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 ."""
323
364
//|
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 ) {
325
366
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 ));
327
368
}
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 );
329
370
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 ) {
331
372
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 ));
333
374
return mp_const_none ;
334
375
}
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 );
339
380
340
381
341
382
@@ -349,14 +390,16 @@ STATIC const mp_rom_map_elem_t synthio_note_locals_dict_table[] = {
349
390
{ MP_ROM_QSTR (MP_QSTR_filter ), MP_ROM_PTR (& synthio_note_filter_obj ) },
350
391
{ MP_ROM_QSTR (MP_QSTR_panning ), MP_ROM_PTR (& synthio_note_panning_obj ) },
351
392
{ 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 ) },
352
395
{ MP_ROM_QSTR (MP_QSTR_envelope ), MP_ROM_PTR (& synthio_note_envelope_obj ) },
353
396
{ MP_ROM_QSTR (MP_QSTR_amplitude ), MP_ROM_PTR (& synthio_note_amplitude_obj ) },
354
397
{ MP_ROM_QSTR (MP_QSTR_bend ), MP_ROM_PTR (& synthio_note_bend_obj ) },
355
398
{ MP_ROM_QSTR (MP_QSTR_ring_frequency ), MP_ROM_PTR (& synthio_note_ring_frequency_obj ) },
356
399
{ MP_ROM_QSTR (MP_QSTR_ring_bend ), MP_ROM_PTR (& synthio_note_ring_bend_obj ) },
357
400
{ 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 ) },
360
403
};
361
404
STATIC MP_DEFINE_CONST_DICT (synthio_note_locals_dict , synthio_note_locals_dict_table );
362
405
0 commit comments