-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from WolfgangDrescher/deg
Implement --solfege option for deg tool
- Loading branch information
Showing
4 changed files
with
190 additions
and
28 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: Tue Jan 17 21:33:56 PST 2023 | ||
// Last Modified: Fr 20 Jan 2023 00:01:35 CET | ||
// Filename: humlib.h | ||
// URL: https://github.com/craigsapp/humlib/blob/master/include/humlib.h | ||
// Syntax: C++11 | ||
|
@@ -6736,13 +6736,15 @@ class Tool_deg : public HumTool { | |
bool isDegCircleLine (HumdrumFile& infile, int lineIndex); | ||
bool isDegColorLine (HumdrumFile& infile, int lineIndex); | ||
bool isDegHatLine (HumdrumFile& infile, int lineIndex); | ||
bool isDegSolfegeLine (HumdrumFile& infile, int lineIndex); | ||
bool isKeyDesignationLine (HumdrumFile& infile, int lineIndex); | ||
|
||
void checkAboveStatus (string& value, bool arrowStatus); | ||
void checkArrowStatus (string& value, bool arrowStatus); | ||
void checkCircleStatus (string& value, bool arrowStatus); | ||
void checkColorStatus (string& value, bool arrowStatus); | ||
void checkHatStatus (string& value, bool arrowStatus); | ||
void checkSolfegeStatus (string& value, bool arrowStatus); | ||
|
||
void checkKeyDesignationStatus(string& value, int keyDesignationStatus); | ||
|
||
|
@@ -6783,6 +6785,7 @@ class Tool_deg : public HumTool { | |
bool m_hatQ = false; // used with --hat option | ||
bool m_colorQ = false; // used with --color option | ||
std::string m_color; // used with --color option | ||
bool m_solfegeQ = false; // used with --solfege option | ||
|
||
bool m_degOnlyQ = false; // used with -I option | ||
bool m_recipQ = false; // used with -r option | ||
|
@@ -6808,6 +6811,7 @@ class Tool_deg : public HumTool { | |
bool foundColorLine; | ||
bool foundHatLine; | ||
bool foundKeyDesignationLine; | ||
bool foundSolfegeLine; | ||
|
||
InterleavedPrintVariables(void) { clear(); } | ||
void clear(void) { | ||
|
@@ -6819,6 +6823,7 @@ class Tool_deg : public HumTool { | |
foundColorLine = false; | ||
foundHatLine = false; | ||
foundKeyDesignationLine = false; | ||
foundSolfegeLine = false; | ||
} | ||
}; | ||
InterleavedPrintVariables m_ipv; | ||
|
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
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: Tue Jan 17 21:33:56 PST 2023 | ||
// Last Modified: Fr 20 Jan 2023 00:01:35 CET | ||
// Filename: /include/humlib.cpp | ||
// URL: https://github.com/craigsapp/humlib/blob/master/src/humlib.cpp | ||
// Syntax: C++11 | ||
|
@@ -68933,10 +68933,11 @@ string Tool_deg::ScaleDegree::m_forcedKey = ""; | |
Tool_deg::Tool_deg(void) { | ||
define("above=b", "Display scale degrees above analyzed staff"); | ||
define("arr|arrow|arrows=b", "Display scale degree alterations as arrows"); | ||
define("b|boxes|box=b", "Display scale degrees in boxes"); | ||
define("color=s", "Display color for scale degrees"); | ||
define("c|circ|circles|circle=b", "Display scale degrees in circles"); | ||
define("hat|caret|circumflex=b", "Display hats on scale degrees"); | ||
define("b|boxes|box=b", "Display scale degrees in boxes"); | ||
define("color=s", "Display color for scale degrees"); | ||
define("c|circ|circles|circle=b", "Display scale degrees in circles"); | ||
define("hat|caret|circumflex=b", "Display hats on scale degrees"); | ||
define("solf|solfege=b", "Display (relative) solfege syllables instead of scale degree numbers"); | ||
define("I|no-input=b", "Do not interleave **deg data with input score in output"); | ||
define("kern=b", "Prefix composite rhythm **kern spine with -I option"); | ||
define("k|kern-tracks=s", "Process only the specified kern spines"); | ||
|
@@ -69008,6 +69009,7 @@ void Tool_deg::initialize(void) { | |
m_circleQ = getBoolean("circle"); | ||
m_colorQ = getBoolean("color"); | ||
m_hatQ = getBoolean("hat"); | ||
m_solfegeQ = getBoolean("solfege"); | ||
|
||
if (m_colorQ) { | ||
m_color = getString("color"); | ||
|
@@ -69217,6 +69219,7 @@ string Tool_deg::createOutputHumdrumLine(HumdrumFile& infile, int lineIndex) { | |
bool colorStatus = false; | ||
bool hatStatus = false; | ||
bool keyDesignationStatus = false; | ||
bool solfegeStatus = false; | ||
|
||
// Keep track of an existing styling line and if such a line is found, | ||
// then insert a styling interpretation for the new **deg spines here | ||
|
@@ -69243,6 +69246,9 @@ string Tool_deg::createOutputHumdrumLine(HumdrumFile& infile, int lineIndex) { | |
if (m_hatQ && !m_ipv.foundHatLine) { | ||
hatStatus = isDegHatLine(infile, lineIndex); | ||
} | ||
if (m_solfegeQ && !m_ipv.foundSolfegeLine) { | ||
solfegeStatus = isDegSolfegeLine(infile, lineIndex); | ||
} | ||
} | ||
|
||
// spineData: The output Humdrum data line stored in a 2D vector. | ||
|
@@ -69281,6 +69287,7 @@ string Tool_deg::createOutputHumdrumLine(HumdrumFile& infile, int lineIndex) { | |
checkCircleStatus(value, circleStatus); | ||
checkColorStatus(value, colorStatus); | ||
checkHatStatus(value, hatStatus); | ||
checkSolfegeStatus(value, hatStatus); | ||
spineData.back().push_back(value); | ||
if (value == "*v") { | ||
hasDegMerger = true; | ||
|
@@ -69307,6 +69314,7 @@ string Tool_deg::createOutputHumdrumLine(HumdrumFile& infile, int lineIndex) { | |
checkCircleStatus(value, circleStatus); | ||
checkColorStatus(value, colorStatus); | ||
checkHatStatus(value, hatStatus); | ||
checkSolfegeStatus(value, hatStatus); | ||
spineData.back().push_back(value); | ||
if (value == "*v") { | ||
hasDegMerger = true; | ||
|
@@ -69336,6 +69344,9 @@ string Tool_deg::createOutputHumdrumLine(HumdrumFile& infile, int lineIndex) { | |
if (hatStatus) { | ||
m_ipv.foundHatLine = true; | ||
} | ||
if (solfegeStatus) { | ||
m_ipv.foundSolfegeLine = true; | ||
} | ||
|
||
|
||
// if styling interpretation lines were not found before the data, | ||
|
@@ -69393,6 +69404,15 @@ string Tool_deg::createOutputHumdrumLine(HumdrumFile& infile, int lineIndex) { | |
} | ||
} | ||
|
||
if (!m_ipv.foundSolfegeLine) { | ||
if (m_solfegeQ && !m_ipv.foundSolfegeLine) { | ||
string line = printDegInterpretation("*solf", infile, lineIndex); | ||
if (!line.empty()) { | ||
extraLines.push_back(line); | ||
} | ||
} | ||
} | ||
|
||
if (!m_ipv.foundKeyDesignationLine) { | ||
if (!m_defaultKey.empty() && !m_ipv.foundKeyDesignationLine) { | ||
string line = printDegInterpretation(m_defaultKey, infile, lineIndex); | ||
|
@@ -69468,7 +69488,7 @@ void Tool_deg::checkKeyDesignationStatus(string& value, int keyDesignationStatus | |
|
||
////////////////////////////// | ||
// | ||
// Tool_deg::checkAboveStatus -- Add *arr interpretation to spine if needed. | ||
// Tool_deg::checkAboveStatus -- Add *above interpretation to spine if needed. | ||
// | ||
|
||
void Tool_deg::checkAboveStatus(string& value, bool aboveStatus) { | ||
|
@@ -69512,7 +69532,7 @@ void Tool_deg::checkCircleStatus(string& value, bool circleStatus) { | |
|
||
////////////////////////////// | ||
// | ||
// Tool_deg::checkColorStatus -- Add *arr interpretation to spine if needed. | ||
// Tool_deg::checkColorStatus -- Add *color interpretation to spine if needed. | ||
// | ||
|
||
void Tool_deg::checkColorStatus(string& value, bool colorStatus) { | ||
|
@@ -69540,6 +69560,21 @@ void Tool_deg::checkHatStatus(string& value, bool hatStatus) { | |
|
||
|
||
|
||
////////////////////////////// | ||
// | ||
// Tool_deg::checkSolfegeStatus -- Add *solfege interpretation to spine if needed. | ||
// | ||
|
||
void Tool_deg::checkSolfegeStatus(string& value, bool hatStatus) { | ||
if (hatStatus && m_solfegeQ && (!m_ipv.foundSolfegeLine) && (!m_ipv.foundData)) { | ||
if (value == "*") { | ||
value = "*solf"; | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
////////////////////////////// | ||
// | ||
// Tool_deg::isKeyDesignationLine -- Returns true if any spine on the line | ||
|
@@ -69567,8 +69602,7 @@ bool Tool_deg::isKeyDesignationLine(HumdrumFile& infile, int lineIndex) { | |
////////////////////////////// | ||
// | ||
// Tool_deg::isDegAboveLine -- Return true if **deg spines only | ||
// include *arr, *Xarr, *acc, *Xacc interpretations | ||
// and "*" (but not all "*"). | ||
// include *above, *below, interpretations and "*" (but not all "*"). | ||
// | ||
|
||
bool Tool_deg::isDegAboveLine(HumdrumFile& infile, int lineIndex) { | ||
|
@@ -69679,8 +69713,7 @@ bool Tool_deg::isDegCircleLine(HumdrumFile& infile, int lineIndex) { | |
////////////////////////////// | ||
// | ||
// Tool_deg::isDegColorLine -- Return true if **deg spines only | ||
// include *arr, *Xarr, *acc, *Xacc interpretations | ||
// and "*" (but not all "*"). | ||
// include *color interpretations and "*" (but not all "*"). | ||
// | ||
|
||
bool Tool_deg::isDegColorLine(HumdrumFile& infile, int lineIndex) { | ||
|
@@ -69748,6 +69781,42 @@ bool Tool_deg::isDegHatLine(HumdrumFile& infile, int lineIndex) { | |
|
||
|
||
|
||
////////////////////////////// | ||
// | ||
// Tool_deg::isDegSolfegeLine -- Return true if **deg spines includes | ||
// any *solf, or *Xsolf, interpretations and "*" (but not all "*"). | ||
// | ||
|
||
bool Tool_deg::isDegSolfegeLine(HumdrumFile& infile, int lineIndex) { | ||
// If there are no **deg spines, then don't bother searching for them. | ||
if (!m_ipv.hasDegSpines) { | ||
return false; | ||
} | ||
if (!infile[lineIndex].isInterpretation()) { | ||
return false; | ||
} if (infile[lineIndex].isManipulator()) { | ||
return false; | ||
} | ||
|
||
int degCount = 0; | ||
for (int i=0; i<infile[lineIndex].getFieldCount(); i++) { | ||
HTp token = infile.token(lineIndex, i); | ||
if (!token->isDataType("**deg")) { | ||
continue; | ||
} | ||
degCount++; | ||
if (*token == "*solf") { return true; } | ||
if (*token == "*Xsolf") { return true; } | ||
} | ||
if (degCount == 0) { | ||
m_ipv.hasDegSpines = false; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
|
||
|
||
////////////////////////////// | ||
// | ||
// Tool_deg::printDegInterpretation -- | ||
|
@@ -69905,7 +69974,7 @@ string Tool_deg::prepareMergerLine(vector<vector<string>>& merge) { | |
|
||
////////////////////////////// | ||
// | ||
// Tool_deg::calculateManipulatorOutput -- Deal with *^ *v *- *+ manipulators | ||
// Tool_deg::calculateManipulatorOutputForSpine -- Deal with *^ *v *- *+ manipulators | ||
// | ||
|
||
void Tool_deg::calculateManipulatorOutputForSpine(vector<string>& lineout, | ||
|
@@ -69964,6 +70033,7 @@ void Tool_deg::printDegScore(HumdrumFile& infile) { | |
bool printCircle = !m_circleQ; | ||
bool printColor = !m_colorQ; | ||
bool printHat = !m_hatQ; | ||
bool printSolfege = !m_solfegeQ; | ||
|
||
int lineCount = (int)m_degSpines[0].size(); | ||
int spineCount = (int)m_degSpines.size(); | ||
|
@@ -70032,11 +70102,17 @@ void Tool_deg::printDegScore(HumdrumFile& infile) { | |
} | ||
|
||
if (!printHat) { | ||
string line = createDegInterpretation("*arr", i, m_recipQ); | ||
string line = createDegInterpretation("*hat", i, m_recipQ); | ||
m_humdrum_text << line << endl; | ||
printHat = true; | ||
} | ||
|
||
if (!printSolfege) { | ||
string line = createDegInterpretation("*solf", i, m_recipQ); | ||
m_humdrum_text << line << endl; | ||
printSolfege = true; | ||
} | ||
|
||
} | ||
|
||
for (int j=0; j<spineCount; j++) { | ||
|
@@ -70680,7 +70756,7 @@ string Tool_deg::ScaleDegree::generateDegDataToken(void) const { | |
|
||
////////////////////////////// | ||
// | ||
// Tool_deg::ScaleDegree::createDegDataSubToken -- Convert the ScaleDegree | ||
// Tool_deg::ScaleDegree::generateDegDataSubtoken -- Convert the ScaleDegree | ||
// subtoken (chord note) into **deg data. | ||
// | ||
|
||
|
Oops, something went wrong.