Skip to content

Commit

Permalink
ported musescore#7309 : Fix tempo rounding issue in MusicXML export
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkorsukov committed Feb 17, 2021
1 parent 4217739 commit ba4d44e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/importexport/musicxml/internal/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4164,7 +4164,11 @@ void ExportMusicXml::tempoText(TempoText const* const text, int staff)
if (staff) {
_xml.tag("staff", staff);
}
_xml.tagE(QString("sound tempo=\"%1\"").arg(QString::number(text->tempo() * 60.0)));
// Format tempo with maximum 2 decimal places, because in some MuseScore files tempo is stored
// imprecisely and this could cause rounding errors (e.g. 92 BPM would be saved as 91.9998).
qreal bpm = text->tempo() * 60.0;
qreal bpmRounded = round(bpm * 100) / 100;
_xml.tagE(QString("sound tempo=\"%1\"").arg(QString::number(bpmRounded)));
_xml.etag();
}

Expand Down

0 comments on commit ba4d44e

Please sign in to comment.