Skip to content

Commit 126a1a4

Browse files
authored
Merge pull request #9197 from jepler/synthio-lfo-doc-improvements
LFO: document some things that trip up users
2 parents 7fb7910 + 8fcb1bf commit 126a1a4

File tree

1 file changed

+26
-1
lines changed
  • shared-bindings/synthio

1 file changed

+26
-1
lines changed

shared-bindings/synthio/LFO.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ STATIC const uint16_t triangle[] = {0, 32767, 0, -32767};
4343
//|
4444
//| If `waveform` is None, a triangle waveform is used.
4545
//|
46-
//| `rate`, `phase_offset`, `offset`, `scale`, and `once` can be changed at run-time. `waveform` may be mutated.
46+
//| `rate`, `phase_offset`, `offset`, `scale`, and `once` can be changed at
47+
//| run-time. `waveform` may be mutated.
4748
//|
4849
//| `waveform` must be a ``ReadableBuffer`` with elements of type ``'h'``
4950
//| (16-bit signed integer). Internally, the elements of `waveform` are scaled
@@ -58,6 +59,30 @@ STATIC const uint16_t triangle[] = {0, 32767, 0, -32767};
5859
//| In the current implementation, LFOs are updated every 256 samples. This
5960
//| should be considered an implementation detail, though it affects how LFOs
6061
//| behave for instance when used to implement an integrator (``l.offset = l``).
62+
//|
63+
//| An LFO's output, which is reflected in its `value` property, is not
64+
//| updated in any other way than when its associated synthesizer updates it.
65+
//| For instance, if an LFO is created with ``offset=1``, its `value` will still
66+
//| be ``0`` until it is updated by its associated synthesizer. Similarly, merely
67+
//| updating its properties does not update its value property.
68+
//|
69+
//| The interpolation of the waveform is necessarily different depending on the
70+
//| ``once`` property. Consider a LFO with ``waveform=np.array([0, 100],
71+
//| dtype=np.int16), interpolate=True, once=True, rate=1``. Over 1 second this
72+
//| LFO's output will change from ``0`` to ``100``, and will remain at
73+
//| ``100`` thereafter, creating a "bend out" over a duration of 1 second.
74+
//|
75+
//| However, when ``once=False``, this creates a triangle waveform with a
76+
//| period of 1 second. Over about the first half second the input will
77+
//| increase from ``0`` to ``100``, then during the second half of the second
78+
//| it will decrease back to ``0``.
79+
//|
80+
//| The time of the peak output is different depending on the value of ``once``:
81+
//| At 1.0s for ``once=True`` and at 0.5s for ``once=False``.
82+
//|
83+
//| Because of this difference in interpolation, dynamically updating the
84+
//| ``once`` flag except when the LFO is at a phase of 0 will cause a step in
85+
//| the LFO's output.
6186
//| """
6287
//|
6388
//| def __init__(

0 commit comments

Comments
 (0)