@@ -40,11 +40,12 @@ STATIC const uint16_t triangle[] = {0, 32767, 0, -32767};
4040//| should be considered an implementation detail, though it affects how LFOs
4141//| behave for instance when used to implement an integrator (``l.offset = l``).
4242//|
43- //| An LFO's output, which is reflected in its `value` property, is not
44- //| updated in any other way than when its associated synthesizer updates it.
45- //| For instance, if an LFO is created with ``offset=1``, its `value` will still
46- //| be ``0`` until it is updated by its associated synthesizer. Similarly, merely
47- //| updating its properties does not update its value property.
43+ //| An LFO's ``value`` property is computed once when it is constructed, and then
44+ //| when its associated synthesizer updates it.
45+ //|
46+ //| This means that for instance an LFO **created** with ``offset=1`` has ```value==1``
47+ //| immediately, but **updating** the ``offset`` property alone does not
48+ //| change ``value``; it only updates through an association with an active synthesizer.
4849//|
4950//| The interpolation of the waveform is necessarily different depending on the
5051//| ``once`` property. Consider a LFO with ``waveform=np.array([0, 100],
@@ -100,11 +101,17 @@ STATIC mp_obj_t synthio_lfo_make_new(const mp_obj_type_t *type_in, size_t n_args
100101 synthio_synth_parse_waveform (& self -> waveform_bufinfo , args [ARG_waveform ].u_obj );
101102 }
102103 self -> waveform_obj = args [ARG_waveform ].u_obj ;
103- self -> base .last_tick = synthio_global_tick ;
104104
105105 mp_obj_t result = MP_OBJ_FROM_PTR (self );
106106 properties_construct_helper (result , lfo_properties + 1 , args + 1 , MP_ARRAY_SIZE (lfo_properties ) - 1 );
107107
108+ // Force computation of the LFO's initial output
109+ synthio_global_rate_scale = 0 ;
110+ self -> base .last_tick = synthio_global_tick - 1 ;
111+ synthio_block_slot_t slot ;
112+ synthio_block_assign_slot (MP_OBJ_FROM_PTR (result ), & slot , MP_QSTR_self );
113+ (void )synthio_block_slot_get (& slot );
114+
108115 return result ;
109116};
110117
0 commit comments