-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation for issue humdrum-tools/verovio-humdrum-viewer#840
- Loading branch information
Showing
3 changed files
with
91 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Sat Sep 23 22:51:29 PDT 2023 | ||
// Last Modified: Sun Sep 24 17:52:16 PDT 2023 | ||
// Filename: min/humlib.h | ||
// URL: https://github.com/craigsapp/humlib/blob/master/min/humlib.h | ||
// Syntax: C++11 | ||
|
@@ -7914,9 +7914,10 @@ class Tool_kern2mens : public HumTool { | |
bool run (HumdrumFile& infile, ostream& out); | ||
|
||
protected: | ||
void convertToMens (HumdrumFile& infile); | ||
string convertKernTokenToMens (HTp token); | ||
void printBarline (HumdrumFile& infile, int line); | ||
void convertToMens (HumdrumFile& infile); | ||
std::string convertKernTokenToMens(HTp token); | ||
void printBarline (HumdrumFile& infile, int line); | ||
std::string getClefConversion (HTp token); | ||
|
||
private: | ||
bool m_numbersQ = true; // used with -N option | ||
|
@@ -8344,6 +8345,7 @@ class Tool_mens2kern : public HumTool { | |
int brevis_def, int semibrevis_def); | ||
void getMensuralInfo (HTp token, int& maximodus, int& modus, | ||
int& tempus, int& prolatio); | ||
std::string getClefConversion(HTp token); | ||
|
||
private: | ||
bool m_debugQ; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Sat Sep 23 22:51:29 PDT 2023 | ||
// Last Modified: Sun Sep 24 17:52:16 PDT 2023 | ||
// Filename: min/humlib.cpp | ||
// URL: https://github.com/craigsapp/humlib/blob/master/min/humlib.cpp | ||
// Syntax: C++11 | ||
|
@@ -86326,6 +86326,9 @@ string Tool_kern2mens::convertKernTokenToMens(HTp token) { | |
data += m_clef; | ||
return data; | ||
} | ||
} else if (hre.search(token, "^\\*[mo]?clef")) { | ||
string value = getClefConversion(token); | ||
return value; | ||
} | ||
} | ||
if (!token->isData()) { | ||
|
@@ -86446,6 +86449,78 @@ void Tool_kern2mens::printBarline(HumdrumFile& infile, int line) { | |
|
||
|
||
|
||
////////////////////////////// | ||
// | ||
// Tool_kern2mens::getClefConversion -- | ||
// If token is *oclef and there is an adjacent *clef, | ||
// convert *oclef to *clef and *clef to *mclef; otherwise, | ||
// return the given clef. | ||
// | ||
// | ||
|
||
string Tool_kern2mens::getClefConversion(HTp token) { | ||
|
||
vector<HTp> clefs; | ||
vector<HTp> oclefs; | ||
vector<HTp> mclefs; | ||
|
||
HumRegex hre; | ||
|
||
HTp current = token->getNextToken(); | ||
while (current) { | ||
if (current->isData()) { | ||
break; | ||
} | ||
if (current->compare(0, 5, "*clef") == 0) { | ||
clefs.push_back(current); | ||
} | ||
if (current->compare(0, 6, "*oclef") == 0) { | ||
oclefs.push_back(current); | ||
} | ||
if (current->compare(0, 6, "*mclef") == 0) { | ||
mclefs.push_back(current); | ||
} | ||
current = current->getNextToken(); | ||
} | ||
|
||
current = token->getPreviousToken(); | ||
while (current) { | ||
if (current->isData()) { | ||
break; | ||
} | ||
if (current->compare(0, 5, "*clef") == 0) { | ||
clefs.push_back(current); | ||
} | ||
if (current->compare(0, 6, "*oclef") == 0) { | ||
oclefs.push_back(current); | ||
} | ||
if (current->compare(0, 6, "*mclef") == 0) { | ||
mclefs.push_back(current); | ||
} | ||
current = current->getPreviousToken(); | ||
} | ||
|
||
if (token->compare(0, 5, "*clef") == 0) { | ||
if (oclefs.size() > 0) { | ||
string value = *token; | ||
hre.replaceDestructive(value, "mclef", "clef"); | ||
return value; | ||
} | ||
} | ||
|
||
if (token->compare(0, 6, "*oclef") == 0) { | ||
if (clefs.size() > 0) { | ||
string value = *token; | ||
hre.replaceDestructive(value, "clef", "oclef"); | ||
return value; | ||
} | ||
} | ||
|
||
return *token; | ||
} | ||
|
||
|
||
|
||
|
||
///////////////////////////////// | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters