Skip to content

Commit 0fe7502

Browse files
committed
Documentation improvements
1 parent 55db6b7 commit 0fe7502

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

shared-bindings/synthio/Note.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static const mp_arg_t note_properties[] = {
5858
//| panning: BlockInput = 0.0,
5959
//| waveform: Optional[ReadableBuffer] = None,
6060
//| waveform_loop_start: int = 0,
61-
//| waveform_loop_end: int = 0,
61+
//| waveform_loop_end: int = waveform_max_length,
6262
//| envelope: Optional[Envelope] = None,
6363
//| amplitude: BlockInput = 0.0,
6464
//| bend: BlockInput = 0.0,
@@ -67,7 +67,7 @@ static const mp_arg_t note_properties[] = {
6767
//| ring_bend: float = 0.0,
6868
//| ring_waveform: Optional[ReadableBuffer] = 0.0,
6969
//| ring_waveform_loop_start: int = 0,
70-
//| ring_waveform_loop_end: int = 0,
70+
//| ring_waveform_loop_end: int = waveform_max_length,
7171
//| ) -> None:
7272
//| """Construct a Note object, with a frequency in Hz, and optional panning, waveform, envelope, tremolo (volume change) and bend (frequency change).
7373
//|
@@ -219,7 +219,11 @@ MP_PROPERTY_GETSET(synthio_note_waveform_obj,
219219
(mp_obj_t)&synthio_note_set_waveform_obj);
220220

221221
//| 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."""
222+
//| """The sample index of where to begin looping waveform data.
223+
//|
224+
//| Values outside the range ``0`` to ``waveform_max_length-1`` (inclusive) are rejected with a `ValueError`.
225+
//|
226+
//| Values greater than or equal to the actual waveform length are treated as 0."""
223227
STATIC mp_obj_t synthio_note_get_waveform_loop_start(mp_obj_t self_in) {
224228
synthio_note_obj_t *self = MP_OBJ_TO_PTR(self_in);
225229
return mp_obj_new_int(common_hal_synthio_note_get_waveform_loop_start(self));
@@ -237,7 +241,13 @@ MP_PROPERTY_GETSET(synthio_note_waveform_loop_start_obj,
237241
(mp_obj_t)&synthio_note_set_waveform_loop_start_obj);
238242

239243
//| 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."""
244+
//| """The sample index of where to end looping waveform data.
245+
//|
246+
//| Values outside the range ``1`` to ``waveform_max_length`` (inclusive) are rejected with a `ValueError`.
247+
//|
248+
//| 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.
249+
//|
250+
//| Use the `synthio.waveform_max_length` constant to set the loop point at the end of the wave form, no matter its length."""
241251
//|
242252
STATIC mp_obj_t synthio_note_get_waveform_loop_end(mp_obj_t self_in) {
243253
synthio_note_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -342,7 +352,11 @@ MP_PROPERTY_GETSET(synthio_note_ring_waveform_obj,
342352
(mp_obj_t)&synthio_note_set_ring_waveform_obj);
343353

344354
//| 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."""
355+
//| """The sample index of where to begin looping waveform data.
356+
//|
357+
//| Values outside the range ``0`` to ``waveform_max_length-1`` (inclusive) are rejected with a `ValueError`.
358+
//|
359+
//| Values greater than or equal to the actual waveform length are treated as 0."""
346360
STATIC mp_obj_t synthio_note_get_ring_waveform_loop_start(mp_obj_t self_in) {
347361
synthio_note_obj_t *self = MP_OBJ_TO_PTR(self_in);
348362
return mp_obj_new_int(common_hal_synthio_note_get_ring_waveform_loop_start(self));
@@ -360,7 +374,13 @@ MP_PROPERTY_GETSET(synthio_note_ring_waveform_loop_start_obj,
360374
(mp_obj_t)&synthio_note_set_ring_waveform_loop_start_obj);
361375

362376
//| 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."""
377+
//| """The sample index of where to end looping waveform data.
378+
//|
379+
//| Values outside the range ``1`` to ``waveform_max_length`` (inclusive) are rejected with a `ValueError`.
380+
//|
381+
//| 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.
382+
//|
383+
//| Use the `synthio.waveform_max_length` constant to set the loop point at the end of the wave form, no matter its length."""
364384
//|
365385
STATIC mp_obj_t synthio_note_get_ring_waveform_loop_end(mp_obj_t self_in) {
366386
synthio_note_obj_t *self = MP_OBJ_TO_PTR(self_in);

shared-bindings/synthio/__init__.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ STATIC mp_obj_t voct_to_hz(mp_obj_t arg) {
304304
}
305305
MP_DEFINE_CONST_FUN_OBJ_1(synthio_voct_to_hz_obj, voct_to_hz);
306306

307+
//|
308+
//| waveform_max_length: int
309+
//| """The maximum number of samples permitted in a waveform"""
310+
//|
311+
307312
#if CIRCUITPY_AUDIOCORE_DEBUG
308313
STATIC mp_obj_t synthio_lfo_tick(size_t n, const mp_obj_t *args) {
309314
shared_bindings_synthio_lfo_tick(48000);
@@ -333,6 +338,7 @@ STATIC const mp_rom_map_elem_t synthio_module_globals_table[] = {
333338
{ MP_ROM_QSTR(MP_QSTR_Envelope), MP_ROM_PTR(&synthio_envelope_type_obj) },
334339
{ MP_ROM_QSTR(MP_QSTR_midi_to_hz), MP_ROM_PTR(&synthio_midi_to_hz_obj) },
335340
{ MP_ROM_QSTR(MP_QSTR_voct_to_hz), MP_ROM_PTR(&synthio_voct_to_hz_obj) },
341+
{ MP_ROM_QSTR(MP_QSTR_waveform_max_length), MP_ROM_INT(SYNTHIO_WAVEFORM_SIZE) },
336342
#if CIRCUITPY_AUDIOCORE_DEBUG
337343
{ MP_ROM_QSTR(MP_QSTR_lfo_tick), MP_ROM_PTR(&synthio_lfo_tick_obj) },
338344
#endif

0 commit comments

Comments
 (0)