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

Clean up accidentals #27

Open
bel28kent opened this issue Aug 19, 2023 · 8 comments
Open

Clean up accidentals #27

bel28kent opened this issue Aug 19, 2023 · 8 comments

Comments

@bel28kent
Copy link
Owner

It would be good at some point to clean up unnecessary n and X on accidentals in the files; there are many, probably artifacts of encoding in Finale.

@bel28kent
Copy link
Owner Author

bel28kent commented Sep 21, 2023

One option is to strip all n and X followed by a round of manually adding only the cautionary accidentals from the reference editions.

@bel28kent
Copy link
Owner Author

bel28kent commented Apr 9, 2024

Rules:

  1. Any note that is #, -, ##, --, must have that accidental.
  2. A natural note that is in the key AND is not the first natural note to follow a chromatic alteration does not use n.
  3. The note that is the first to follow a chromatic alteration must have a cautionary accidental IF it returns to the diatonic note AND the diatonic note and the chromatic alteration that it follows are in the same measure.
  • Case I: A natural note has been made #, -, ##, --, and returned to natural, add n.
  • Case II: A #, -, ##, --, note has been made natural and returned to #, -, ##, --, add X.
  • Case III: A #, -, ##, --, note has been made one of #, -, ##, --, (not including the accidental it started with), and return to #, -, ##, --, add X.
  1. No note should have an n or X except as a result of 3.

Examples

Screen Shot 2024-04-09 at 9 09 56 AM
**kern	**kern	**kern	**kern
4f#	4f-	4f##	4f--
Screen Shot 2024-04-09 at 9 13 19 AM
**kern
*k[f#]
*G:
4e
  1. Case I.
Screen Shot 2024-04-09 at 9 33 31 AM
**kern	**kern	**kern	**kern
*k[f#]	*k[f#]	*k[f#]	*k[f#]
*G:	*G:	*G:	*G:
*M3/4	*M3/4	*M3/4	*M3/4
4e	4e	4e	4e
4e#	4e-	4e##	4e--
4en	4en	4en	4en

Case II.
Screen Shot 2024-04-09 at 9 50 23 AM

**kern	**kern	**kern	**kern
!! *M3/4
4f#	4f-	4f##	4f--
4f	4f	4f	4f
4f#X	4f-X	4f##X	4f--X

Case III.
Screen Shot 2024-04-09 at 9 54 44 AM

**kern
*M3/4
4e#
4e-
4e#X

@craigsapp
Copy link
Contributor

It would be good at some point to clean up unnecessary n and X on accidentals in the files; there are many, probably artifacts of encoding in Finale.

Yes, I keep the information in the MusicXML that is converted to Humdrum.

The X marker means that the accidental should be visible in the notation. MusicXML does not distinguish between two separate categories of visual accidentals: one case where the visual accidental is controlled by barlines and previous accidentals for the same diatonic note, the other are cautionary/courtesy accidentals where the accidental is not stricty required, but to some degree it is required in modern editorial standards, or is added by the editor to clarify or remind the perform about what accidental should be applied to the note.

Screenshot 2024-04-09 at 9 55 07 AM

[Vew in VHV]

**kern
*k[f#]
=
1fn
=
1f#
*-

The second measure is expected to have a cautionary accidental on the F, and removing it would cause readability problems for performance. Default modern interpretation of this note is that it should be F# (and in kern data notice that it is encoded as an F#, but the sharp does not explicitly need to be added. But standard style is to display a cautionary accidental:

Screenshot 2024-04-09 at 9 58 21 AM

[View in VHV]

X after an accidental forces it to be displayed. n is a special case, where I treat n and nX as equivalent, since f and fn are both F-natural, but there are no dualities for other accidentals (f# is the only way to express f# with undetermined accidental display.

When converting from Finale, there is no concept of a courtesy/cautionary accidental, so I keep all explicit accidental displays (by prefixing with X). (and hidden accidentals with y).

I would recommend keeping cautionary/courtesy accidentals and only remove X when the accidental is non-cautionary (and will be hidden or shown based on modern accidental display).

I do have a VHV filter (humlib command line tool) called autoaccid which might do this (I will have to review the -c option which is probably what you want):

https://doc.verovio.humdrum.org/filter/autoaccid

(or you can check it out and see if it does what you want and/or we could figure out how to add an option to do what you want).

I should also add a feature to VHV to highlight cautionary accidentals, which you can then decide if you want to keep or not. In general if you are doing a diplomatic edition, cautionary accidentals should be kept, and in general they facilitate performance since some cautionary accidentals are required (as above), and some would be recommended to confirm that there is not a typo in the score (functioning as a sic for the accidental).

When I convert from Humdrum to MEI, I mark all cautionary accidentals (following modern accidental display conventions, which are not always the same for older music). For example the following MEI data from the second example at the top:

Click to view MEI data for second example
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/5.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/5.0/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">
 <meiHead>
  <fileDesc>
   <titleStmt>
    <title />
   </titleStmt>
   <pubStmt>
    <unpub>This MEI file was created by Verovio's Humdrum converter. When published, this unpub element should be removed, and the enclosing pubStmt element should be properly filled out.</unpub>
   </pubStmt>
  </fileDesc>
  <encodingDesc>
   <appInfo>
    <application isodate="2024-04-09T10:00:31" version="4.2.0-dev-84f99b0-dirty">
     <name>Verovio</name>
     <p>Transcoded from Humdrum</p>
    </application>
   </appInfo>
  </encodingDesc>
  <extMeta>
   <frames xmlns="http://www.humdrum.org/ns/humxml" />
  </extMeta>
 </meiHead>
 <music decls="#work1_encoded">
  <body>
   <mdiv xml:id="mr7gzip">
    <score xml:id="s28vxwa">
     <scoreDef xml:id="s1csmqmu" midi.bpm="400.000000">
      <staffGrp xml:id="s1g0jemm">
       <staffDef xml:id="staffdef-L1F1" n="1" lines="5">
        <clef xml:id="cw0r7zm" shape="G" line="2" />
        <keySig xml:id="keysig-L2F1" sig="1s" />
       </staffDef>
      </staffGrp>
     </scoreDef>
     <section xml:id="section-L1F1">
      <measure xml:id="measure-L1">
       <staff xml:id="staff-L1F1" n="1">
        <layer xml:id="layer-L1F1N1" n="1">
         <note xml:id="note-L4F1" dur="1" oct="4" pname="f" accid="n" />
        </layer>
       </staff>
      </measure>
      <measure xml:id="measure-L5" right="invis">
       <staff xml:id="staff-L5F1N1" n="1">
        <layer xml:id="layer-L5F1N1" n="1">
         <note xml:id="note-L6F1" dur="1" oct="4" pname="f">
          <accid xml:id="accid-L6F1" accid="s" func="caution" />
         </note>
        </layer>
       </staff>
      </measure>
     </section>
    </score>
   </mdiv>
  </body>
 </music>
</mei>

The accidental for the second note in the example:

<note xml:id="note-L6F1" dur="1" oct="4" pname="f">
       <accid xml:id="accid-L6F1" accid="s" func="caution" />
</note>

The @func="caution" marks the note as cautionary.

Currently the conversion to SVG graphical notation drops this, and I need to add @type="caution" or change @func="caution" to preserve this information in the SVG, which will allow in turn allow cautionary accidentals to be highlighted in VHV (in a manner similar to layers that can be highlighted with the alt/option-l (lowercase L) keyboard command.

@bel28kent
Copy link
Owner Author

Yes, I want to preserve the cautionary accidentals and conduct a diplomatic encoding. This means all accidentals that are in the reference edition should be explicitly encoded in the kern file and render correctly in VHV.

The problem that I have encountered is that there are many n and X in the files that are not necessary for VHV and are redundant in the kern files. I believe that these are artifacts of encoding from Finale. Finale does not automatically add accidentals according to the key signature or previous notes in the measure; the user must manually add all of them. I think this also resulted in adding cautionary accidentals that aren't necessary.

I will add some pseudocode later that clarifies the procedure I have in mind.

@bel28kent
Copy link
Owner Author

/*
 * let Spine[] = List<Token>
 * let Measure[] = List<Token>
 * let Spines[][] = List<Spine>
 * let Measures[][] = List<Measure>
 * let KeySignature[] = List<String>
 */
// UNDERSPECIFIED: how to handle stops and subspines
addCautionaryAccidentals(Spines[][])
    keySignature[] = getKeySignature
    timeSignature = getTimeSignature
    for (Spine s[] : Spines)
        cleanSpine[] = removeExistingCautionaryAccidentals
        measures[][] = getMeasureSlices(cleanSpine)
        for (Measure m[] : measures)
            for (1, < m.size, ++)
                accidental = getAccidental
                previousNoteOnThisLineOrSpace = getPreviousNote
                (and (is-diatonic? m[i]) (is-chromatic? previousNote)) ? addCautionaryAccidental : next
END

@bel28kent
Copy link
Owner Author

One reason for the extra accidentals in the rendering seems to be a VHV issue. When accidentals appear first on grace notes and then on regular notes, VHV renders the accidentals on both, even if there is no cautionary signifier on the latter.

Screen Shot 2024-04-28 at 2 52 00 PM
!!!COM: Scriabin, Alexander
!!!OTL@@FR: Sonate no 7
!!!OTL@@EN: Sonata No. 7
!!!OPS: 64
!!!ODT: 1911–1912
!!!AGN: Sonata
**kern	**dynam	**kern	**dynam
*clefF4	*	*clefG2	*
*k[]	*	*k[]	*
*M6/8	*	*M6/8	*
=44	=44	=44	=44
*^	*	*^	*
.	.	.	.	16qf#LL	.
.	.	.	.	16qa#	.
.	.	.	.	16qb#	.
8qDD#X 8qGG#X	.	.	.	16qcc##JJ	.
80%3B#XLL	4r	.	40%3f#L 40%3a#	[4.ee#X	.
80%3F#XJ	.	.	.	.	.
40%3r	.	.	40%3cc##	.	.
80%3GG#L	.	.	40%3b#	.	.
80%3DD#JJ	.	.	.	.	.
40%3r	.	.	40%3a#	.	.
.	8r	.	.	.	.
40%3r	.	.	40%3f#J	.	.
[8qGG# [8qC##X	.	.	.	.	.
8GG#] 8C##]	40%3e#XL	.	4.f# 4.an	4ee#]	.
.	40%3c##X	.	.	.	.
8r	.	.	.	.	.
.	40%3B#	.	.	.	.
.	40%3A	.	.	.	.
8r	.	.	.	8cc##	.
.	40%3F#J	.	.	.	.
*	*	*	*v	*v	*
*v	*v	*	*	*
=	=	=	=
*-	*-	*-	*-
!!!system-decoration: {(*)}
!!!filter: flipper -a
!!!RDF**kern: > = above
!!!ENC: Bryan Jacob Bell
!!!END: November 2021 to April 2022
!!!PED: Günter Philipp
!!!PTL: Ausgewählte Klavierwerke (Edition Peters)

@craigsapp
Copy link
Contributor

This is related to Behind Bars by Elaine Gould, page 84:

Screenshot 2024-04-29 at 9 21 13 AM

When I convert to graphical music, the visualness of accidentals are calculated automatically (and y and X are used to override the automatic decisions). The algorithm automatically adds a cautionary accidental to regular notes that are followed in the measure by an altered gracenote.

If you do not want that automatically assigned visualness to the following regular note, add y after the accidental. I don't have an "almost immediately" check to suppress the cautionary accidental, as your example falls under, and it is safer to have a predictable algorithm than one that tries to guess whether a following note is almost immediate, which can be a subjective decision (which computers are bad at).

When going the other way from an altered regular note to a grace note, I do not add cautionary accidentals (second case in the example above, where cautionary accidentals are not necessary).

@bel28kent
Copy link
Owner Author

Okay. The grace note problem is something that can be scripted. I will deal with it at the very end when I deal with accidentals.

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

2 participants