Skip to content

LFOModifier: gate output by MIDI activity in note-trigger mode#13

Merged
lucaromagnoli merged 1 commit into
magda_minimalfrom
feat/lfo-midi-gate
May 9, 2026
Merged

LFOModifier: gate output by MIDI activity in note-trigger mode#13
lucaromagnoli merged 1 commit into
magda_minimalfrom
feat/lfo-midi-gate

Conversation

@lucaromagnoli

Copy link
Copy Markdown
Contributor

Summary

  • Adds setGateOnTriggerSource(bool) to LFOModifier. When set and syncType == note, applyToBuffer drives the existing gated_ flag from the MIDI stream itself: NoteOn ungates and increments a held-note count, NoteOff (vel-0-aware) decrements it, AllNotesOff / AllSoundOff hard-resets. Gate re-asserts once the count returns to zero.
  • Lets MIDI-trigger LFOs behave like envelopes — output sits at 0 between notes — without changing the free-run sync mode for callers that don't opt in.

Why

Previously a note-mode LFO only resynced phase on note-on; its output free-ran between MIDI notes, which forced consumers to maintain a parallel "is the LFO running" simulation just to make UI animations and audio agree. With this opt-in flag, the audio engine itself owns the running state.

Behavior

  • Disabled by default → no change for existing TE callers.
  • When enabled + syncType == note: gate follows MIDI activity, output sits at 0 between notes.
  • When enabled but syncType != note: flag is ignored (still no gate).
  • Disabling the flag clears any held gate so output resumes immediately.

Test plan

  • Enable on a MIDI-trigger LFO → output is 0 with no notes held, full waveform while a note is held, returns to 0 on note-off.
  • Disable the flag at runtime → output resumes mid-note correctly.
  • Default (flag off) behavior matches upstream (LFO free-runs between notes).

Adds setGateOnTriggerSource(): when set and syncType == note,
applyToBuffer drives the existing gated_ flag from the MIDI stream
itself — NoteOn ungates and increments a held-note count, NoteOff
(vel-0-aware) decrements it, AllNotesOff/AllSoundOff hard-resets.
Gate re-asserts once the count returns to zero.

This lets MIDI-trigger LFOs behave like envelopes — output sits at 0
between notes — without changing the free-run sync mode for callers
that don't opt in.
@lucaromagnoli lucaromagnoli merged commit a3729f2 into magda_minimal May 9, 2026
3 checks passed
@lucaromagnoli lucaromagnoli deleted the feat/lfo-midi-gate branch May 9, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant