rism-digital / verovio

🎵 Music notation engraving library for MEI with MusicXML and Humdrum support and various toolkits (JavaScript, Python)
https://www.verovio.org
GNU Lesser General Public License v3.0
649 stars 176 forks source link

Skylining problem with stems of offset notes #977

Closed craigsapp closed 2 years ago

craigsapp commented 5 years ago

In the following example, the two staves are placed too close together. The stems on the notes of the third and fourth chords are colliding with each other:

screen shot 2019-01-05 at 10 17 16 am

The stems are not literally colliding, but they are visually colliding since they are so close to each other. The solution would be to give stems and apparent width of about 1 diatonic step (1/2 step on each side of the stem). This should trigger the avoidance of the visual collisions of the stems.

MEI data:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://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="2019-01-05T10:27:18" version="2.0.0-dev-1687ce7-dirty">
                    <name>Verovio</name>
                    <p>Transcoded from Humdrum</p>
                </application>
            </appInfo>
        </encodingDesc>
        <workList>
            <work>
                <title />
            </work>
        </workList>
    </meiHead>
    <music>
        <body>
            <mdiv xml:id="mdiv-0000000053400653">
                <score xml:id="score-0000001801480760">
                    <scoreDef xml:id="scoredef-0000000956178052" midi.bpm="400">
                        <staffGrp xml:id="staffgrp-0000000752221028" symbol="brace" bar.thru="true">
                            <label xml:id="label-0000000713834645" />
                            <staffDef xml:id="staffdef-0000000090660605" clef.shape="G" clef.line="2" key.sig="1s" meter.count="3" meter.unit="4" n="1" lines="5" />
                            <staffDef xml:id="staffdef-0000000479768223" clef.shape="F" clef.line="4" key.sig="1s" meter.count="3" meter.unit="4" n="2" lines="5" />
                        </staffGrp>
                    </scoreDef>
                    <section xml:id="section-L1F1">
                        <measure xml:id="measure-L6" n="9">
                            <staff xml:id="staff-L6F3N1" n="1">
                                <layer xml:id="layer-L6F3N1" n="1">
                                    <note xml:id="note-L7F3" dur="2" oct="4" pname="f" accid.ges="s" />
                                    <note xml:id="note-L9F3" dur="4" oct="4" pname="e" accid.ges="n" />
                                </layer>
                                <layer xml:id="layer-L6F4N2" n="2">
                                    <note xml:id="note-L7F4" dur="2" oct="4" pname="d" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L9F4" dur="4" oct="4" pname="d" stem.len="5.500000" accid.ges="n" />
                                </layer>
                            </staff>
                            <staff xml:id="staff-L6F1N1" n="2">
                                <layer xml:id="layer-L6F1N1" n="1">
                                    <note xml:id="note-L7F1" dur="4" oct="3" pname="a" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L8F1" dur="4" oct="3" pname="b" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L9F1" dur="4" oct="3" pname="b" stem.len="5.500000" accid.ges="n" />
                                </layer>
                                <layer xml:id="layer-L6F2N2" n="2">
                                    <note xml:id="note-L7F2" dur="4" oct="3" pname="d" accid.ges="n" />
                                    <note xml:id="note-L8F2" dur="4" oct="2" pname="b" stem.len="6.000000" accid.ges="n" />
                                    <note xml:id="note-L9F2" dur="4" oct="2" pname="g" stem.len="5.500000" accid="s" />
                                </layer>
                            </staff>
                            <tie xml:id="tie-L9F4-L11F4" startid="#note-L9F4" endid="#note-L11F4" />
                        </measure>
                        <measure xml:id="measure-L10" n="10">
                            <staff xml:id="staff-L10F3N1" n="1">
                                <layer xml:id="layer-L10F3N1" n="1">
                                    <note xml:id="note-L11F3" dur="4" oct="4" pname="e" accid.ges="n" />
                                    <note xml:id="note-L12F3" dur="4" oct="4" pname="f" accid.ges="s" />
                                    <note xml:id="note-L13F3" dur="4" oct="4" pname="d" accid="s" />
                                </layer>
                                <layer xml:id="layer-L10F4N2" n="2">
                                    <note xml:id="note-L11F4" dur="4" oct="4" pname="d" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L12F4" dur="4" oct="4" pname="c" stem.len="5.500000" accid="s" />
                                    <note xml:id="note-L13F4" dur="4" oct="3" pname="b" stem.len="5.500000" accid.ges="n" />
                                </layer>
                            </staff>
                            <staff xml:id="staff-L10F1N1" n="2">
                                <layer xml:id="layer-L10F1N1" n="1">
                                    <note xml:id="note-L11F1" dur="4" oct="3" pname="a" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L12F1" dur="4" oct="3" pname="f" stem.len="6.000000" accid.ges="s" />
                                    <note xml:id="note-L13F1" dur="4" oct="3" pname="f" stem.len="6.000000" accid.ges="s" />
                                </layer>
                                <layer xml:id="layer-L10F2N2" n="2">
                                    <note xml:id="note-L11F2" dur="4" oct="2" pname="a" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L12F2" dur="4" oct="2" pname="a" stem.len="5.500000" accid="s" />
                                    <note xml:id="note-L13F2" dur="4" oct="2" pname="b" stem.len="6.000000" accid.ges="n" />
                                </layer>
                            </staff>
                        </measure>
                        <measure xml:id="measure-L14" n="11">
                            <staff xml:id="staff-L14F3N1" n="1">
                                <layer xml:id="layer-L14F3N1" n="1">
                                    <note xml:id="note-L15F3" dur="2" oct="4" pname="e" accid.ges="n" />
                                    <note xml:id="note-L16F3" dur="4" oct="4" pname="e" accid.ges="n" />
                                </layer>
                                <layer xml:id="layer-L14F4N2" n="2">
                                    <note xml:id="note-L15F4" dur="2" oct="3" pname="b" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L16F4" dur="4" oct="3" pname="a" stem.len="5.500000" accid.ges="n" />
                                </layer>
                            </staff>
                            <staff xml:id="staff-L14F1N1" n="2">
                                <layer xml:id="layer-L14F1N1" n="1">
                                    <note xml:id="note-L15F1" dur="2" oct="3" pname="g" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L16F1" dur="4" oct="3" pname="e" stem.len="6.500000" accid.ges="n" />
                                </layer>
                                <layer xml:id="layer-L14F2N2" n="2">
                                    <note xml:id="note-L15F2" dur="2" oct="2" pname="e" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L16F2" dur="4" oct="3" pname="c" stem.len="6.500000" accid.ges="n" />
                                </layer>
                            </staff>
                            <fermata xml:id="fermata-L15F3" staff="1" startid="#note-L15F3" place="above" />
                            <fermata xml:id="fermata-L15F2" staff="2" startid="#note-L15F2" place="below" />
                            <tie xml:id="tie-L16F2-L18F2" startid="#note-L16F2" endid="#note-L18F2" />
                        </measure>
                        <measure xml:id="measure-L17" n="12">
                            <staff xml:id="staff-L17F3N1" n="1">
                                <layer xml:id="layer-L17F3N1" n="1">
                                    <note xml:id="note-L18F3" dur="2" oct="4" pname="d" accid.ges="n" />
                                    <note xml:id="note-L20F3" dur="4" oct="4" pname="e" accid.ges="n" />
                                </layer>
                                <layer xml:id="layer-L17F4N2" n="2">
                                    <note xml:id="note-L18F4" dur="4" oct="3" pname="a" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L19F4" dur="4" oct="3" pname="b" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L20F4" dur="4" oct="3" pname="a" stem.len="5.500000" accid.ges="n" />
                                </layer>
                            </staff>
                            <staff xml:id="staff-L17F1N1" n="2">
                                <layer xml:id="layer-L17F1N1" n="1">
                                    <note xml:id="note-L18F1" dur="4" oct="3" pname="f" stem.len="6.000000" accid.ges="s" />
                                    <note xml:id="note-L19F1" dur="4" oct="3" pname="g" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L20F1" dur="4" oct="3" pname="e" stem.len="6.500000" accid.ges="n" />
                                </layer>
                                <layer xml:id="layer-L17F2N2" n="2">
                                    <note xml:id="note-L18F2" dur="4" oct="3" pname="c" stem.len="6.500000" accid.ges="n" />
                                    <note xml:id="note-L19F2" dur="4" oct="2" pname="b" stem.len="6.000000" accid.ges="n" />
                                    <note xml:id="note-L20F2" dur="4" oct="3" pname="c" stem.len="6.500000" accid="s" />
                                </layer>
                            </staff>
                        </measure>
                        <measure xml:id="measure-L21" n="13">
                            <staff xml:id="staff-L21F3N1" n="1">
                                <layer xml:id="layer-L21F3N1" n="1">
                                    <note xml:id="note-L22F3" dur="2" oct="4" pname="f" accid.ges="s" />
                                    <note xml:id="note-L24F3" dur="4" oct="4" pname="f" accid.ges="s" />
                                </layer>
                                <layer xml:id="layer-L21F4N2" n="2">
                                    <note xml:id="note-L22F4" dur="2" oct="3" pname="a" stem.len="5.500000" accid.ges="n" />
                                    <note xml:id="note-L24F4" dur="4" oct="4" pname="c" stem.len="5.500000" accid.ges="n" />
                                </layer>
                            </staff>
                            <staff xml:id="staff-L21F1N1" n="2">
                                <layer xml:id="layer-L21F1N1" n="1">
                                    <note xml:id="note-L22F1" dur="4" oct="3" pname="d" accid.ges="n" />
                                    <note xml:id="note-L23F1" dur="4" oct="3" pname="f" stem.len="6.000000" accid.ges="s" />
                                    <note xml:id="note-L24F1" dur="4" oct="3" pname="a" stem.len="5.500000" accid.ges="n" />
                                </layer>
                                <layer xml:id="layer-L21F2N2" n="2">
                                    <note xml:id="note-L22F2" dur="4" oct="3" pname="d" accid.ges="n" />
                                    <note xml:id="note-L23F2" dur="4" oct="3" pname="c" stem.len="6.500000" accid="s" />
                                    <note xml:id="note-L24F2" dur="4" oct="3" pname="d" accid="s" />
                                </layer>
                            </staff>
                        </measure>
                    </section>
                </score>
            </mdiv>
        </body>
    </music>
</mei>

Original Humdrum data for text example:

**kern  **kern
*clefF4 *clefG2
*k[f#]  *k[f#]
*M3/4   *M3/4
*^  *^
=9  =9  =9  =9
4A  4D  2f# 2d
4B  4BB .   .
4B  4GG#    4e  [4d
=10 =10 =10 =10
4A  4AA 4e  4d]
4F# 4AA#    4f# 4c#
4F# 4BB 4d# 4B
=11 =11 =11 =11
2G;y    2EE;    2e; 2B;y
4E  [4C 4e  4A
=12 =12 =12 =12
4F# 4C] 2dX 4A
4G  4BB .   4B
4E  4C# 4e  4A
=13 =13 =13 =13
4D  4D  2f# 2A
4F# 4C# .   .
4A  4D# 4f# 4cX
=   =   =   =
*v  *v  *   *
*   *v  *v
*-  *-
Monceber commented 2 years ago

Should no longer be an issue. image