Hi @martin ,
the preset ‘Send LFO’ you made (Electra One App) is really easy to understand and convert from a pipe lfo into one that can be added in other presets. It was also quite easy to add additional controls to it like choosing waveforms and even add additional waveshapes.
I did set the timer Period to 2 ms though, and added a condition to ensure MIDI messages are only transmitted when their value (assuming a max resolution of 256) changes. It works rather well and result in smoother value changes.
However currently the LFO speed increases when the page containing the scope is left. I mitigate this by reducing SCOPE_WIDTH to 20-40, instead of a more desirable 157-314. Can this be caused by the scope redraw/repaint taken more time than alotted between timer.setPeriod (2 ms) ? What happens then? Is the timer.onTick delayed ? Or skipped? Could we make the clocking stable by not using an incremental constant “timerInterval”, but rather use timestamp differences between the current and the previous call of function updateLFO()?
Next step for me is to turn it into a MIDI clockable LFO. Should not be too hard. Would the best approach then be to disregard timer.onTick callbacks and set the lfo.phase within each midi.onClock callback? I mean, with a high rate of 240 bpm this equals 4 quarter notes per second and thus 96 clock messages per s, or about one update each 10 ms. That’s even less then a timer.onTick period of 2ms.