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

<tupletSpan> wrongly converted to <tuplet> #3859

Open
th-we opened this issue Nov 13, 2024 · 2 comments
Open

<tupletSpan> wrongly converted to <tuplet> #3859

th-we opened this issue Nov 13, 2024 · 2 comments

Comments

@th-we
Copy link
Contributor

th-we commented Nov 13, 2024

Describe the problem

When converting <tupletSpan>s with @startid and @endid inside beams to MEI basic, Verovio wraps the entire beam into a tuplet instead of just the tuplet notes.

To Reproduce
Steps to reproduce the behavior:

  1. Save the below MEI as tuplet-span.mei
  2. On the command line, do: verovio -a -f mei -t mei-basic -o tuplet-basic.mei tuplet-span.mei
  3. The <layer> element that Verovio exports to tuplet-basic.mei looks like this:
<layer xml:id="lngvvyg" n="1">
   <tuplet xml:id="tssp0fk" type="tupletSpan" num="3" numbase="2">
      <beam xml:id="b12h26eu">
         <note xml:id="n1lfq8kp" dur="8" oct="4" pname="a" />
         <note xml:id="n1i1ycu8" dur="8" oct="4" pname="a" />
         <note xml:id="tupletStart" dur="8" oct="4" pname="a" />
         <note xml:id="nij7hcn" dur="8" oct="4" pname="a" />
         <note xml:id="tupletEnd" dur="8" oct="4" pname="a" />
      </beam>
   </tuplet>
</layer>    

Expected behavior

The <layer> element resulting from the below test data should look like this:

<layer n="1">
  <beam>
    <note dur="8" oct="4" pname="a" />
    <note dur="8" oct="4" pname="a" />
    <tuplet num="3" numbase="2">
      <note dur="8" oct="4" pname="a" xml:id="tupletStart" />
      <note dur="8" oct="4" pname="a" />
      <note dur="8" oct="4" pname="a" xml:id="tupletEnd" />  
    </tuplet>
  </beam>
</layer>

Input data

<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="5.0">
  <meiHead>
    <fileDesc>
      <titleStmt>
        <title />
      </titleStmt>
      <pubStmt />
    </fileDesc>
  </meiHead>
  <music>
    <body>
      <mdiv>
        <score>
          <scoreDef meter.count="2" meter.unit="4">
            <staffGrp>
              <staffDef n="1" lines="5" clef.shape="G" clef.line="2" />
            </staffGrp>
          </scoreDef>
          <section>
            <measure n="1">
              <staff n="1">
                <layer n="1">
                  <beam>
                    <note dur="8" oct="4" pname="a" />
                    <note dur="8" oct="4" pname="a" />
                    <note dur="8" oct="4" pname="a" xml:id="tupletStart" />
                    <note dur="8" oct="4" pname="a" />
                    <note dur="8" oct="4" pname="a" xml:id="tupletEnd" />
                  </beam>
                </layer>
              </staff>
              <tupletSpan startid="#tupletStart" endid="#tupletEnd" num="3" numbase="2" />
            </measure>
          </section>
        </score>
      </mdiv>
    </body>
  </music>
</mei>

Verovio information

  • Verovio 4.4.0-dev-911d63c
  • Binding: command-line

Environment

  • OS: Linux
@lpugin
Copy link
Contributor

lpugin commented Nov 13, 2024

This is not limited to MEI-basic. The Handling of tupletSpan is indeed very limited.

@lpugin
Copy link
Contributor

lpugin commented Nov 13, 2024

If you want to give a try improving it, this is where all the restructuring is happing:

verovio/src/iomei.cpp

Lines 8206 to 8225 in 911d63c

LayerElement *startChild = dynamic_cast<LayerElement *>(start->GetLastAncestorNot(LAYER));
LayerElement *endChild = dynamic_cast<LayerElement *>(end->GetLastAncestorNot(LAYER));
if (!startChild || !endChild || (startChild->GetParent() != endChild->GetParent())) {
LogWarning("Start and end elements for <tupletSpan> '%s' not in the same layer", tuplet->GetID().c_str());
delete tuplet;
return false;
}
Layer *parentLayer = dynamic_cast<Layer *>(startChild->GetParent());
assert(parentLayer);
int startIdx = startChild->GetIdx();
int endIdx = endChild->GetIdx();
// LogDebug("%d %d %s!", startIdx, endIdx, start->GetID().c_str());
for (int i = endIdx; i >= startIdx; --i) {
LayerElement *element = dynamic_cast<LayerElement *>(parentLayer->DetachChild(i));
if (element) tuplet->InsertChild(element, 0);
}
parentLayer->InsertChild(tuplet, startIdx);

@lpugin lpugin changed the title Conversion of <tupletSpan> to MEI basic <tupletSpan> wrongly converted to <tuplet> Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants