humdrum-tools / verovio-humdrum-viewer

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

Cautionary natural-sharp encoding #110

Closed jacekiwaszko1 closed 6 years ago

jacekiwaszko1 commented 6 years ago

In Chopin's Mazurka op. 56 no 1, mm. 166 (Schlesinger edition) there's cautionary neutral-sharp sign:

cautionary-neutral-sharp-m56n01mm166

It is possible to encode it in MEI and to view it in Verovio:

cautionary-neutral-sharp2

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="4.0.0">
    <meiHead>
        <fileDesc>
            <titleStmt>
                <title />
            </titleStmt>
            <pubStmt />
        </fileDesc>
        <encodingDesc>
            <appInfo>
                <application isodate="2018-06-08T10:50:19" version="2.0.0-dev-fef1aab">
                    <name>Verovio</name>
                    <p>Transcoded from Humdrum</p>
                </application>
            </appInfo>
        </encodingDesc>
        <workDesc>
            <work>
                <titleStmt>
                    <title />
                </titleStmt>
            </work>
        </workDesc>
    </meiHead>
    <music>
        <body>
            <mdiv xml:id="mdiv-0000002003693255">
                <score xml:id="score-0000000510032891">
                    <scoreDef xml:id="scoredef-0000001477426825">
                        <staffGrp xml:id="staffgrp-0000000219329251">
                            <staffDef xml:id="staffdef-0000001106032645" clef.shape="F" clef.line="4" key.sig="5s" meter.count="3" meter.unit="4" n="1" lines="5">
                                <label xml:id="label-0000001864578229" />
                            </staffDef>
                        </staffGrp>
                    </scoreDef>
                    <section xml:id="section-0000002115632857">
                        <measure xml:id="measure-L1" n="0">
                            <staff xml:id="staff-0000000785571029" n="1">
                                <layer xml:id="layer-L1F1N1" n="1">
                                    <beam xml:id="beam-L5F1-L7F1">
                                        <chord xml:id="chord-L5F1" dur="8">
                                            <note xml:id="note-L5F1S1" oct="4" pname="f" accid.ges="s" />
                                            <note xml:id="note-L5F1S2" oct="4" pname="d" accid.ges="s" />
                                        </chord>
                                        <rest xml:id="rest-L6F1" dur="16" />
                                        <chord xml:id="chord-L7F1" dur="16">
                                            <note xml:id="note-L7F1S1" oct="4" pname="f" accid.ges="s" />
                                            <note xml:id="note-L7F1S2" oct="3" pname="b" accid.ges="n" />
                                        </chord>
                                    </beam>
                                    <chord xml:id="chord-L8F1" dur="4">
                                        <note xml:id="note-L8F1S1" oct="4" pname="f" accid.ges="s" />
                                        <note xml:id="note-L8F1S2" oct="4" pname="d" accid.ges="s" />
                                    </chord>
                                    <chord xml:id="chord-L9F1" dur="4">
                                        <note xml:id="note-L9F1S1" oct="4" pname="e" accid="s" />
                                        <note xml:id="note-L9F1S2" oct="4" pname="c" accid="x" />
                                    </chord>
                                </layer>
                            </staff>
                        </measure>
                        <measure xml:id="measure-L10">
                            <staff xml:id="staff-L10F1N1" n="1">
                                <layer xml:id="layer-L10F1N1" n="1">
                                    <beam xml:id="beam-L11F1-L13F1">
                                        <chord xml:id="chord-L11F1" dur="8">
                                            <note xml:id="note-L11F1S1" oct="4" pname="f" accid.ges="s" />
                                            <note xml:id="note-L11F1S2" oct="4" pname="d" accid.ges="s" />
                                        </chord>
                                        <rest xml:id="rest-L12F1" dur="16" />
                                        <chord xml:id="chord-L13F1" dur="16">
                                            <note xml:id="note-L13F1S1" oct="4" pname="f" accid.ges="s" />
                                            <note xml:id="note-L13F1S2" oct="3" pname="b" accid.ges="n" />
                                        </chord>
                                    </beam>
                                    <chord xml:id="chord-L14F1" dur="4">
                                        <note xml:id="note-L14F1S1" oct="4" pname="f" accid.ges="s" />
                                        <note xml:id="note-L14F1S2" oct="4" pname="d" accid.ges="s" />
                                    </chord>
                                    <chord xml:id="chord-L15F1" dur="4">
                                        <note xml:id="note-L15F1S1" oct="4" pname="e" accid="s" />
                                        <note xml:id="note-L15F1S2" oct="4" pname="c">
                                            <accid xml:id="accid-L15F1S2" accid="ns" func="caution" />
                                        </note>
                                    </chord>
                                </layer>
                            </staff>
                        </measure>
                    </section>
                </score>
            </mdiv>
        </body>
    </music>
