Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
craigsapp committed Oct 25, 2023
1 parent 9925244 commit 8609592
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 11 deletions.
5 changes: 4 additions & 1 deletion include/hum/humlib.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Sat Aug 8 12:24:49 PDT 2015
// Last Modified: Mon Oct 2 19:58:27 PDT 2023
// Last Modified: Tue Oct 3 17:45:18 PDT 2023
// Filename: min/humlib.h
// URL: https://github.com/craigsapp/humlib/blob/master/min/humlib.h
// Syntax: C++11
Expand Down Expand Up @@ -7949,13 +7949,16 @@ class Tool_kern2mens : public HumTool {
void storeKernEditorialAccidental(HumdrumFile& infile);
void storeKernTerminalLong (HumdrumFile& infile);
void addVerovioStyling (HumdrumFile& infile);
void analyzeColoration (HumdrumFile& infile);
void analyzeColoration (HTp infile);

private:
bool m_numbersQ = true; // used with -N option
bool m_measuresQ = true; // used with -M option
bool m_invisibleQ = true; // used with -I option
bool m_doublebarQ = true; // used with -D option
bool m_noverovioQ = false; // used with -V option
bool m_evenNoteSpacingQ = false; // used with -e option
std::string m_clef; // used with -c option

std::string m_kernEditorialAccidental; // used with !!!RDF**kern:
Expand Down
84 changes: 75 additions & 9 deletions src/hum/humlib.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Sat Aug 8 12:24:49 PDT 2015
// Last Modified: Mon Oct 2 19:58:27 PDT 2023
// Last Modified: Tue Oct 3 17:45:18 PDT 2023
// Filename: min/humlib.cpp
// URL: https://github.com/craigsapp/humlib/blob/master/min/humlib.cpp
// Syntax: C++11
Expand Down Expand Up @@ -86527,6 +86527,7 @@ Tool_kern2mens::Tool_kern2mens(void) {
define("D|no-double-bar=b", "keep thick final barlines");
define("c|clef=s", "clef to use in mensural notation");
define("V|no-verovio=b", "don't add verovio styling");
define("e|evenNoteSpacing|even-note-spacing=b", "add evenNoteSpacing option");
}


Expand Down Expand Up @@ -86574,6 +86575,7 @@ bool Tool_kern2mens::run(HumdrumFile& infile) {
m_doublebarQ = !getBoolean("no-double-bar");
m_noverovioQ = getBoolean("no-verovio");
m_clef = getString("clef");
m_evenNoteSpacingQ = getBoolean("even-note-spacing");
storeKernEditorialAccidental(infile);
storeKernTerminalLong(infile);
convertToMens(infile);
Expand All @@ -86588,6 +86590,7 @@ bool Tool_kern2mens::run(HumdrumFile& infile) {
//

void Tool_kern2mens::convertToMens(HumdrumFile& infile) {
analyzeColoration(infile);
int maxtrack = infile.getMaxTrack();
for (int i=0; i<infile.getLineCount(); i++) {
if (infile[i].isBarline()) {
Expand Down Expand Up @@ -86640,15 +86643,21 @@ void Tool_kern2mens::addVerovioStyling(HumdrumFile& infile) {
if (hre.search(token, "!!!verovio:\\s*evenNoteSpacing")) {
return;
}
if (hre.search(token, "!!!verovio:\\s*spacingLinear")) {
return;
}
if (hre.search(token, "!!!verovio:\\s*spacingNonLinear")) {
return;
if (!m_evenNoteSpacingQ) {
if (hre.search(token, "!!!verovio:\\s*spacingLinear")) {
return;
}
if (hre.search(token, "!!!verovio:\\s*spacingNonLinear")) {
return;
}
}
}
m_humdrum_text << "!!!verovio: spacingLinear 0.3\n";
m_humdrum_text << "!!!verovio: spacingNonLinear 0.5\n";
if (m_evenNoteSpacingQ) {
m_humdrum_text << "!!!verovio: evenNoteSpacing\n";
} else {
m_humdrum_text << "!!!verovio: spacingLinear 0.3\n";
m_humdrum_text << "!!!verovio: spacingNonLinear 0.5\n";
}
}


Expand Down Expand Up @@ -86705,7 +86714,10 @@ string Tool_kern2mens::convertKernTokenToMens(HTp token) {
if (rhythm.find('.') != std::string::npos) {
perfect = true;
}
hre.replaceDestructive(data, rhythm, "\\d+\\.*");
hre.replaceDestructive(data, rhythm, "\\d+%?\\d*\\.*");
hre.replaceDestructive(data, "S", "3\\%4");
hre.replaceDestructive(data, "s", "3\\%2");
hre.replaceDestructive(data, "M", "3");
hre.replaceDestructive(data, "X", "000");
hre.replaceDestructive(data, "L", "00");
hre.replaceDestructive(data, "S", "0");
Expand Down Expand Up @@ -86736,6 +86748,11 @@ string Tool_kern2mens::convertKernTokenToMens(HTp token) {
}
}

bool coloration = token->getValueBool("auto", "coloration");
if (coloration) {
data += "~";
}

return data;
}

Expand Down Expand Up @@ -86945,20 +86962,69 @@ void Tool_kern2mens::storeKernTerminalLong(HumdrumFile& infile) {
if (hre.search(value, "^\\s*([^\\s]+)\\s*=\\s*(.*)\\s*$")) {
string signifier = hre.getMatch(1);
string definition = hre.getMatch(2);

if (hre.search(definition, "terminal\\s+long")) {
m_kernTerminalLong = signifier;
m_kernTerminalLongIndex = i;
m_mensTerminalLongLine = "!!!RDF**mens: " + signifier + " = ";
m_mensTerminalLongLine += definition;
break;
} else if (hre.search(definition, "long\\s+note")) {
m_kernTerminalLong = signifier;
m_kernTerminalLongIndex = i;
m_mensTerminalLongLine = "!!!RDF**mens: " + signifier + " = ";
m_mensTerminalLongLine += definition;
break;
}

}
}
}



//////////////////////////////
//
// Tool_kern2mens::analyzeColoration --
//

void Tool_kern2mens::analyzeColoration(HumdrumFile& infile) {
vector<HTp> spinestarts = infile.getKernSpineStartList();
for (int i=0; i<(int)spinestarts.size(); i++) {
analyzeColoration(spinestarts[i]);
}
}

void Tool_kern2mens::analyzeColoration(HTp stok) {
HTp current = stok->getNextToken();
bool coloration = false;
while (current) {
if (current->isInterpretation()) {
if (*current == "*col") {
coloration = true;
} else if (*current == "*Xcol") {
coloration = false;
}
}
if (!current->isData()) {
current = current->getNextToken();
continue;
}
if (current->isNull()) {
current = current->getNextToken();
continue;
}
if (coloration) {
current->setValue("auto", "coloration", 1);
}
current = current->getNextToken();
}
}





/////////////////////////////////
//
// Tool_kernify::Tool_kernify -- Set the recognized options for the tool.
Expand Down
6 changes: 5 additions & 1 deletion src/iohumdrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16615,7 +16615,11 @@ void HumdrumInput::processDynamics(hum::HTp token, int staffindex)
}
else {
forceBelowQ = true;
staffadj2 = 1;
// Don't know what the following adjustment is for.
// Probably for two-staff parts? If so then have
// separate cases for single/double staff parts.
// Similar case below search for "What is this here".
// staffadj2 = 1;
}
}

Expand Down

0 comments on commit 8609592

Please sign in to comment.