A class or method to convert integer and float to scientific pitch notation?

@semiquaver
Thank you for your feedback!

About Separator

The following are alternatives:

<a4=e5=a5>=/e/3/2/e=p=(
<a4`e5`a5>`/e/3/2/e`p`(
<a4,e5,a5>,/e/3/2/e,p,(
<a4-e5-a5>-/e/3/2/e-p-(  // - is used for articulation (tenuto).
<a4;e5;a5>;/e/3/2/e;p;(
<a4\e5\a5>\/e/3/2/e\p\(
<a4\e5\a5>_/e/3/2/e_p_( // _ is used for articulation (detached-legato).

_ is good for readability, but the shift key should be pressed, so I think it is a bit impractical. Could you choose other character than _? My mind is open to accept your opinion. If you think _ is the best one, than I will follow your mind.

About Tuplets

The following are the meanings of / and //:

  • / appended to the leftmost side of information:
    An indicator of tuplet notation.
  • / attached to the rightmost side of information:
    The note is the last note of a tuplet (a tuplet can be a nested tuplet).
  • // attached to the leftmost side of information:
    An indicator of nested tuplets.
  • // attached to the rightmost side of information:
    The note is the last note of a tuplet and also the last note of a nested tuplet.

For examples:

  • /e/3/2/e:
    the eighth note which is part of the 3:2 ratio of the eighth.
  • /e/
    the eighth note which is the last note of a tuplet.
  • /e//
    the eighth note which is the last note of a tuplet and a nested tuplet.

The following example may illustrate why the note value is needed at the end of tuplet notation:

  • /q/3/2/e:
    the quarter note, which is part of the 3:2 ratio of the eighth.
    However, /e/3/2/e can also be written as /e/3/2. I will add it! Thanks!

I also thought so, too.
/e/3:2/e is better than /e/3/2/e
OK! I can change it!

I used [] pairs for array notation of musical entries as in the example 1 in the following post:

v1: [
                [[\a7, \a6], [\e, 3, 2, \e]],    // [\a7, \a6]: a two-note chord; [\e, 3, 2, \e]: tuplet start. \e: eighth.
                [$|, [\e]],                      // $|; the same pitches as before; [\e]: tuplet continues.
                [$|, [5, \]],                    // [5, \]: tuplet ends. \: end sign, 5 = eighth.
                [[\af7, \as6], [\e, 3, 2, \e]],  // [\e, 3, 2, \e]: tuplet start.
                [$|, [[\x, 3, 2, \x]]],          // [[\x, 3, 2, \x]]: nested tuplet start; x: sixteenth.
                [$|, [[\x]]],                    // [[\x]]: nested tuplet continues.
                [$|, [[\x, \]]],                 // [[\x, \]]: nested tuplet end.
                [$|, [\e, \]],                   // [\e, \]: tuplet end.
                [$|, [\e, 5, 4, \e]],
                [$|, [[\e, 3, 2, \e]]],
                [$|, [[\q, \]]],
                [$|, [\q, \]]
            ]

In the string (or symbol) notation for musical entries, I do not use parentheses and braces to bind information.

I attach the structure of the musicXML part for the tuplet and then explain my notation details.

Below is the musicXML code for a three-note chord:

      <note>
        <pitch>
          <step>A</step>
          <alter>0.0</alter>
          <octave>4</octave>
        </pitch>
        <duration>84000</duration>              // related to non-tuplet and tuplet
        <voice>1</voice>
        <type>eighth</type>                           // related to non-tuplet and tuplet
        <accidental>natural</accidental>
        <time-modification>                            // related to tuplet
          <actual-notes>3</actual-notes>       
          <normal-notes>2</normal-notes>
          <normal-type>eighth</normal-type>
        </time-modification>
        <staff>1</staff>
        <notations>
          <tuplet type="start" bracket="yes" number="1"> // related to tuplet
            <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>
        </notations>
        <notations>
          <slur number="1" type="start"/>
        </notations>
      </note>
      <note>
        <chord/>
        <pitch>
          <step>E</step>
          <alter>0.0</alter>
          <octave>5</octave>
        </pitch>
        <duration>84000</duration>
        <voice>1</voice>
        <type>eighth</type>
        <accidental>natural</accidental>
        <staff>1</staff>
      </note>
      <note>
        <chord/>
        <pitch>
          <step>A</step>
          <alter>0.0</alter>
          <octave>5</octave>
        </pitch>
        <duration>84000</duration>
        <voice>1</voice>
        <type>eighth</type>
        <staff>1</staff>
      </note>

There are two (or three) components that define rhythm:

  • duration
  • note type
  • dot if present

There are many components to define a tuplet, but the core components are the following three in time modification:

  • actual-notes
  • normal-notes
  • normal-type

The other components can be constructed from these three.

Nested tuplets are computed from these components and the tuplet number.

In the string (or symbol) notation of musical notation, / is the tuplet indicator for start (for the start of tuplet information) and for end (for the end of tuplet information).

Thus, the first note of a tuplet requires the following four things, none of which can be currently omitted in either notation:

  1. /q/3/2/e: note-type / tuplet actual-note / tuplet normal-note / tuplet normal-type
  2. [\q, 3, 2, \e]
  3. /e/3/2/e: note-type / tuplet actual-note / tuplet normal-note / tuplet normal-type
  4. [\e, 3, 2, \e]

← In the case of 3 and 4, the last note value can be omitted. I will add it!

The last note of a tuplet should indicate that it is the last note of the tuplet. This is indicated by \ for array notation of musical entries and / for string (or symbol) notation of musical entries. They come at the end of the tuplet information, as follows

  • /e/
  • [\e, ]

The notes between the first tuplet note and the last tuplet note need no information, so they need their rhythmic values:

  • /e
  • [\e]