Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve beam shortening to resolve overlap #3836

Merged
merged 7 commits into from
Oct 22, 2024

Conversation

brdvd
Copy link
Contributor

@brdvd brdvd commented Oct 22, 2024

This PR enhances the changes from #3291 . The basic issue is that the introduced beam shortening was not properly controlled. In some cases the beams even flipped to the other side due to this.

Example 1

Before After
Before-1 After-1
Show MEI
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="5.0">
   <meiHead xml:id="mqsgymx">
      <fileDesc xml:id="f15w1rxo">
         <titleStmt xml:id="truhx8h">
            <title>Pigens Sang ved Bækken</title>
         </titleStmt>
         <pubStmt xml:id="ppcgs0q" />
      </fileDesc>
   </meiHead>
   <music>
      <body>
         <mdiv xml:id="m1n3czb3">
            <score xml:id="scjw24t">
               <scoreDef xml:id="s11cx33s">
                  <staffGrp xml:id="s1e1gp6n">
                     <staffDef xml:id="P1" n="1" lines="5" ppq="12">
                        <clef xml:id="c1dvjb6y" shape="F" line="4" />
                        <keySig xml:id="k1iafbot" sig="2f" />
                        <meterSig xml:id="m1ql6uxa" count="2" unit="4" />
                     </staffDef>
                  </staffGrp>
               </scoreDef>
               <section xml:id="sdkjhgdf5">
                  <measure xml:id="mdsrpu8" n="17">
                     <staff xml:id="s169d3nc" n="1">
                        <layer xml:id="l1enkosp" n="5">
                           <chord xml:id="ctqlbs3" dur.ppq="12" dur="4" stem.dir="up">
                              <note xml:id="n1y86v4v" oct="3" pname="g" />
                              <note xml:id="n1ees80l" oct="3" pname="b" accid.ges="f" />
                           </chord>
                           <beam xml:id="bboiu7g">
                              <note xml:id="nsykmsi" dots="1" dur.ppq="9" dur="8" oct="3" pname="b"
                                 stem.dir="up" accid.ges="f" />
                              <note xml:id="n1tnwwut" dur.ppq="3" dur="16" oct="3" pname="a"
                                 stem.dir="up" />
                           </beam>
                        </layer>
                        <layer xml:id="l1wpcy5a" n="6">
                           <space xml:id="s1n5bk1n" dur.ppq="12" dur="4" />
                           <note xml:id="n1o221dv" dur.ppq="12" dur="4" oct="3" pname="f"
                              stem.dir="up">
                              <accid xml:id="a1k40wal" accid="s" />
                           </note>
                        </layer>
                        <layer xml:id="ldwgn9w" n="7">
                           <chord xml:id="c2lrcp9" dur.ppq="12" dur="4" stem.dir="down">
                              <note xml:id="n1yx4fd1" oct="2" pname="d" />
                              <note xml:id="n1tbo69s" oct="3" pname="d" />
                           </chord>
                           <chord xml:id="czklsto" dur.ppq="12" dur="4" stem.dir="down">
                              <note xml:id="n3thoxw" oct="2" pname="d" />
                              <note xml:id="nzz6uad" oct="3" pname="d" />
                           </chord>
                        </layer>
                     </staff>
                     <tie xml:id="tlch5cc" startid="#n1yx4fd1" endid="#n3thoxw" curvedir="below" />
                     <tie xml:id="t1830oww" startid="#n1tbo69s" endid="#nzz6uad" curvedir="below" />
                  </measure>
               </section>
            </score>
         </mdiv>
      </body>
   </music>
</mei>

Example 2

Before After
Before-7 After-7
Show MEI
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/5.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/5.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="5.0">
   <meiHead>
      <fileDesc>
         <titleStmt>
            <title>Clef changes under beams</title>
         </titleStmt>
         <pubStmt>
            <respStmt>
               <persName role="encoder">Klaus Rettinghaus</persName>
               <corpName role="funder">Enote GmbH</corpName>
            </respStmt>
            <date isodate="2020">2020</date>
         </pubStmt>
         <seriesStmt>
            <title>Verovio test suite</title>
         </seriesStmt>
         <notesStmt>
            <annot>Beams should avoid clefs.</annot>
         </notesStmt>
      </fileDesc>
      <encodingDesc>
         <appInfo>
            <application version="unknown" label="0">
               <name>Verovio</name>
            </application>
         </appInfo>
      </encodingDesc>
   </meiHead>
   <music>
      <body>
         <mdiv>
            <score>
               <scoreDef>
                  <staffGrp>
                     <staffDef n="1" lines="5" clef.shape="G" clef.line="2" meter.count="4"
                        meter.unit="4" />
                  </staffGrp>
               </scoreDef>
               <section>
                  <measure>
                     <staff n="1">
                        <layer n="1">
                           <beam>
                              <note dur="8" oct="5" pname="e" stem.dir="down" />
                              <note dur="8" oct="5" pname="e" stem.dir="down" />
                           </beam>
                           <beam>
                              <note dur="8" oct="5" pname="a" stem.dir="down" />
                              <note dur="8" oct="5" pname="a" stem.dir="down" />
                           </beam>
                        </layer>
                        <layer n="2">
                           <beam>
                              <note dur="8" oct="4" pname="e" stem.dir="down" />
                              <note dur="8" oct="4" pname="e" stem.dir="down" />
                           </beam>
                           <beam>
                              <note dur="8" oct="4" pname="a" stem.dir="down" />
                              <note dur="8" oct="4" pname="a" stem.dir="down" />
                           </beam>
                        </layer>
                     </staff>
                  </measure>
               </section>
            </score>
         </mdiv>
      </body>
   </music>
</mei>

Code changes

  • Beams are shortened due to overlap, only if the overlap is less than three units.
  • The CalcLayerOverlap method is moved into the AdjustBeamsFunctor as it is only used there. This also simplifies the signature.
  • The implementation of the method is improved.

Copy link
Contributor

@rettinghaus rettinghaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@lpugin lpugin merged commit 26afb67 into rism-digital:develop Oct 22, 2024
5 checks passed
@brdvd brdvd deleted the feat/beam-overlap branch October 22, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants