Skip to content

Commit

Permalink
Restyle melodic approach style of **deg processing in the Humdrum-to-…
Browse files Browse the repository at this point in the history
…MEI converter.
  • Loading branch information
craigsapp committed Dec 29, 2022
1 parent 3bfd2b2 commit 025746b
Showing 1 changed file with 46 additions and 18 deletions.
64 changes: 46 additions & 18 deletions src/iohumdrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7926,6 +7926,9 @@ void HumdrumInput::addHarmFloatsForMeasure(int startline, int endline)
}

std::u32string content;
std::u32string precontent;
bool updirQ = false;
bool downdirQ = false;
if (datatype == "**harm") {
setPlaceRelStaff(harm, "below", false);
content = cleanHarmString2(*token);
Expand All @@ -7937,14 +7940,51 @@ void HumdrumInput::addHarmFloatsForMeasure(int startline, int endline)
else if (isDegree) {
setPlaceRelStaff(harm, "below", false);
content = cleanDegreeString(token);
int dirQ = !token->getValueInt("auto", "Xdir");
if (dirQ) {
// note: token is presumend to not be a chord.
if (token->find('^') != std::string::npos) {
// precontent = U"\u2191"; // up arrow
precontent = U"\u21D7"; // double up diagonal arrow
// precontent = U"\u2B08"; // thick up diagonal arrow
updirQ = true;
}
else if (token->find('v') != std::string::npos) {
// precontent = U"\u2193"; // down arrow
precontent = U"\u21D8"; // double down arrow
// precontent = U"\u2B0A"; // thick down diagonal arrow
downdirQ = true;
}
}
}
else if (isCData) {
content = UTF8to32(*token);
}
else {
content = cleanHarmString(*token);
}

text->SetText(content);
if (isDegree && (updirQ || downdirQ) && !precontent.empty()) {
Rend *prerend = new Rend();
Text *pretext = new Text();
prerend->AddChild(pretext);
pretext->SetText(precontent);
if (updirQ) {
prerend->SetRend(TEXTRENDITION_sub);
}
else if (downdirQ) {
prerend->SetRend(TEXTRENDITION_sup);
}
if (rend) {
rend->InsertChild(prerend, 0);
prerend->SetParent(rend);
}
else {
harm->InsertChild(prerend, 0);
prerend->SetParent(harm);
}
}

hum::HumNum tstamp = getMeasureTstamp(token, xstaffindex);
harm->SetTstamp(tstamp.getFloat());
Expand Down Expand Up @@ -8360,18 +8400,7 @@ std::u32string HumdrumInput::cleanDegreeString(hum::HTp token, int n)

std::u32string output;

int dirQ = !token->getValueInt("auto", "Xdir");

if (dirQ) {
if (temp.find('^') != std::string::npos) {
output += U"\u2191"; // up arrow
}
else if (temp.find('v') != std::string::npos) {
output += U"\u2193"; // down arrow
}
}

bool solfege = token->getValueInt("auto", "solf");
bool solfegeQ = token->getValueInt("auto", "solf");

hum::HumRegex hre;
if (hre.search(temp, "(\\d+)")) {
Expand All @@ -8381,7 +8410,7 @@ std::u32string HumdrumInput::cleanDegreeString(hum::HTp token, int n)
if (flats) {
semitones = -flats;
}
if (solfege) {
if (solfegeQ) {
output += getMoveableDoName(degree, semitones, minor);
}
else {
Expand All @@ -8405,16 +8434,14 @@ std::u32string HumdrumInput::cleanDegreeString(hum::HTp token, int n)
int accidQ = !token->getValueInt("auto", "nodegacc");

// Add semitone adjustments
if (accidQ) {
if (solfege) {
// do nothing
}
else if (sharps > 0) {
if (accidQ && !solfegeQ) {
if (sharps > 0) {
if (sharps == 1) {
output += U"\u2191"; // up arrow
}
else if (sharps == 2) {
output += U"\u21D1"; // double up arrow
// output += U"\u21C8"; // double up arrow
}
else {
for (int i = 0; i < sharps; i++) {
Expand All @@ -8428,6 +8455,7 @@ std::u32string HumdrumInput::cleanDegreeString(hum::HTp token, int n)
}
else if (flats == 2) {
output += U"\u21D3"; // double down arrow
// output += U"\u21CA"; // double down arrow
}
else {
for (int i = 0; i < flats; i++) {
Expand Down

1 comment on commit 025746b

@craigsapp
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit changes the style of melodic approach arrows in the Humdrum-to-MEI converter. Previously they were displayed as up/down arrows before the degree number. Chromatic alterations now use up/down arrows after the degree, so using up/down arrows for melodic approach is too confusing to read.

Chromatic alterations still come before the degree number, but now they are both sub/sup rendered as well as displayed as a diagonal arrow pointing up/down. This helps to separate visually from the chromatic alteration arrows.

Example:

Screen Shot 2022-12-28 at 10 06 11 PM

Humdrum data:

**kern	**deg
*clefG2	*color:crimson
*M4/4	*hat
*C:	*C:
=1	=1
!!LO:TX:a:t=*dir:color=crimson
4c	1
4e	^3
4g	^5
4cc	^1
=2	=2
4b--	v7--
4g-	v5-
4d#	v2+
4c	v1
=3||	=3||
*	*Xdir
*	*Xhat
*	*circle
*	*above
!!LO:TX:b:t=*Xdir:color=crimson
4c	1
4e	^3
4g	^5
4cc	^1
=4	=4
4b--	v7--
4g-	v5-
4d#	v2+
4c	v1
==	==
*-	*-
Click to view MEI conversion for above Humdrum data
<?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 />
   </titleStmt>
   <pubStmt />
  </fileDesc>
  <encodingDesc>
   <appInfo>
    <application isodate="2022-12-28T22:06:16" version="3.15.0-dev-3a49fbf">
     <name>Verovio</name>
     <p>Transcoded from Humdrum</p>
    </application>
   </appInfo>
  </encodingDesc>
  <workList>
   <work>
    <title />
   </work>
  </workList>
 </meiHead>
 <music>
  <body>
   <mdiv xml:id="m55pcbv">
    <score xml:id="s13qy3yc">
     <scoreDef xml:id="s4pahba">
      <staffGrp xml:id="s1bvz5a9">
       <staffDef xml:id="staffdef-L1F1" n="1" lines="5">
        <clef xml:id="clef-L2F1" shape="G" line="2" />
        <meterSig xml:id="metersig-L3F1" count="4" unit="4" />
       </staffDef>
      </staffGrp>
     </scoreDef>
     <section xml:id="section-L1F1">
      <measure xml:id="measure-L1" n="1">
       <staff xml:id="staff-L1F1" n="1">
        <layer xml:id="layer-L1F1N1" n="1">
         <note xml:id="note-L7F1" dur="4" oct="4" pname="c" accid.ges="n" />
         <note xml:id="note-L8F1" dur="4" oct="4" pname="e" accid.ges="n" />
         <note xml:id="note-L9F1" dur="4" oct="4" pname="g" accid.ges="n" />
         <note xml:id="note-L10F1" dur="4" oct="5" pname="c" accid.ges="n" />
        </layer>
       </staff>
       <dir xml:id="dir-L6F1" place="above" staff="1" tstamp="1.000000">
        <rend xml:id="rlnrppx" color="crimson" fontstyle="normal">*dir</rend>
       </dir>
       <harm xml:id="harm-L7F2" type="deg" place="below" staff="1" tstamp="1.000000" n="2">
        <rend xml:id="rnfh5bi" color="crimson">1̂</rend>
       </harm>
       <harm xml:id="harm-L8F2" type="deg" place="below" staff="1" tstamp="2.000000" n="2">
        <rend xml:id="r1hmcvmv" color="crimson">
         <rend xml:id="rzm862y" rend="sub">⇗</rend>3̂</rend>
       </harm>
       <harm xml:id="harm-L9F2" type="deg" place="below" staff="1" tstamp="3.000000" n="2">
        <rend xml:id="rfxo83w" color="crimson">
         <rend xml:id="r5nj8hu" rend="sub">⇗</rend>5̂</rend>
       </harm>
       <harm xml:id="harm-L10F2" type="deg" place="below" staff="1" tstamp="4.000000" n="2">
        <rend xml:id="rs35iob" color="crimson">
         <rend xml:id="rbc7y4v" rend="sub">⇗</rend>1̂</rend>
       </harm>
      </measure>
      <measure xml:id="measure-L11" right="dbl" n="2">
       <staff xml:id="staff-L11F1N1" n="1">
        <layer xml:id="layer-L11F1N1" n="1">
         <note xml:id="note-L12F1" dur="4" oct="4" pname="b" accid="ff" />
         <note xml:id="note-L13F1" dur="4" oct="4" pname="g" accid="f" />
         <note xml:id="note-L14F1" dur="4" oct="4" pname="d" accid="s" />
         <note xml:id="note-L15F1" dur="4" oct="4" pname="c" accid.ges="n" />
        </layer>
       </staff>
       <harm xml:id="harm-L12F2" type="deg" place="below" staff="1" tstamp="1.000000" n="2">
        <rend xml:id="rmnudef" color="crimson">
         <rend xml:id="rvoqacx" rend="sup">⇘</rend>7̂⇓</rend>
       </harm>
       <harm xml:id="harm-L13F2" type="deg" place="below" staff="1" tstamp="2.000000" n="2">
        <rend xml:id="r13jmpza" color="crimson">
         <rend xml:id="r1urxhba" rend="sup">⇘</rend>5̂↓</rend>
       </harm>
       <harm xml:id="harm-L14F2" type="deg" place="below" staff="1" tstamp="3.000000" n="2">
        <rend xml:id="r6aq5qn" color="crimson">
         <rend xml:id="rb28pwf" rend="sup">⇘</rend>2̂↑</rend>
       </harm>
       <harm xml:id="harm-L15F2" type="deg" place="below" staff="1" tstamp="4.000000" n="2">
        <rend xml:id="rosg4jb" color="crimson">
         <rend xml:id="r1rwzosk" rend="sup">⇘</rend>1̂</rend>
       </harm>
      </measure>
      <measure xml:id="measure-L16" n="3">
       <staff xml:id="staff-L16F1N1" n="1">
        <layer xml:id="layer-L16F1N1" n="1">
         <note xml:id="note-L22F1" dur="4" oct="4" pname="c" accid.ges="n" />
         <note xml:id="note-L23F1" dur="4" oct="4" pname="e" accid.ges="n" />
         <note xml:id="note-L24F1" dur="4" oct="4" pname="g" accid.ges="n" />
         <note xml:id="note-L25F1" dur="4" oct="5" pname="c" accid.ges="n" />
        </layer>
       </staff>
       <dir xml:id="dir-L21F1" place="below" staff="1" tstamp="1.000000">
        <rend xml:id="r16z3ql0" color="crimson" fontstyle="normal">*Xdir</rend>
       </dir>
       <harm xml:id="harm-L22F2" type="deg" place="above" staff="1" tstamp="1.000000" n="2">
        <rend xml:id="r12p0xdp" color="crimson" rend="circle">1</rend>
       </harm>
       <harm xml:id="harm-L23F2" type="deg" place="above" staff="1" tstamp="2.000000" n="2">
        <rend xml:id="ra7fayl" color="crimson" rend="circle">3</rend>
       </harm>
       <harm xml:id="harm-L24F2" type="deg" place="above" staff="1" tstamp="3.000000" n="2">
        <rend xml:id="r1voefvr" color="crimson" rend="circle">5</rend>
       </harm>
       <harm xml:id="harm-L25F2" type="deg" place="above" staff="1" tstamp="4.000000" n="2">
        <rend xml:id="r1nk2w4n" color="crimson" rend="circle">1</rend>
       </harm>
      </measure>
      <measure xml:id="measure-L26" right="end" n="4">
       <staff xml:id="staff-L26F1N1" n="1">
        <layer xml:id="layer-L26F1N1" n="1">
         <note xml:id="note-L27F1" dur="4" oct="4" pname="b" accid="ff" />
         <note xml:id="note-L28F1" dur="4" oct="4" pname="g" accid="f" />
         <note xml:id="note-L29F1" dur="4" oct="4" pname="d" accid="s" />
         <note xml:id="note-L30F1" dur="4" oct="4" pname="c" accid.ges="n" />
        </layer>
       </staff>
       <harm xml:id="harm-L27F2" type="deg" place="above" staff="1" tstamp="1.000000" n="2">
        <rend xml:id="r387ylv" color="crimson" rend="circle">7⇓</rend>
       </harm>
       <harm xml:id="harm-L28F2" type="deg" place="above" staff="1" tstamp="2.000000" n="2">
        <rend xml:id="r1q729o9" color="crimson" rend="circle">5↓</rend>
       </harm>
       <harm xml:id="harm-L29F2" type="deg" place="above" staff="1" tstamp="3.000000" n="2">
        <rend xml:id="rqvcv1c" color="crimson" rend="circle">2↑</rend>
       </harm>
       <harm xml:id="harm-L30F2" type="deg" place="above" staff="1" tstamp="4.000000" n="2">
        <rend xml:id="r1gtyd3r" color="crimson" rend="circle">1</rend>
       </harm>
      </measure>
     </section>
    </score>
   </mdiv>
  </body>
 </music>
</mei>

Subscript and superscript up/down arrows for melodic approach were tried. They look decent, but the above rendering is more readable. Single tail diagonal arrows were tried, but they do not have the exact same thickness (in the default text font for the SVG when displaying in MacOS) which was distracting. I also tried "bold" diagonal arrows, but those were too prominent.

In the future when there is a clone of the deg command in humlib, perhaps single-tail diagonal arrows can represent approach by step (^ and v), while approach by leap (^^ and vv) can be displayed with the double tails as in the example.

Note that melodic approaches are displayed by default, and to turn them off, add the *Xdir interpretation (or do not encode melodic approach in the **deg data). The second measure of the above example demonstrates suppressing their display with *Xdir.

Note that drawing circles around the superscript/subscript arrows does not produce good results (which is why I did not circle them in the above example).

Please sign in to comment.