Skip to content

Commit

Permalink
Keep functor variable within layer loop
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Dec 9, 2024
1 parent 1e3fc62 commit 33f1191
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit 33f1191

Please sign in to comment.