verovio icon indicating copy to clipboard operation
verovio copied to clipboard

vertical position of single staff - changed behaviour?

Open axgeertinger opened this issue 3 years ago • 6 comments

With Verovio 2.7.0, the piano input staff on a search page I've created had a fixed position as desired (that is, it didn't move as notes were entered). With Verovio 3.0.2, this behaviour has changed. When entering high notes (f'' and above), some extra top margin is added, pushing the staff downwards. You can try it here: https://melodier.dsl.dk/mei_search.xq?a=72-74-76-72-72-74-76-72&language=en I also had to change the top margin from 0 to 90 to get the empty staff in roughly the same position as with Verovio 2.7.0. The options I am using are:

// Verovio settings for the piano input 
var verovio_options_search = {
    from:               'mei',
    svgViewBox:         true,
    scale:              100,
    pageWidth:          1200,
    pageHeight:         260,
    pageMarginTop:      90,
    pageMarginLeft:     0,
    header:             'none',
    footer:             'none',
    spacingStaff:       10,
    spacingLinear:      0.9,
    spacingNonLinear:   0.36,
    font:               'Bravura',
    adjustPageHeight:   false,
    noJustification:    true, 
    systemDivider:      'none'
};

I suspect the changed behaviour has to do with https://github.com/rism-ch/verovio/commit/aaaea02e7a00ff5642e32c43d22e46eb06483671 , but I can't figure it out. Is it intended, and is there a way to disable it?

Best, Axel

axgeertinger avatar Nov 20 '20 16:11 axgeertinger

There was some change in the behavior of the margins in July. Here is an issue where I was examining the changes:https://github.com/rism-ch/verovio/issues/1553

The reference position for the top margin was moved to the top line of the staff from some higher position.

I do not know if it was intended. The ideal solution to "turn it off" would be to implement issue #1553 so that the default top margin does not chop off music at the top of the image when the notes are high.

craigsapp avatar Nov 20 '20 16:11 craigsapp

I can avoid clipping at the top by adding some top margin. So I did. But the main problem is that it moves down as notes are added, which really doesn't look good. And I would also need to add more vertical space to avoid the staff being chopped off at the bottom instead. But I just want it to stay where it is.

axgeertinger avatar Nov 20 '20 18:11 axgeertinger

I see the problem, and perhaps it is different from #1553.

Here is an example of placing a note on a staff with pageTopMargin set to 100:

Screen Shot 2020-11-20 at 12 33 05 PM

The height of the SVG image is 114.47 units.

When I move the note up one step:

Screen Shot 2020-11-20 at 12 33 31 PM

The top margin is already increasing slightly for some reason. You can see the vertical height of the SVG image goes from 114.97 to 115. Then every increase in pitch height increases the top margin gets bigger, here by 4.77 units:

Screen Shot 2020-11-20 at 12 34 18 PM

Then 4.78 units for the next step:

Screen Shot 2020-11-20 at 12 34 43 PM

Then 4.76 units:

Screen Shot 2020-11-20 at 12 35 10 PM

Then 4.77 units:

Screen Shot 2020-11-20 at 12 35 39 PM

In other words, there is probably an anti-clipping algorithm which is being too aggressive, and is trying to keep the top margin always 100 units from the highest part of the music (but there is a strange situation where it increases the margin before the whole note leaves the staff, which indicate there could be some sort of bug in the intention of this feature).

For conversion to PDF files and paper printouts, it would also be useful to fix the position of the top and bottom staves to a fixed height on the page, so adjustment of this behavior would be desirable. One possible solution would be to add an "allowClipping" option that would not add the extra padding, and it would be up to the user to get a height that does not clip their music. But it seems like the current behavior is more aggressive with the padding than previously, in which case the previous system might be better to return to.

MEI test data:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="4.0.0">
 <meiHead>
  <fileDesc>
   <titleStmt>
    <title />
   </titleStmt>
   <pubStmt />
  </fileDesc>
  <encodingDesc>
   <appInfo>
    <application isodate="2020-11-20T12:47:32" version="3.1.0-dev-94a4985-dirty">
     <name>Verovio</name>
     <p>Transcoded from Humdrum</p>
    </application>
   </appInfo>
  </encodingDesc>
  <workList>
   <work>
    <title />
   </work>
  </workList>
 </meiHead>
 <music>
  <body>
   <mdiv xml:id="mdiv-0000000257133738">
    <score xml:id="score-0000000419315167">
     <scoreDef xml:id="scoredef-0000001257117184" midi.bpm="400">
      <staffGrp xml:id="staffgrp-0000001116808717">
       <staffDef xml:id="staffdef-0000000141253921" n="1" lines="5">
        <clef xml:id="clef-0000000315191440" shape="G" line="2" />
       </staffDef>
      </staffGrp>
     </scoreDef>
     <section xml:id="section-L1F1">
      <measure xml:id="measure-L1" right="end" n="1">
       <staff xml:id="staff-0000000766864141" n="1">
        <layer xml:id="layer-L1F1N1" n="1">
         <note xml:id="note-L3F1" dur="1" oct="6" pname="c" accid.ges="n" />
        </layer>
       </staff>
      </measure>
     </section>
    </score>
   </mdiv>
  </body>
 </music>
</mei>

craigsapp avatar Nov 20 '20 20:11 craigsapp

It needs to be investigated, but I think the problem is related to this one https://github.com/rism-ch/verovio/issues/1183

Basically, the clef is not taken into account for the vertical spacing (i.e., cropping). The space above is actually calculated looking at the position of the top note. We can see in Craig's snippets it is increasing by a VU (except for the first increase that is due to the whole note shape)

lpugin avatar Nov 23 '20 07:11 lpugin

Adding more top margin automatically (though probably not as aggressively as now) may be desirable in some situations, but it might be useful to make it optional with an "allowClipping" option as Craig suggests. AFAIK, the standard for most music pulishers is to keep the topmost staff at the same position on every page unless there are exceptionally high notes or text forcing it down. So for standard page layout, I would say that margins should be increased only if the bounding box actually exceeds the viewbox. As it is, adding more pageMarginTop prevents clipping at the top, but it does not stop the staff from moving down as soon as the notes exceed the top staff line - even when there is plenty of space above.

axgeertinger avatar Nov 23 '20 09:11 axgeertinger

I have reverted our site to Verovio 2.7.0 for now. To document the undesired behaviour, I placed a copy of the script using Verovio 3.0.2 here: https://melodier.dsl.dk/mei_search_verovio3.xq?a=72-74-76-72-72-74-76-72&language=en

axgeertinger avatar Nov 30 '20 12:11 axgeertinger

Should have been closed with https://github.com/rism-digital/verovio/pull/2632

lpugin avatar Dec 08 '22 17:12 lpugin