Skip to content

Commit

Permalink
Fix #207346: Restrict the first exported MIDI track to timing events.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmcclinch committed Feb 14, 2021
1 parent 5318f4a commit 5fb7b09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions audio/exports/exportmidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ namespace Ms {
// writeHeader
//---------------------------------------------------------

void ExportMidi::writeHeader()
void ExportMidi::writeHeader(MidiTrack& track)
{
if (mf.tracks().isEmpty())
return;
MidiTrack &track = mf.tracks().front();
#if 0 // TODO
MeasureBase* measure = cs->first();

Expand Down Expand Up @@ -249,6 +248,8 @@ bool ExportMidi::write(QIODevice* device, bool midiExpandRepeats, bool exportRPN
mf.setDivision(MScore::division);
mf.setFormat(1);
QList<MidiTrack>& tracks = mf.tracks();
MidiTrack tempoTrack;
tempoTrack.setOutChannel(0);

for (int i = 0; i < cs->nstaves(); ++i)
tracks.append(MidiTrack());
Expand All @@ -257,7 +258,7 @@ bool ExportMidi::write(QIODevice* device, bool midiExpandRepeats, bool exportRPN
cs->renderMidi(&events, false, midiExpandRepeats, synthState);

pauseMap.calculate(cs);
writeHeader();
writeHeader(tempoTrack);

int staffIdx = 0;
for (auto &track: tracks) {
Expand Down Expand Up @@ -370,6 +371,7 @@ bool ExportMidi::write(QIODevice* device, bool midiExpandRepeats, bool exportRPN
}
++staffIdx;
}
mf.tracks().prepend(tempoTrack);
return !mf.write(device);
}

Expand Down
2 changes: 1 addition & 1 deletion audio/exports/exportmidi.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ExportMidi {

PauseMap pauseMap;

void writeHeader();
void writeHeader(MidiTrack& tempoTrack);

public:
MidiFile mf;
Expand Down

0 comments on commit 5fb7b09

Please sign in to comment.