From 33f1191d7cb04878b481fba6ec435567aa4bc6ab Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Mon, 9 Dec 2024 17:33:21 +0100 Subject: [PATCH] Keep functor variable within layer loop --- src/doc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/doc.cpp b/src/doc.cpp index 92f991fd1f..c7d562d941 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -525,8 +525,7 @@ void Doc::ExportMIDI(smf::MidiFile *midiFile) scoreDef->Process(generateScoreDefMIDI); - GenerateMIDIFunctor generateMIDI(midiFile); - generateMIDI.SetControlEvents(true); + bool controlEvents = true; for (auto &layers : staves.second.child) { filters.Clear(); @@ -535,6 +534,8 @@ void Doc::ExportMIDI(smf::MidiFile *midiFile) AttNIntegerComparison matchLayer(LAYER, layers.first); filters.Add(&matchStaff); filters.Add(&matchLayer); + + GenerateMIDIFunctor generateMIDI(midiFile); generateMIDI.SetFilters(&filters); generateMIDI.SetChannel(midiChannel); @@ -545,13 +546,14 @@ void Doc::ExportMIDI(smf::MidiFile *midiFile) generateMIDI.SetCurrentTempo(tempo); generateMIDI.SetDeferredNotes(initMIDI.GetDeferredNotes()); generateMIDI.SetCueExclusion(this->GetOptions()->m_midiNoCue.GetValue()); + generateMIDI.SetControlEvents(controlEvents); // LogDebug("Exporting track %d ----------------", midiTrack); this->Process(generateMIDI); tempoEventTicks = generateMIDI.GetTempoEventTicks(); // Process them only once per staff - generateMIDI.SetControlEvents(false); + controlEvents = false; } } midiFile->sortTracks();