fluidsyX: resume macros waiting on keyOff/sampleEnd via FluidSynth voice callbacks#10
Draft
Copilot wants to merge 5 commits into
Draft
fluidsyX: resume macros waiting on keyOff/sampleEnd via FluidSynth voice callbacks#10Copilot wants to merge 5 commits into
Copilot wants to merge 5 commits into
Conversation
Copilot
AI
changed the title
fluidsyX: implement voice callbacks for keyOff/sampleEnd SoundMacro wait support
fluidsyX: resume macros waiting on keyOff/sampleEnd via FluidSynth voice callbacks
May 24, 2026
Copilot created this pull request from a session on behalf of
derselbst
May 24, 2026 10:32
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fluidsyX had no mechanism to detect voice noteoff or sample completion, so
CmdWaitTickswithkeyOfforsampleEndflags would block macro execution indefinitely. FluidSynth PR #1778 (≥ 2.5.4) addsfluid_voice_set_callbackwithFLUID_VOICE_CALLBACK_NOTEOFF/FLUID_VOICE_CALLBACK_FINISHEDreasons, enabling these signals.Additionally, two pre-existing bugs in
CmdWaitTicks::DoFluidprevented the wait from ever terminating even when conditions were met.New: voice callback infrastructure (
FLUID_VERSION_AT_LEAST(2, 5, 4))VoiceCallbackData— carriesapp,macroId,voiceId(for self-removal from map onFINISHED), stored in a newstd::map<unsigned int, VoiceCallbackData> voiceCallbacksonFluidsyXApp.std::mapstable-reference guarantee makes passing&entryto FluidSynth safe across subsequent inserts.voiceStateCallback— setskeyoffReceivedonNOTEOFF,sampleEndReceivedonFINISHED. For indefinite waits only (inIndefiniteWait), callsscheduleImmediateResumeto unblock the macro viafluid_sequencer_send_now. Finite timed waits only get the flag set; their existing timers fire and check it. TheFINISHEDhandler also erases thevoiceCallbacksentry.MacroExecContext::selfId— macroId is now pre-assigned inenqueueSoundMacrobefore the command loop and stored on the context, making it available insidedummy_preset_noteon(called synchronously fromfluid_synth_start) when registering the callback.Bug fixes in
CmdWaitTicks::DoFluidctx.pc++: both pre-checks (keyOff already received, sampleEnd already received) returned0without advancing the program counter, causing the outer loop to re-execute the same wait instruction forever.if(v)guard on keyoff pre-check: afterreleaseVoice()setsctx.voiceId = 0,findVoiceByIdreturnsnullptrand the pre-check was silently skipped. Fixed to treatv == nullptras "not sustained":