@@ -20,15 +20,15 @@ static const mp_arg_t note_properties[] = {
20
20
{ MP_QSTR_amplitude , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (1 ) } },
21
21
{ MP_QSTR_bend , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (0 ) } },
22
22
{ MP_QSTR_waveform , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_NONE } },
23
- { MP_QSTR_waveform_loop_start , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
24
- { MP_QSTR_waveform_loop_end , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (SYNTHIO_WAVEFORM_SIZE ) } },
23
+ { MP_QSTR_waveform_loop_start , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (0 ) } },
24
+ { MP_QSTR_waveform_loop_end , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (SYNTHIO_WAVEFORM_SIZE ) } },
25
25
{ MP_QSTR_envelope , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_NONE } },
26
26
{ MP_QSTR_filter , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_NONE } },
27
- { MP_QSTR_ring_frequency , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
28
- { MP_QSTR_ring_bend , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
27
+ { MP_QSTR_ring_frequency , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (0 ) } },
28
+ { MP_QSTR_ring_bend , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (0 ) } },
29
29
{ MP_QSTR_ring_waveform , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_NONE } },
30
- { MP_QSTR_ring_waveform_loop_start , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (0 ) } },
31
- { MP_QSTR_ring_waveform_loop_end , MP_ARG_OBJ , {.u_obj = MP_ROM_INT (SYNTHIO_WAVEFORM_SIZE ) } },
30
+ { MP_QSTR_ring_waveform_loop_start , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (0 ) } },
31
+ { MP_QSTR_ring_waveform_loop_end , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = MP_ROM_INT (SYNTHIO_WAVEFORM_SIZE ) } },
32
32
};
33
33
//| class Note:
34
34
//| def __init__(
@@ -37,17 +37,17 @@ static const mp_arg_t note_properties[] = {
37
37
//| frequency: float,
38
38
//| panning: BlockInput = 0.0,
39
39
//| waveform: Optional[ReadableBuffer] = None,
40
- //| waveform_loop_start: int = 0,
41
- //| waveform_loop_end: int = waveform_max_length,
40
+ //| waveform_loop_start: BlockInput = 0,
41
+ //| waveform_loop_end: BlockInput = waveform_max_length,
42
42
//| envelope: Optional[Envelope] = None,
43
- //| amplitude: BlockInput = 0 .0,
43
+ //| amplitude: BlockInput = 1 .0,
44
44
//| bend: BlockInput = 0.0,
45
45
//| filter: Optional[Biquad] = None,
46
46
//| ring_frequency: float = 0.0,
47
47
//| ring_bend: float = 0.0,
48
48
//| ring_waveform: Optional[ReadableBuffer] = None,
49
- //| ring_waveform_loop_start: int = 0,
50
- //| ring_waveform_loop_end: int = waveform_max_length,
49
+ //| ring_waveform_loop_start: BlockInput = 0,
50
+ //| ring_waveform_loop_end: BlockInput = waveform_max_length,
51
51
//| ) -> None:
52
52
//| """Construct a Note object, with a frequency in Hz, and optional panning, waveform, envelope, tremolo (volume change) and bend (frequency change).
53
53
//|
@@ -198,46 +198,44 @@ MP_PROPERTY_GETSET(synthio_note_waveform_obj,
198
198
(mp_obj_t )& synthio_note_get_waveform_obj ,
199
199
(mp_obj_t )& synthio_note_set_waveform_obj );
200
200
201
- //| waveform_loop_start: int
201
+
202
+
203
+ //| waveform_loop_start: BlockInput
202
204
//| """The sample index of where to begin looping waveform data.
203
205
//|
204
- //| Values outside the range ``0`` to ``waveform_max_length-1`` (inclusive) are rejected with a `ValueError`.
205
- //|
206
- //| Values greater than or equal to the actual waveform length are treated as 0."""
206
+ //| The value is limited to the range ``0`` to ``len(waveform)-1`` (inclusive)."""
207
207
static mp_obj_t synthio_note_get_waveform_loop_start (mp_obj_t self_in ) {
208
208
synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
209
- return mp_obj_new_int ( common_hal_synthio_note_get_waveform_loop_start (self ) );
209
+ return common_hal_synthio_note_get_waveform_loop_start (self );
210
210
}
211
211
MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_waveform_loop_start_obj , synthio_note_get_waveform_loop_start );
212
212
213
213
static mp_obj_t synthio_note_set_waveform_loop_start (mp_obj_t self_in , mp_obj_t arg ) {
214
214
synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
215
- common_hal_synthio_note_set_waveform_loop_start (self , mp_obj_get_int ( arg ) );
215
+ common_hal_synthio_note_set_waveform_loop_start (self , arg );
216
216
return mp_const_none ;
217
217
}
218
218
MP_DEFINE_CONST_FUN_OBJ_2 (synthio_note_set_waveform_loop_start_obj , synthio_note_set_waveform_loop_start );
219
219
MP_PROPERTY_GETSET (synthio_note_waveform_loop_start_obj ,
220
220
(mp_obj_t )& synthio_note_get_waveform_loop_start_obj ,
221
221
(mp_obj_t )& synthio_note_set_waveform_loop_start_obj );
222
222
223
- //| waveform_loop_end: int
223
+ //| waveform_loop_end: BlockInput
224
224
//| """The sample index of where to end looping waveform data.
225
225
//|
226
- //| Values outside the range ``1`` to ``waveform_max_length`` (inclusive) are rejected with a `ValueError`.
227
- //|
228
- //| If the value is greater than the actual waveform length, or less than or equal to the loop start, the loop will occur at the end of the waveform.
226
+ //| The value is limited to the range ``waveform_loop_start+1`` to ``len(waveform)`` (inclusive).
229
227
//|
230
228
//| Use the `synthio.waveform_max_length` constant to set the loop point at the end of the wave form, no matter its length."""
231
229
//|
232
230
static mp_obj_t synthio_note_get_waveform_loop_end (mp_obj_t self_in ) {
233
231
synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
234
- return mp_obj_new_int ( common_hal_synthio_note_get_waveform_loop_end (self ) );
232
+ return common_hal_synthio_note_get_waveform_loop_end (self );
235
233
}
236
234
MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_waveform_loop_end_obj , synthio_note_get_waveform_loop_end );
237
235
238
236
static mp_obj_t synthio_note_set_waveform_loop_end (mp_obj_t self_in , mp_obj_t arg ) {
239
237
synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
240
- common_hal_synthio_note_set_waveform_loop_end (self , mp_obj_get_int ( arg ) );
238
+ common_hal_synthio_note_set_waveform_loop_end (self , arg );
241
239
return mp_const_none ;
242
240
}
243
241
MP_DEFINE_CONST_FUN_OBJ_2 (synthio_note_set_waveform_loop_end_obj , synthio_note_set_waveform_loop_end );
@@ -331,46 +329,42 @@ MP_PROPERTY_GETSET(synthio_note_ring_waveform_obj,
331
329
(mp_obj_t )& synthio_note_get_ring_waveform_obj ,
332
330
(mp_obj_t )& synthio_note_set_ring_waveform_obj );
333
331
334
- //| ring_waveform_loop_start: int
332
+ //| ring_waveform_loop_start: BlockInput
335
333
//| """The sample index of where to begin looping waveform data.
336
334
//|
337
- //| Values outside the range ``0`` to ``waveform_max_length-1`` (inclusive) are rejected with a `ValueError`.
338
- //|
339
- //| Values greater than or equal to the actual waveform length are treated as 0."""
335
+ //| The value is limited to the range ``0`` to ``len(ring_waveform)-1`` (inclusive)."""
340
336
static mp_obj_t synthio_note_get_ring_waveform_loop_start (mp_obj_t self_in ) {
341
337
synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
342
- return mp_obj_new_int ( common_hal_synthio_note_get_ring_waveform_loop_start (self ) );
338
+ return common_hal_synthio_note_get_ring_waveform_loop_start (self );
343
339
}
344
340
MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_ring_waveform_loop_start_obj , synthio_note_get_ring_waveform_loop_start );
345
341
346
342
static mp_obj_t synthio_note_set_ring_waveform_loop_start (mp_obj_t self_in , mp_obj_t arg ) {
347
343
synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
348
- common_hal_synthio_note_set_ring_waveform_loop_start (self , mp_obj_get_int ( arg ) );
344
+ common_hal_synthio_note_set_ring_waveform_loop_start (self , arg );
349
345
return mp_const_none ;
350
346
}
351
347
MP_DEFINE_CONST_FUN_OBJ_2 (synthio_note_set_ring_waveform_loop_start_obj , synthio_note_set_ring_waveform_loop_start );
352
348
MP_PROPERTY_GETSET (synthio_note_ring_waveform_loop_start_obj ,
353
349
(mp_obj_t )& synthio_note_get_ring_waveform_loop_start_obj ,
354
350
(mp_obj_t )& synthio_note_set_ring_waveform_loop_start_obj );
355
351
356
- //| ring_waveform_loop_end: int
352
+ //| ring_waveform_loop_end: BlockInput
357
353
//| """The sample index of where to end looping waveform data.
358
354
//|
359
- //| Values outside the range ``1`` to ``waveform_max_length`` (inclusive) are rejected with a `ValueError`.
360
- //|
361
- //| If the value is greater than the actual waveform length, or less than or equal to the loop start, the loop will occur at the end of the waveform.
355
+ //| The value is limited to the range ``ring_waveform_loop_start+1`` to ``len(ring_waveform)`` (inclusive).
362
356
//|
363
357
//| Use the `synthio.waveform_max_length` constant to set the loop point at the end of the wave form, no matter its length."""
364
358
//|
365
359
static mp_obj_t synthio_note_get_ring_waveform_loop_end (mp_obj_t self_in ) {
366
360
synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
367
- return mp_obj_new_int ( common_hal_synthio_note_get_ring_waveform_loop_end (self ) );
361
+ return common_hal_synthio_note_get_ring_waveform_loop_end (self );
368
362
}
369
363
MP_DEFINE_CONST_FUN_OBJ_1 (synthio_note_get_ring_waveform_loop_end_obj , synthio_note_get_ring_waveform_loop_end );
370
364
371
365
static mp_obj_t synthio_note_set_ring_waveform_loop_end (mp_obj_t self_in , mp_obj_t arg ) {
372
366
synthio_note_obj_t * self = MP_OBJ_TO_PTR (self_in );
373
- common_hal_synthio_note_set_ring_waveform_loop_end (self , mp_obj_get_int ( arg ) );
367
+ common_hal_synthio_note_set_ring_waveform_loop_end (self , arg );
374
368
return mp_const_none ;
375
369
}
376
370
MP_DEFINE_CONST_FUN_OBJ_2 (synthio_note_set_ring_waveform_loop_end_obj , synthio_note_set_ring_waveform_loop_end );
0 commit comments