Skip to content

Commit

Permalink
Use tick set outside functor to track tempo events
Browse files Browse the repository at this point in the history
across multiple staves and layers
  • Loading branch information
brdvd committed Sep 18, 2024
1 parent 752d145 commit 3ae93e9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,15 +406,18 @@ void Doc::ExportMIDI(smf::MidiFile *midiFile)
}

double tempo = MIDI_TEMPO;
std::set<int> tempoEventTicks; // track the ticks of added tempo events

// set MIDI tempo
ScoreDef *scoreDef = this->GetFirstVisibleScore()->GetScoreDef();
if (scoreDef->HasMidiBpm()) {
tempo = scoreDef->GetMidiBpm();
tempoEventTicks.insert(0);
midiFile->addTempo(0, 0, tempo);
}
else if (scoreDef->HasMm()) {
tempo = Tempo::CalcTempo(scoreDef);
tempoEventTicks.insert(0);
midiFile->addTempo(0, 0, tempo);
}

Expand Down Expand Up @@ -522,13 +525,16 @@ void Doc::ExportMIDI(smf::MidiFile *midiFile)
generateMIDI.SetChannel(midiChannel);
generateMIDI.SetTrack(midiTrack);
generateMIDI.SetStaffN(staves->first);
generateMIDI.SetTempoEventTicks(tempoEventTicks);
generateMIDI.SetTransSemi(transSemi);
generateMIDI.SetCurrentTempo(tempo);
generateMIDI.SetDeferredNotes(initMIDI.GetDeferredNotes());
generateMIDI.SetCueExclusion(this->GetOptions()->m_midiNoCue.GetValue());

// LogDebug("Exporting track %d ----------------", midiTrack);
this->Process(generateMIDI);

tempoEventTicks = generateMIDI.GetTempoEventTicks();
}
}
}
Expand Down

0 comments on commit 3ae93e9

Please sign in to comment.