[MusicXML] Value of <system-distance> exported to xml is too small (by twice the spatium)

• Feb 20, 2014 - 14:22
Type
Functional
Severity
S4 - Minor
Status
closed
Project
Tags

Version: MuseScoreNightly-2014-02-20-1307-37db5d7.7z
OS: Win XP Sp3 (on Virtual Box on Ubuntu 12.04)

Bug: The value for the distance between systems exported to xml is smaller than what is actually layed out on the screen and exported to a png file.

Source code: System::layout2(), line 365 and ExportMusicXml::write, line 4128

To reproduce the bug:
- make a new score with one vocal staff and 32 empty measures
- export it as xml
- also export it as png (300 dpi)
- calculate the scaling (pixels per tenth) from the default values in the xml file:
<scaling>
<millimeters>7.05556</millimeters>
<tenths>40</tenths>
</scaling>

scaling = (7.05556 / 40.) * (300. / 25.4) = 2.0833 pixels per tenth

- First a sanity check: measure the staff size in the png file (e.g. with the Gimp):
png staff size = 83 pixels
- calculate the staff size from the xml file:
xml staff size = 40. * 2.0833 = 83.3 pixels
This is a precise correspondence

- now measure the system distance in the png file between the bottom of measure 1 and the top of measure 18
png staff distance = 312 pixels
- calculate the same system distance from the xml file (given in measure 18): <system-distance>130.00</system-distance>
xml system distance = 130. * 2.0833 = 270.83 pixels

The difference between the system distance in the png file and and the xml file is:
(312. - 270.83) / 2.0833 = 20 tenth or precisely twice the Spatium (10 tenth)

This finding may correspond to what I found in the source code.
In ExportMusicXml::write, line 4128 I found the following expression for <system-distance>:

m->pagePos().y() - previousMeasure->pagePos().y() - previousMeasure->bbox().height()

This would be right, when bbox.height() would be the real staffHeight.
However, diving deeper, I found where the height of the bbox might be set (in System::layout2(), line 365):

m->bbox().setRect(0.0, -_spatium, m->width(), systemHeight + 2 * _spatium);

The addition of 2 * _spatium would explain the difference between png and xml values.


Comments