</mei>

(I simply changed @accid="s" to @accid="ns" in <accid>)

But I can't find the way to encode this in Humdrum. Neither 4cn#, 4cnX#, 4cn#X or 4cnX#X makes any difference. Am I missing something?

KERN data:

**kern
*clefF4
*k[f#c#g#d#a#]
*M3/4
8f# 8d#L
16r
16f# 16BJ
4f# 4d#
4e# 4c##)
=
8f# 8d#L
16r
16f# 16BJ
4f# 4d#
4e# 4cn#)
=
*-
craigsapp commented 6 years ago

There is no current way of representing this case in **kern, or more precisely in the Humdrum-to-MEI converter.

This is a systematic accidental style that could be inferred from the **kern accidentals without any additional encoding. I could implement a parser that automatically calculates any necessary cancellation accidentals, but in general there will not be many such cases in the music. This particular case is more difficult to infer since the accidental is cautionary, with the cancellation being for a note in the previous measure. The easiest way for now would be to encode with a layout command as described below. I can do a more proper parsing of accidentals to generate a 19th-century syntax of cancellation naturals for such cases if there is need for it (modern editions would usually not display the natural before the sharp in such cases, so I have not done such a thing so far).

I have already developed the layout encoding for such cases, but not implemented it in the Humdrum-to-MEI converter yet. Here is an example from a 17th-century manuscript that is more extreme:

screen shot 2018-06-08 at 10 54 30 am

The music is in a bass clef and b-flat key signature, and the sharp is indicating a B-natural in modern notational syntax. I encode it like this:

**kern
*clefF4
*k[b-]
*LO:N:acc=#
1BBn
1C
1GG
4GG
4AA
2BB-y
*-

The note is encoded as sounding in **kern data, and then there is a layout command before the note that indicates that the visual accidental should be a sharp sign.

Likewise for your example, the layout command would be:

 !LO:N:acc=n#

Where the visual accidental would be a natural followed by a sharp.

In this case there is a complication of the note being in a chord. Typically this would be encoded as:

!LO:N:n=2:acc=n#
4e# 4c#

where n=2 means that the layout command is for the second note in the following token. But if you use the chord-tools, the accidental might get attached to the other note. If encoding the chord in the other direction:

!LO:N:n=1:acc=n#
4c# 4e#

If you want to make it more robust to shifting note order in chords, an RDF reference record could be developed, such as:

4e# 4cN#
!!!RDF**kern: N = cancellation accidental
craigsapp commented 6 years ago

The !LO:N:acc=n# method has been implemented:

screen shot 2018-06-08 at 3 40 57 pm
**kern
4f-- 4c##
!LO:N:acc=n-
2f-
!LO:N:n=2:acc=n#
4e# 4c#
*-

Your example, with the n removed from the c#:

screen shot 2018-06-08 at 3 44 38 pm

And the 17th-century example:

screen shot 2018-06-08 at 3 50 31 pm
**kern
*k[b-]
!LO:N:acc=#
1BB
1C
1GG
4GG
4AA
2BB-i
*-
!!!RDF**kern: i = editorial accidental