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

Direct access to actual_notes, normal_notes and type in a tuplet #405

Open
leleogere opened this issue Dec 16, 2024 · 0 comments
Open

Direct access to actual_notes, normal_notes and type in a tuplet #405

leleogere opened this issue Dec 16, 2024 · 0 comments

Comments

@leleogere
Copy link

Currently, tuplets objects only consist of pointers to the start and end note of the tuplet. There is no way of saying if it is a "3-against-2-eights" triplet for example, or a "5-against-4-sixteenths" quintuplet when iterating over the score and encountering a Tuplet object. To get this information, one would have to explore the notes in between the start and end note, trying to guess this information from their type (which is not straightforward as a type quarter_3/2 could be either a quarter note in an eighth-note triplet or a quarter note in a quarter-note tuplet for example, or for example when parsing nested tuplets).

The actual/normal notes information is sometimes accessible in the MusicXML file. For example, below is an example of a note on which are starting 2 nested tuplets: a 3-against-2-eight triplet and a 3-against-2-sixteenth triplet.

Show XML
      <note>
        <pitch>
          <step>E</step>
          <octave>4</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>16th</type>
        <time-modification>
          <actual-notes>9</actual-notes>
          <normal-notes>4</normal-notes>
          </time-modification>
        <stem>up</stem>
        <beam number="1">begin</beam>
        <beam number="2">begin</beam>
        <notations>
          <tuplet type="start" number="1" bracket="yes" placement="below">
            <tuplet-actual>
              <tuplet-number>3</tuplet-number>
              <tuplet-type>eighth</tuplet-type>
              </tuplet-actual>
            <tuplet-normal>
              <tuplet-number>2</tuplet-number>
              <tuplet-type>eighth</tuplet-type>
              </tuplet-normal>
            </tuplet>
          <tuplet type="start" number="2" bracket="yes">
            <tuplet-actual>
              <tuplet-number>3</tuplet-number>
              <tuplet-type>16th</tuplet-type>
              </tuplet-actual>
            <tuplet-normal>
              <tuplet-number>2</tuplet-number>
              <tuplet-type>16th</tuplet-type>
              </tuplet-normal>
            </tuplet>
          </notations>
        </note>

However, this information is not always explicitly provided (in scores exported by MuseScore at least), and is supposed to be inferred from the <time-modification> tags if absent (according to MusicXML spec).

Show XML
      <note>
        <pitch>
          <step>F</step>
          <octave>4</octave>
          </pitch>
        <duration>3</duration>
        <voice>1</voice>
        <type>eighth</type>
        <time-modification>
          <actual-notes>3</actual-notes>
          <normal-notes>2</normal-notes>
          <normal-type>eighth</normal-type>
          </time-modification>
        <stem>up</stem>
        <notations>
          <tuplet type="start" bracket="yes"/>
          </notations>
        </note>
      <note>
        <pitch>
          <step>G</step>
          <octave>4</octave>
          </pitch>
        <duration>6</duration>
        <voice>1</voice>
        <type>quarter</type>
        <time-modification>
          <actual-notes>3</actual-notes>
          <normal-notes>2</normal-notes>
          <normal-type>eighth</normal-type>
          </time-modification>
        <stem>up</stem>
        <notations>
          <tuplet type="stop"/>
          </notations>
        </note>

Being able to access this information directly in the tuplet object would be extremely useful:

tuplet = next(score.iter_all(cls=partitura.score.Tuplet)
tuplet.actual_notes  # 3 for a 3-against-2-eights tuplet
tuplet.normal_notes  # 2 for a 3-against-2-eights tuplet
tupet.type           # eight for a 3-against-2-eights tuplet

However, while this feature would be very handful, I do not know if this is actually possible as tuplets can get quite complex.

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

No branches or pull requests

1 participant