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

Support for <octave-change> at musicXML import #2725

Closed
wergo opened this issue Mar 22, 2022 · 8 comments · Fixed by #2726
Closed

Support for <octave-change> at musicXML import #2725

wergo opened this issue Mar 22, 2022 · 8 comments · Fixed by #2726

Comments

@wergo
Copy link
Contributor

wergo commented Mar 22, 2022

Current behavior
When importing orchestral scores containing transposed instruments from musicXML files, Verovio currently correctly imports <transpose><diatonic> and <transpose><chromatic> from the musicXML parts attributes into @trans.diat and @trans.semi. However, transpositions of more than an octave should be coded (and indeed are coded) with <ocatve-change> (see https://www.w3.org/2021/06/musicxml40/musicxml-reference/elements/transpose/, no changes here from version 3.1).

See discussions here:
music-encoding/sibmei#194
music-encoding/music-encoding#440

Describe the solution you'd like
As MEI does not have an @trans.octave-shift attribute, we would probably have to translate this musicXML element to @trans.semi. So, we should add 12 semitones for <octave-shift> to @trans.semi.

This is the current code in Verovio:

verovio/src/iomusxml.cpp

Lines 1418 to 1428 in 4d8c60d

// transpose
pugi::xpath_node transpose;
xpath = StringFormat("transpose[@number='%d']", i + 1);
transpose = it->select_node(xpath.c_str());
if (!transpose) {
transpose = it->select_node("transpose");
}
if (transpose) {
staffDef->SetTransDiat(transpose.node().child("diatonic").text().as_int());
staffDef->SetTransSemi(transpose.node().child("chromatic").text().as_int());
}

Expected MEI result
The staffDef of Glockenspiel should contain @trans.diat="0" @trans.semi="24";
of the guitar @trans.diat="0" @trans.semi="12".

grafik

Test example in musicXML (Glockenspiel 2 octaves higher, guitar one octave lower)
<?xml version="1.0" encoding='UTF-8' standalone='no' ?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.0">
 <work>
  <work-title />
 </work>
 <identification>
  <rights>Copyright © </rights>
  <encoding>
   <encoding-date>2022-03-22</encoding-date>
   <encoder>Werner Goebl</encoder>
   <software>Sibelius 19.1.0</software>
   <software>Direct export, not from Dolet</software>
   <encoding-description>Sibelius / MusicXML 3.0</encoding-description>
   <supports element="print" type="yes" value="yes" attribute="new-system" />
   <supports element="print" type="yes" value="yes" attribute="new-page" />
   <supports element="accidental" type="yes" />
   <supports element="beam" type="yes" />
   <supports element="stem" type="yes" />
  </encoding>
 </identification>
 <defaults>
  <scaling>
   <millimeters>210</millimeters>
   <tenths>2000</tenths>
  </scaling>
  <page-layout>
   <page-height>2828</page-height>
   <page-width>2000</page-width>
   <page-margins type="both">
    <left-margin>142</left-margin>
    <right-margin>142</right-margin>
    <top-margin>142</top-margin>
    <bottom-margin>142</bottom-margin>
   </page-margins>
  </page-layout>
  <system-layout>
   <system-margins>
    <left-margin>86</left-margin>
    <right-margin>0</right-margin>
   </system-margins>
   <system-distance>92</system-distance>
  </system-layout>
  <appearance>
   <line-width type="stem">0.9375</line-width>
   <line-width type="beam">5</line-width>
   <line-width type="staff">0.9375</line-width>
   <line-width type="light barline">1.5625</line-width>
   <line-width type="heavy barline">5</line-width>
   <line-width type="leger">1.5625</line-width>
   <line-width type="ending">1.5625</line-width>
   <line-width type="wedge">1.25</line-width>
   <line-width type="enclosure">0.9375</line-width>
   <line-width type="tuplet bracket">1.25</line-width>
   <line-width type="bracket">5</line-width>
   <line-width type="dashes">1.5625</line-width>
   <line-width type="extend">0.9375</line-width>
   <line-width type="octave shift">1.5625</line-width>
   <line-width type="pedal">1.5625</line-width>
   <line-width type="slur middle">1.5625</line-width>
   <line-width type="slur tip">0.625</line-width>
   <line-width type="tie middle">1.5625</line-width>
   <line-width type="tie tip">0.625</line-width>
   <note-size type="cue">75</note-size>
   <note-size type="grace">60</note-size>
  </appearance>
  <music-font font-family="Opus Std" font-size="11.9055" />
  <lyric-font font-family="Times New Roman" font-size="6.8829" />
  <lyric-language xml:lang="de" />
 </defaults>
 <part-list>
  <part-group type="start" number="1">
   <group-symbol>bracket</group-symbol>
  </part-group>
  <score-part id="P1">
   <part-name>Flöte</part-name>
   <part-name-display>
    <display-text>Flöte</display-text>
   </part-name-display>
   <part-abbreviation>Fl.</part-abbreviation>
   <part-abbreviation-display>
    <display-text>Fl.</display-text>
   </part-abbreviation-display>
   <score-instrument id="P1-I1">
    <instrument-name>Flute (2)</instrument-name>
    <instrument-sound>wind.flutes.flute</instrument-sound>
    <solo />
    <virtual-instrument>
     <virtual-library>General MIDI</virtual-library>
     <virtual-name>Flute</virtual-name>
    </virtual-instrument>
   </score-instrument>
  </score-part>
  <score-part id="P2">
   <part-name>Klarinette in B</part-name>
   <part-name-display>
    <display-text>Klarinette in B</display-text>
   </part-name-display>
   <part-abbreviation>Kl.</part-abbreviation>
   <part-abbreviation-display>
    <display-text>Kl.</display-text>
   </part-abbreviation-display>
   <score-instrument id="P2-I1">
    <instrument-name>Clarinet in B^b</instrument-name>
    <instrument-sound>wind.reed.clarinet</instrument-sound>
    <solo />
    <virtual-instrument>
     <virtual-library>General MIDI</virtual-library>
     <virtual-name>Clarinet</virtual-name>
    </virtual-instrument>
   </score-instrument>
  </score-part>
  <part-group type="stop" number="1" />
  <score-part id="P3">
   <part-name>Glockenspiel</part-name>
   <part-name-display>
    <display-text>Glockenspiel</display-text>
   </part-name-display>
   <part-abbreviation>Glsp.</part-abbreviation>
   <part-abbreviation-display>
    <display-text>Glsp.</display-text>
   </part-abbreviation-display>
   <score-instrument id="P3-I1">
    <instrument-name>Glockenspiel (2)</instrument-name>
    <instrument-sound>pitched-percussion.glockenspiel</instrument-sound>
    <solo />
    <virtual-instrument>
     <virtual-library>General MIDI</virtual-library>
     <virtual-name>Glockenspiel</virtual-name>
    </virtual-instrument>
   </score-instrument>
  </score-part>
  <score-part id="P4">
   <part-name>Akustische Gitarre</part-name>
   <part-name-display>
    <display-text>Akustische Gitarre</display-text>
   </part-name-display>
   <part-abbreviation>A. Git.</part-abbreviation>
   <part-abbreviation-display>
    <display-text>A. Git.</display-text>
   </part-abbreviation-display>
   <score-instrument id="P4-I1">
    <instrument-name>Acoustic Guitar (2)</instrument-name>
    <instrument-sound>pluck.guitar.steel-string</instrument-sound>
    <solo />
    <virtual-instrument>
     <virtual-library>General MIDI</virtual-library>
     <virtual-name>Acoustic Guitar (steel)</virtual-name>
    </virtual-instrument>
   </score-instrument>
  </score-part>
 </part-list>
 <part id="P1">
  <!--============== Part: P1, Measure: 1 ==============-->
  <measure number="1" width="824">
   <print new-page="yes">
    <system-layout>
     <system-margins>
      <left-margin>203</left-margin>
      <right-margin>0</right-margin>
     </system-margins>
     <top-system-distance>229</top-system-distance>
    </system-layout>
   </print>
   <attributes>
    <divisions>256</divisions>
    <key color="#000000">
     <fifths>2</fifths>
     <mode>major</mode>
    </key>
    <time color="#000000">
     <beats>4</beats>
     <beat-type>4</beat-type>
    </time>
    <staves>1</staves>
    <clef number="1" color="#000000">
     <sign>G</sign>
     <line>2</line>
    </clef>
    <staff-details number="1" print-object="yes" />
   </attributes>
   <note color="#000000" default-x="112" default-y="-45">
    <pitch>
     <step>D</step>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P1-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="290" default-y="10">
    <pitch>
     <step>A</step>
     <octave>4</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P1-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>up</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="468" default-y="-45">
    <pitch>
     <step>D</step>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P1-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="646" default-y="-35">
    <pitch>
     <step>F</step>
     <alter>1</alter>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P1-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
  </measure>
  <!--============== Part: P1, Measure: 2 ==============-->
  <measure number="2" width="688">
   <note color="#000000" default-x="15" default-y="-25">
    <pitch>
     <step>A</step>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P1-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note default-x="193">
    <rest />
    <duration>256</duration>
    <instrument id="P1-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <staff>1</staff>
   </note>
   <note default-x="370">
    <rest />
    <duration>512</duration>
    <instrument id="P1-I1" />
    <voice>1</voice>
    <type>half</type>
    <staff>1</staff>
   </note>
   <barline>
    <bar-style>light-heavy</bar-style>
   </barline>
  </measure>
 </part>
 <part id="P2">
  <!--============== Part: P2, Measure: 1 ==============-->
  <measure number="1" width="824">
   <print new-page="yes">
    <system-layout>
     <system-margins>
      <left-margin>203</left-margin>
      <right-margin>0</right-margin>
     </system-margins>
    </system-layout>
    <staff-layout number="1">
     <staff-distance>55</staff-distance>
    </staff-layout>
   </print>
   <attributes>
    <divisions>256</divisions>
    <key color="#000000">
     <fifths>4</fifths>
     <mode>major</mode>
    </key>
    <time color="#000000">
     <beats>4</beats>
     <beat-type>4</beat-type>
    </time>
    <staves>1</staves>
    <clef number="1" color="#000000">
     <sign>G</sign>
     <line>2</line>
    </clef>
    <staff-details number="1" print-object="yes" />
    <transpose>
     <diatonic>-1</diatonic>
     <chromatic>-2</chromatic>
    </transpose>
   </attributes>
   <note color="#000000" default-x="112" default-y="-40">
    <pitch>
     <step>E</step>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P2-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="290" default-y="-55">
    <pitch>
     <step>B</step>
     <octave>4</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P2-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="468" default-y="-40">
    <pitch>
     <step>E</step>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P2-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="646" default-y="-30">
    <pitch>
     <step>G</step>
     <alter>1</alter>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P2-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
  </measure>
  <!--============== Part: P2, Measure: 2 ==============-->
  <measure number="2" width="688">
   <note color="#000000" default-x="15" default-y="-20">
    <pitch>
     <step>B</step>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P2-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note default-x="193">
    <rest />
    <duration>256</duration>
    <instrument id="P2-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <staff>1</staff>
   </note>
   <note default-x="370">
    <rest />
    <duration>512</duration>
    <instrument id="P2-I1" />
    <voice>1</voice>
    <type>half</type>
    <staff>1</staff>
   </note>
   <barline>
    <bar-style>light-heavy</bar-style>
   </barline>
  </measure>
 </part>
 <part id="P3">
  <!--============== Part: P3, Measure: 1 ==============-->
  <measure number="1" width="824">
   <print new-page="yes">
    <system-layout>
     <system-margins>
      <left-margin>203</left-margin>
      <right-margin>0</right-margin>
     </system-margins>
    </system-layout>
    <staff-layout number="1">
     <staff-distance>65</staff-distance>
    </staff-layout>
   </print>
   <attributes>
    <divisions>256</divisions>
    <key color="#000000">
     <fifths>2</fifths>
     <mode>major</mode>
    </key>
    <time color="#000000">
     <beats>4</beats>
     <beat-type>4</beat-type>
    </time>
    <staves>1</staves>
    <clef number="1" color="#000000">
     <sign>G</sign>
     <line>2</line>
    </clef>
    <staff-details number="1" print-object="yes" />
    <transpose>
     <diatonic>0</diatonic>
     <chromatic>0</chromatic>
     <octave-change>2</octave-change>
    </transpose>
   </attributes>
   <note color="#000000" default-x="112" default-y="-45">
    <pitch>
     <step>D</step>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P3-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="290" default-y="10">
    <pitch>
     <step>A</step>
     <octave>4</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P3-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>up</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="468" default-y="-45">
    <pitch>
     <step>D</step>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P3-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="646" default-y="-35">
    <pitch>
     <step>F</step>
     <alter>1</alter>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P3-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
  </measure>
  <!--============== Part: P3, Measure: 2 ==============-->
  <measure number="2" width="688">
   <note color="#000000" default-x="15" default-y="-25">
    <pitch>
     <step>A</step>
     <octave>5</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P3-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note default-x="193">
    <rest />
    <duration>256</duration>
    <instrument id="P3-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <staff>1</staff>
   </note>
   <note default-x="370">
    <rest />
    <duration>512</duration>
    <instrument id="P3-I1" />
    <voice>1</voice>
    <type>half</type>
    <staff>1</staff>
   </note>
   <barline>
    <bar-style>light-heavy</bar-style>
   </barline>
  </measure>
 </part>
 <part id="P4">
  <!--============== Part: P4, Measure: 1 ==============-->
  <measure number="1" width="824">
   <print new-page="yes">
    <system-layout>
     <system-margins>
      <left-margin>203</left-margin>
      <right-margin>0</right-margin>
     </system-margins>
    </system-layout>
    <staff-layout number="1">
     <staff-distance>55</staff-distance>
    </staff-layout>
   </print>
   <attributes>
    <divisions>256</divisions>
    <key color="#000000">
     <fifths>2</fifths>
     <mode>major</mode>
    </key>
    <time color="#000000">
     <beats>4</beats>
     <beat-type>4</beat-type>
    </time>
    <staves>1</staves>
    <clef number="1" color="#000000">
     <sign>G</sign>
     <line>2</line>
     <clef-octave-change>-1</clef-octave-change>
    </clef>
    <staff-details number="1" print-object="yes" />
    <transpose>
     <diatonic>0</diatonic>
     <chromatic>0</chromatic>
     <octave-change>-1</octave-change>
    </transpose>
   </attributes>
   <note color="#000000" default-x="112" default-y="-45">
    <pitch>
     <step>D</step>
     <octave>4</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P4-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="290" default-y="10">
    <pitch>
     <step>A</step>
     <octave>3</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P4-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>up</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="468" default-y="-45">
    <pitch>
     <step>D</step>
     <octave>4</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P4-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note color="#000000" default-x="646" default-y="-35">
    <pitch>
     <step>F</step>
     <alter>1</alter>
     <octave>4</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P4-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
  </measure>
  <!--============== Part: P4, Measure: 2 ==============-->
  <measure number="2" width="688">
   <note color="#000000" default-x="15" default-y="-25">
    <pitch>
     <step>A</step>
     <octave>4</octave>
    </pitch>
    <duration>256</duration>
    <instrument id="P4-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <stem>down</stem>
    <staff>1</staff>
   </note>
   <note default-x="193">
    <rest />
    <duration>256</duration>
    <instrument id="P4-I1" />
    <voice>1</voice>
    <type>quarter</type>
    <staff>1</staff>
   </note>
   <note default-x="370">
    <rest />
    <duration>512</duration>
    <instrument id="P4-I1" />
    <voice>1</voice>
    <type>half</type>
    <staff>1</staff>
   </note>
   <barline>
    <bar-style>light-heavy</bar-style>
   </barline>
  </measure>
 </part>
</score-partwise>

Converted MEI
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/dev/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/dev/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.0-dev">
   <meiHead>
      <fileDesc>
         <titleStmt>
            <title></title>
            <respStmt />
         </titleStmt>
         <pubStmt><availability>
               <distributor>Copyright © </distributor>
            </availability>
            <date isodate="2022-03-22" type="encoding-date">2022-03-22</date>
         </pubStmt>
      </fileDesc>
      <encodingDesc xml:id="encodingdesc-6j8yjw">
         <appInfo xml:id="appinfo-foom4q">
            <application xml:id="application-rux7h5" isodate="2022-03-22T13:02:29" version="3.10.0-dev-4d8c60d">
               <name xml:id="name-8b5g6g">Verovio</name>
               <p xml:id="p-7jpw3j">Transcoded from MusicXML</p>
            </application>
         </appInfo>
      </encodingDesc>
   </meiHead>
   <music>
      <body>
         <mdiv xml:id="mu1wxv0">
            <score xml:id="sx3nowc">
               <scoreDef xml:id="sumjnl9">
                  <staffGrp xml:id="s9r14wu">
                     <staffGrp xml:id="stoah55">
                        <grpSym xml:id="g5z90gq" symbol="bracket" />
                        <staffDef xml:id="P1" n="1" lines="5" ppq="256">
                           <label xml:id="lijm700">Flöte</label>
                           <labelAbbr xml:id="l2ofs4h">Fl.</labelAbbr>
                           <clef xml:id="c771dq5" shape="G" color="#000000" line="2" />
                           <keySig xml:id="kujuo8g" mode="major" sig="2s" />
                           <meterSig xml:id="m8ci66o" count="4" unit="4" />
                        </staffDef>
                        <staffDef xml:id="P2" n="2" lines="5" ppq="256" trans.diat="-1.000000" trans.semi="-2.000000">
                           <label xml:id="ldon2k0">Klarinette in B</label>
                           <labelAbbr xml:id="lnu85cs">Kl.</labelAbbr>
                           <clef xml:id="cbrjil6" shape="G" color="#000000" line="2" />
                           <keySig xml:id="ktr9lbv" mode="major" sig="4s" />
                           <meterSig xml:id="m62pwfw" count="4" unit="4" />
                        </staffDef>
                     </staffGrp>
                     <staffDef xml:id="P3" n="3" lines="5" ppq="256">
                        <label xml:id="l6khekj">Glockenspiel</label>
                        <labelAbbr xml:id="lbzskj3">Glsp.</labelAbbr>
                        <clef xml:id="cf440x" shape="G" color="#000000" line="2" />
                        <keySig xml:id="kdoheti" mode="major" sig="2s" />
                        <meterSig xml:id="m9pjq2g" count="4" unit="4" />
                     </staffDef>
                     <staffDef xml:id="P4" n="4" lines="5" ppq="256">
                        <label xml:id="l35viz2">Akustische Gitarre</label>
                        <labelAbbr xml:id="l4hk54g">A. Git.</labelAbbr>
                        <clef xml:id="chr84o1" shape="G" color="#000000" line="2" dis="8" dis.place="below" />
                        <keySig xml:id="kn3cq1k" mode="major" sig="2s" />
                        <meterSig xml:id="mv8ngon" count="4" unit="4" />
                     </staffDef>
                  </staffGrp>
               </scoreDef>
               <section xml:id="si345ji">
                  <pb xml:id="pc444pu" />
                  <measure xml:id="mrox2r4" n="1">
                     <staff xml:id="shmntnt" n="1">
                        <layer xml:id="lveri9l" n="1">
                           <note xml:id="nco8hd0" dur.ppq="256" dur="4" oct="5" pname="d" color="#000000" stem.dir="down" />
                           <note xml:id="nvekt0e" dur.ppq="256" dur="4" oct="4" pname="a" color="#000000" stem.dir="up" />
                           <note xml:id="nmicn64" dur.ppq="256" dur="4" oct="5" pname="d" color="#000000" stem.dir="down" />
                           <note xml:id="nnr2enu" dur.ppq="256" dur="4" oct="5" pname="f" color="#000000" stem.dir="down" accid.ges="s" />
                        </layer>
                     </staff>
                     <staff xml:id="seelbo9" n="2">
                        <layer xml:id="lpv3n3s" n="1">
                           <note xml:id="nglybcj" dur.ppq="256" dur="4" oct="5" pname="e" color="#000000" stem.dir="down" />
                           <note xml:id="njp5raz" dur.ppq="256" dur="4" oct="4" pname="b" color="#000000" stem.dir="down" />
                           <note xml:id="nmoqm34" dur.ppq="256" dur="4" oct="5" pname="e" color="#000000" stem.dir="down" />
                           <note xml:id="nf4smqn" dur.ppq="256" dur="4" oct="5" pname="g" color="#000000" stem.dir="down" accid.ges="s" />
                        </layer>
                     </staff>
                     <staff xml:id="su906tf" n="3">
                        <layer xml:id="lxaby4e" n="1">
                           <note xml:id="n3mpqih" dur.ppq="256" dur="4" oct="5" pname="d" color="#000000" stem.dir="down" />
                           <note xml:id="nlounle" dur.ppq="256" dur="4" oct="4" pname="a" color="#000000" stem.dir="up" />
                           <note xml:id="n8cb8gf" dur.ppq="256" dur="4" oct="5" pname="d" color="#000000" stem.dir="down" />
                           <note xml:id="nafxm89" dur.ppq="256" dur="4" oct="5" pname="f" color="#000000" stem.dir="down" accid.ges="s" />
                        </layer>
                     </staff>
                     <staff xml:id="sv6zyol" n="4">
                        <layer xml:id="lgq40i6" n="1">
                           <note xml:id="nywzvcf" dur.ppq="256" dur="4" oct="4" pname="d" color="#000000" stem.dir="down" />
                           <note xml:id="n6ggoo8" dur.ppq="256" dur="4" oct="3" pname="a" color="#000000" stem.dir="up" />
                           <note xml:id="nv0osbz" dur.ppq="256" dur="4" oct="4" pname="d" color="#000000" stem.dir="down" />
                           <note xml:id="nhpejsn" dur.ppq="256" dur="4" oct="4" pname="f" color="#000000" stem.dir="down" accid.ges="s" />
                        </layer>
                     </staff>
                  </measure>
                  <measure xml:id="mwtjrqk" right="end" n="2">
                     <staff xml:id="s82ke2b" n="1">
                        <layer xml:id="lhkq6ve" n="1">
                           <note xml:id="nsvznyn" dur.ppq="256" dur="4" oct="5" pname="a" color="#000000" stem.dir="down" />
                           <rest xml:id="rq88nnk" dur.ppq="256" dur="4" />
                           <rest xml:id="ro6qbm7" dur.ppq="512" dur="2" />
                        </layer>
                     </staff>
                     <staff xml:id="sl8h0m5" n="2">
                        <layer xml:id="lowsojt" n="1">
                           <note xml:id="nry3xg4" dur.ppq="256" dur="4" oct="5" pname="b" color="#000000" stem.dir="down" />
                           <rest xml:id="rsjx9fj" dur.ppq="256" dur="4" />
                           <rest xml:id="r46r25n" dur.ppq="512" dur="2" />
                        </layer>
                     </staff>
                     <staff xml:id="scz65ov" n="3">
                        <layer xml:id="li5lnij" n="1">
                           <note xml:id="nw40tqw" dur.ppq="256" dur="4" oct="5" pname="a" color="#000000" stem.dir="down" />
                           <rest xml:id="rmp6nj6" dur.ppq="256" dur="4" />
                           <rest xml:id="reyzpsv" dur.ppq="512" dur="2" />
                        </layer>
                     </staff>
                     <staff xml:id="sbqkk79" n="4">
                        <layer xml:id="lgm38ee" n="1">
                           <note xml:id="n7lnfb8" dur.ppq="256" dur="4" oct="4" pname="a" color="#000000" stem.dir="down" />
                           <rest xml:id="rnl3ozx" dur.ppq="256" dur="4" />
                           <rest xml:id="rtg3zmk" dur.ppq="512" dur="2" />
                        </layer>
                     </staff>
                  </measure>
               </section>
            </score>
         </mdiv>
      </body>
   </music>
</mei>
@rettinghaus
Copy link
Contributor

I think it should be @trans.semi="-12" for the guitar.
Why should @trans.diat be 0 in these cases?

Also I'm wondering if we could have combined cases like

<chromatic>3</chromatic>
<octave-change>-1</octave-change>

@wergo
Copy link
Contributor Author

wergo commented Mar 22, 2022

I think it should be @trans.semi="-12" for the guitar.

Absolutely, my mistake.

Why should @trans.diat be 0 in these cases?

The piccolo example at https://music-encoding.org/guidelines/v4/content/cmn.html#cmnDefs suggests to only use @trans.semi for that:
<staffDef [...] trans.diat="0" trans.semi="12" />

<chromatic>3</chromatic>
<octave-change>-1</octave-change>

That should result in @trans.semi="-9"?

@rettinghaus
Copy link
Contributor

In your example the guitar will sound two octaves lower, because you also use a clef with octave change.

@wergo
Copy link
Contributor Author

wergo commented Mar 22, 2022

In your example the guitar will sound two octaves lower, because you also use a clef with octave change.

Well, no. <clef @dis> shifts also the displayed notation (in the opposite direction), so the sounding pitch remains the same.

@craigsapp
Copy link
Contributor

Why should @trans.diat be 0 in these cases?

if @trans.semi="12" then it must be @trans.diat="7" for transposing up an octave. In other words, transpose up 12 semitones which is equivalent to 7 diatonic steps.

If @trans.diat="0" that would transpose C4 to C############4 rather than to C5.

See

"A Binomial Representation of Pitch for Computer Processing of Musical Data" by Alexander R. Brinkman. Music Theory Spectrum, Volume 8, Issue 1, Spring 1986, Pages 44–57, https://doi.org/10.2307/746069
Published: 01 March 1986

https://academic.oup.com/mts/article-abstract/8/1/44/1063294?redirectedFrom=fulltext

@wergo
Copy link
Contributor Author

wergo commented Mar 22, 2022

This makes sense to me.

So, the flute example from the guidelines in then incorrect? (https://music-encoding.org/guidelines/v4/content/cmn.html#cmnDefs)

...and in #2726 we would have to add a + 7 * transpose.node().child("octave-change").text().as_int()) to SetTransDiat.

@craigsapp
Copy link
Contributor

So, the flute example from the guidelines in then incorrect?

Yes. If you are only using the transposition to get the correct MIDI data, then the diatonic qualifier is not needed, for example C5 and C############4 have the same frequency (assuming equal temperament).

But switching between sounding and written pitch for notation requires the diatonic steps to match the semitone steps. Since 12/0 is nonsense, it can be automatically corrected to 12/7 before doing a transposition (but it is better not to rely on autocorrection).

@wergo
Copy link
Contributor Author

wergo commented Mar 22, 2022

Thanks @craigsapp for clarifying this (and in music-encoding/sibmei#194). Great to have it incorporated in Verovio; thanks @rettinghaus for the implementation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants