humdrum-tools / verovio-humdrum-viewer

Verovio Humdrum Viewer
http://verovio.humdrum.org
37 stars 9 forks source link

Converting instruments in A tuning #832

Open jedrekk86 opened 1 year ago

jedrekk86 commented 1 year ago

There is a problem with the conversion of instruments in A tuning (Clarinet for example) when the key has four flats. In MuseScore five sharps appear correctly, after conversion in Humdrum there's a different key appear.

MuseScore:

image

Humdrum: image

**kern
*I"Clarinetto in A
*I'Cl. in A
*clefG2
*ITrd2c3
*k[]
*M4/4
=1
4g#\
4a#\
4b#\
4cc#\
=2
4dd#\
4ee#\
4ff##\
4gg#\
==
*-
craigsapp commented 1 year ago

Can you also post the MusicXML export from Musescore? After the MuiscXML file is created, open in VHV or a similar text editor and copy the contents, then paste into a post on this page. Surround the MusicXML text in triple backquotes:

```xml
[MusicXML text pasted here]

The `xml` type will allow colorizing of the XML data.

Humdrum data can be displayed in the message using a similar method:
[Humdrum text pasted here]

For long examples, you can add with this text:
MusicXML data for above example ```xml [MusicXML contents here] ```

Example of how the above code renders in a post:

<details>
<summary> MusicXML data for above example </summary>

```xml
[MusicXML contents here]

jedrekk86 commented 1 year ago

Here is the MusicXML export

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="4.0">
  <work>
    <work-title>Test</work-title>
    </work>
  <identification>
    <creator type="composer"></creator>
    <encoding>
      <software>MuseScore 4.1.1</software>
      <encoding-date>2023-08-23</encoding-date>
      <supports element="accidental" type="yes"/>
      <supports element="beam" type="yes"/>
      <supports element="print" attribute="new-page" type="no"/>
      <supports element="print" attribute="new-system" type="no"/>
      <supports element="stem" type="yes"/>
      </encoding>
    </identification>
  <part-list>
    <score-part id="P1">
      <part-name>Clarinetto in A</part-name>
      <part-abbreviation>Cl. in A</part-abbreviation>
      <score-instrument id="P1-I1">
        <instrument-name>Clarinetto</instrument-name>
        <instrument-sound>wind.reed.clarinet.a</instrument-sound>
        </score-instrument>
      <midi-device id="P1-I1" port="1"></midi-device>
      <midi-instrument id="P1-I1">
        <midi-channel>1</midi-channel>
        <midi-program>72</midi-program>
        <volume>78.7402</volume>
        <pan>0</pan>
        </midi-instrument>
      </score-part>
    </part-list>
  <part id="P1">
    <measure number="1">
      <attributes>
        <divisions>1</divisions>
        <key>
          <fifths>5</fifths>
          </key>
        <time>
          <beats>4</beats>
          <beat-type>4</beat-type>
          </time>
        <clef>
          <sign>G</sign>
          <line>2</line>
          </clef>
        <transpose>
          <diatonic>-2</diatonic>
          <chromatic>-3</chromatic>
          </transpose>
        </attributes>
      <note>
        <pitch>
          <step>B</step>
          <octave>4</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>quarter</type>
        <stem>down</stem>
        </note>
      <note>
        <pitch>
          <step>C</step>
          <alter>1</alter>
          <octave>5</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>quarter</type>
        <stem>down</stem>
        </note>
      <note>
        <pitch>
          <step>D</step>
          <alter>1</alter>
          <octave>5</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>quarter</type>
        <stem>down</stem>
        </note>
      <note>
        <pitch>
          <step>E</step>
          <octave>5</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>quarter</type>
        <stem>down</stem>
        </note>
      </measure>
    <measure number="2">
      <note>
        <pitch>
          <step>F</step>
          <alter>1</alter>
          <octave>5</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>quarter</type>
        <stem>down</stem>
        </note>
      <note>
        <pitch>
          <step>G</step>
          <alter>1</alter>
          <octave>5</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>quarter</type>
        <stem>down</stem>
        </note>
      <note>
        <pitch>
          <step>A</step>
          <alter>1</alter>
          <octave>5</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>quarter</type>
        <stem>down</stem>
        </note>
      <note>
        <pitch>
          <step>B</step>
          <octave>5</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>quarter</type>
        <stem>down</stem>
        </note>
      <barline location="right">
        <bar-style>light-heavy</bar-style>
        </barline>
      </measure>
    </part>
  </score-partwise>
craigsapp commented 1 year ago

This is a tricky case of an enharmonic key signature.

Going from B major (written) to A-flat major (sounding) means that the clarinets are treated as being in B-double-flat major rather than A major.

Screenshot 2023-08-23 at 12 36 28

The best solution for now would probably be to edit the transpositions for the A clarinet in the MusicXML export to convert from an A clarinet to a B-double-flat clarinet:

<transpose>
     <diatonic>-2</diatonic>
     <chromatic>-3</chromatic>
</transpose>

This means A, which is -2 diatonic notes below C, and -3 chromatic steps below C. Change to:

<transpose>
     <diatonic>-1</diatonic>
     <chromatic>-3</chromatic>
</transpose>

This means B-double-flat: -1 means it is a type of B, and -3 chromatic means -2 chromatic steps below B natural, so B-double-flat.

Here is the altered MusicXML file:

Click to view MusicXML data for B-double-flat major clarinet ```xml Test MuseScore 4.1.1 2023-08-23 Clarinetto in A Cl. in A Clarinetto wind.reed.clarinet.a 1 72 78.7402 0 1 5 G 2 -1 -3 B 4 1 1 quarter down C 1 5 1 1 quarter down D 1 5 1 1 quarter down E 5 1 1 quarter down F 1 5 1 1 quarter down G 1 5 1 1 quarter down A 1 5 1 1 quarter down B 5 1 1 quarter down light-heavy ```

Converting using B-double-flat clarinets will result in the desired A-flat major sounding pitches (instead of G-sharp major):

!!!OTL: Test
**kern
*I"Clarinetto in A
*I'Cl. in A
*clefG2
*ITrd1c3
*k[b-e-a-d-]
*M4/4
=1
4a-
4b-
4cc
4dd-
=2
4ee-
4ff
4gg
4aa-
==
*-
Screenshot 2023-08-23 at 12 52 05

View in VHV.

*ITrd1c3 notice the sounding-to-written transposition instruction, which treats the clarinets as being in B-double-flat.

A related problem is that in the original conversion the key signature was output as *k[]. This should have been a key signature with 8 sharps (or f-double-sharp and six other regular sharps). The converter probably cannot handle this key signature and gave up, instead outputting and empty key signature since there were more than 7 accidentals in the key signature.

This could be enhanced to output the correct key signature, although real music would never do this:

Screenshot 2023-08-23 at 13 04 30

(I would have to deal with the double-sharp in the key signature to have it not be displayed visually in the above case on the F## note.