Skip to content

Commit

Permalink
Adjust Humdrum to MEI header code (in particular pass-by-reference).
Browse files Browse the repository at this point in the history
  • Loading branch information
craigsapp committed Nov 21, 2023
1 parent 58675e7 commit 52abee0
Show file tree
Hide file tree
Showing 2 changed files with 268 additions and 194 deletions.
117 changes: 58 additions & 59 deletions include/vrv/iohumdrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,14 @@ class HumdrumSignifiers {
bool empty = true;

// boolean switches:
string nostem; // !!!RDF**kern: N = no stem
string cuesize; // !!!RDF**kern: @ = cue size
std::string nostem; // !!!RDF**kern: N = no stem
std::string cuesize; // !!!RDF**kern: @ = cue size

string kernTerminalLong; // !!!RDF**kern: l = terminal long
string kernTerminalBreve; // !!!RDF**kern: l = terminal breve
std::string kernTerminalLong; // !!!RDF**kern: l = terminal long
std::string kernTerminalBreve; // !!!RDF**kern: l = terminal breve

string mensTerminalLong; // !!!RDF**mens: l = terminal long
string mensTerminalBreve; // !!!RDF**mens: l = terminal breve
std::string mensTerminalLong; // !!!RDF**mens: l = terminal long
std::string mensTerminalBreve; // !!!RDF**mens: l = terminal breve

std::vector<string> editaccKern; // !!!RDF**kern: i = editorial accidental
std::vector<string> editaccMens; // !!!RDF**mens: z = editorial accidental
Expand All @@ -386,8 +386,8 @@ class HumdrumSignifiers {
std::string decresctext; // !!!RDF**kern: > = "decresc."
std::string decrescfontstyle; // !!!RDF**kern: < = "decresc." fontstyle="normal|italic|bold|bold-italic"

string below; // !!!RDF**kern: < = below (previous signifier is "below")
string above; // !!!RDF**kern: > = above (previous signifier is "above")
std::string below; // !!!RDF**kern: < = below (previous signifier is "below")
std::string above; // !!!RDF**kern: > = above (previous signifier is "above")

std::string phrase_color; // for global stying of phrase markers
std::string phrase_style; // for global stying of phrase markers
Expand Down Expand Up @@ -430,39 +430,39 @@ class HumdrumSignifiers {
#endif /* NO_HUMDRUM_SUPPORT */

struct HumdrumReferenceItem {
std::string lineText; // the full text of the HumdrumLine containing this item,
// e.g. "!!!OTL2@FR:Le deuxième titre Français"
std::string key; // the interpreted key, with key, index, isTranslated, language stripped out
// e.g. "OTL" (if not parseable, we get everything between "!!!" and ":")
std::string value; // the value (everything after the ':')
// e.g. "Le deuxième titre Français"
bool isParseable = false; // true if we could parse out key, index, isTranslated, language
// e.g. true
bool isHumdrumKey = false; // true if isParseable and key is in the known list of Humdrum keys
// e.g. true
bool isTranslated = false; // true if single '@' (not '@@') is present
// e.g. true
std::string language; // the language, if present, lowercased
// e.g. "fr"
int index = -1; // the index (0 if not present)
// e.g. 2
std::string lineText; // the full text of the HumdrumLine containing this item,
// e.g. "!!!OTL2@FR:Le deuxième titre Français"
std::string key; // the interpreted key, with key, index, isTranslated, language stripped out
// e.g. "OTL" (if not parseable, we get everything between "!!!" and ":")
std::string value; // the value (everything after the ':')
// e.g. "Le deuxième titre Français"
bool isParseable = false; // true if we could parse out key, index, isTranslated, language
// e.g. true
bool isHumdrumKey = false; // true if isParseable and key is in the known list of Humdrum keys
// e.g. true
bool isTranslated = false; // true if single '@' (not '@@') is present
// e.g. true
std::string language; // the language, if present, lowercased
// e.g. "fr"
int index = -1; // the index (0 if not present)
// e.g. 2
};

struct DateWithErrors {
bool valid = false; // if false, ignore everything here, the date was not parseable.
std::string dateError; // error of the entire date ("", "approximate", "uncertain")
bool valid = false; // if false, ignore everything here, the date was not parseable.
std::string dateError; // error of the entire date ("", "approximate", "uncertain")
int year;
std::string yearError; // error of the year ("", "approximate", "uncertain")
std::string yearError; // error of the year ("", "approximate", "uncertain")
int month;
std::string monthError; // error of the month ("", "approximate", "uncertain")
std::string monthError; // error of the month ("", "approximate", "uncertain")
int day;
std::string dayError; // error of the day ("", "approximate", "uncertain")
std::string dayError; // error of the day ("", "approximate", "uncertain")
int hour;
std::string hourError; // error of the hour ("", "approximate", "uncertain")
std::string hourError; // error of the hour ("", "approximate", "uncertain")
int minute;
std::string minuteError; // error of the minute ("", "approximate", "uncertain")
std::string minuteError; // error of the minute ("", "approximate", "uncertain")
int second;
std::string secondError; // error of the second ("", "approximate", "uncertain")
std::string secondError; // error of the second ("", "approximate", "uncertain")
};

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -526,7 +526,7 @@ class HumdrumInput : public vrv::Input {
void addFermata(hum::HTp token, vrv::Object *parent = NULL);
void addBreath(hum::HTp token, vrv::Object *parent = NULL);
void addTrill(vrv::Object *linked, hum::HTp token);
void addTurn(hum::HTp token, const string &tok, int noteIndex);
void addTurn(hum::HTp token, const std::string &tok, int noteIndex);
void addMordent(vrv::Object *linked, hum::HTp token);
void addOrnaments(vrv::Object *object, hum::HTp token);
void addArpeggio(vrv::Object *object, hum::HTp token);
Expand Down Expand Up @@ -640,7 +640,7 @@ class HumdrumInput : public vrv::Input {
void embedQstampInClass(vrv::Space *irest, hum::HTp token, const std::string &tstring);
void embedPitchInformationInClass(vrv::Note *note, const std::string &token);
void embedTieInformation(Note *note, const std::string &token);
void splitSyllableBySpaces(vector<std::string> &vtext, char spacer = ' ');
void splitSyllableBySpaces(std::vector<std::string> &vtext, char spacer = ' ');
void addDefaultTempo(ScoreDef *scoreDef);
int getChordNoteCount(hum::HTp token);
bool isLeftmostSystemArpeggio(hum::HTp token);
Expand Down Expand Up @@ -767,7 +767,7 @@ class HumdrumInput : public vrv::Input {
bool hasLayoutParameter(hum::HTp token, const std::string &category, const std::string &param);
void assignTupletScalings(std::vector<humaux::HumdrumBeamAndTuplet> &tg);
std::string getLayoutParameter(hum::HTp token, const std::string &category, const std::string &catkey,
const string &trueString, const string &falseString = "");
const std::string &trueString, const std::string &falseString = "");
void analyzeClefNulls(hum::HumdrumFile &infile);
void markAdjacentNullsWithClef(hum::HTp clef);
void markOtherClefsAsChange(hum::HTp clef);
Expand All @@ -788,12 +788,12 @@ class HumdrumInput : public vrv::Input {
void addPlicaUp(Note *note);
void addPlicaDown(Note *note);
void setLayoutSlurDirection(Slur *slur, hum::HTp token);
void setFontStyle(Rend *rend, const string &fontstyle);
void setFontStyle(Rend *rend, const std::string &fontstyle);
void setFontWeight(Rend *rend, const std::string &fontweight);
void importVerovioOptions(Doc *doc);
void adjustChordNoteDurations(Chord *chord, std::vector<Note *> &notes, std::vector<string> &tstrings);
void adjustChordNoteDuration(Note *note, hum::HumNum hdur, int dur, int dots, hum::HumNum chorddur,
const string &tstring, hum::HumNum factor);
const std::string &tstring, hum::HumNum factor);
void setNoteMeiDur(Note *note, int meidur);
void storeExpansionListsInChoice(Section *section, std::vector<hum::HTp> &expansions);
double getMmTempo(hum::HTp token, bool checklast = false);
Expand All @@ -810,7 +810,7 @@ class HumdrumInput : public vrv::Input {
void addBarLineElement(hum::HTp bartok, std::vector<std::string> &elements, std::vector<void *> &pointers);
void prepareFingerings(hum::HumdrumFile &infile);
void prepareFingerings(hum::HTp fstart);
std::string getLoColor(hum::HTp token, const string &category, int subtoken = 0);
std::string getLoColor(hum::HTp token, const std::string &category, int subtoken = 0);
bool isTieAllowedToHang(hum::HTp token);
void analyzeVerseColor(hum::HumdrumFile &infile);
void analyzeVerseColor(hum::HTp &token);
Expand Down Expand Up @@ -868,7 +868,7 @@ class HumdrumInput : public vrv::Input {
void checkForLineContinuations(hum::HTp token);
std::u32string convertNumberToWstring(int number);
void appendTextToRend(Rend *rend, const std::string &content);
void parseMultiVerovioOptions(std::map<std::string, std::string> &parameters, const string &input);
void parseMultiVerovioOptions(std::map<std::string, std::string> &parameters, const std::string &input);
void addSforzandoToNote(hum::HTp token, int staffindex);
void addDynamicsMark(hum::HTp dyntok, hum::HTp token, hum::HLp line, const std::string &letters, int staffindex,
int staffadj, int trackdiff);
Expand All @@ -881,7 +881,7 @@ class HumdrumInput : public vrv::Input {
int staffindex, std::vector<std::string> &elements, std::vector<void *> &pointers, hum::HTp token);
int getKeySignatureNumber(const std::string &humkeysig);
int getStaffNumForSpine(hum::HTp token);
bool checkIfReversedSpineOrder(std::vector<hum::HTp> staffstarts);
bool checkIfReversedSpineOrder(std::vector<hum::HTp> &staffstarts);

// header related functions: ///////////////////////////////////////////
void createHeader();
Expand All @@ -897,20 +897,19 @@ class HumdrumInput : public vrv::Input {
void createSimpleComposerElements();
void createTitleElements(pugi::xml_node element);
void createComposerElements(pugi::xml_node element);
void fillInIsoDate(pugi::xml_node element, string dateString);
std::map<std::string, std::string> isoDateAttributesFromHumdrumDate(string inHumdrumDate, bool edtf=false);
DateWithErrors dateWithErrorsFromHumdrumDate(string dateString);
std::string isoDateFromDateWithErrors(DateWithErrors date, bool edtf);
bool sanityCheckDate(
int year, int month, int day,
int hour, int minute, int second);
std::string stripDateError(string &value);
std::string getTextListLanguage(std::vector<HumdrumReferenceItem> textItems);
std::map<std::string, std::vector<HumdrumReferenceItem>> getAllReferenceItems(hum::HumdrumFile infile);
void fillInIsoDate(pugi::xml_node element, const std::string &dateString);
std::map<std::string, std::string> isoDateAttributesFromHumdrumDate(
const std::string &inHumdrumDate, bool edtf = false);
DateWithErrors dateWithErrorsFromHumdrumDate(const std::string &dateString);
std::string isoDateFromDateWithErrors(const DateWithErrors &date, bool edtf);
bool sanityCheckDate(int year, int month, int day, int hour, int minute, int second);
std::string stripDateError(std::string &value);
std::string getTextListLanguage(const std::vector<HumdrumReferenceItem> &textItems);
std::map<std::string, std::vector<HumdrumReferenceItem>> getAllReferenceItems(hum::HumdrumFile &infile);
std::vector<HumdrumReferenceItem> getReferenceItems(const std::string &key);
bool anyReferenceItemsExist(std::vector<string> keys);
int getBestItem(std::vector<HumdrumReferenceItem> items, string requiredLanguage);
bool isStandardHumdrumKey(string key);
bool anyReferenceItemsExist(const std::vector<string> &keys);
int getBestItem(const std::vector<HumdrumReferenceItem> &items, const std::string &requiredLanguage);
bool isStandardHumdrumKey(const std::string &key);

/// Templates ///////////////////////////////////////////////////////////
template <class ELEMENT> void verticalRest(ELEMENT rest, const std::string &token);
Expand Down Expand Up @@ -968,8 +967,8 @@ class HumdrumInput : public vrv::Input {
template <class ELEMENT> void addDurRecip(ELEMENT element, const std::string &ttoken);
template <class ELEMENT> void addFermata(ELEMENT *rest, const std::string &tstring);
template <class ELEMENT> void storeExpansionList(ELEMENT *parent, hum::HTp etok);
template <class ELEMENT> void setWrittenAccidentalUpper(ELEMENT element, const string &value);
template <class ELEMENT> void setWrittenAccidentalLower(ELEMENT element, const string &value);
template <class ELEMENT> void setWrittenAccidentalUpper(ELEMENT element, const std::string &value);
template <class ELEMENT> void setWrittenAccidentalLower(ELEMENT element, const std::string &value);
template <class ELEMENT> void attachToToken(ELEMENT *element, hum::HTp token);
template <class ELEMENT> void setAttachmentType(ELEMENT *element, hum::HTp token);
template <class ELEMENT>
Expand Down Expand Up @@ -1218,13 +1217,13 @@ class HumdrumInput : public vrv::Input {
std::vector<Slur *> m_ftrem_slurs;

// m_group_name == used to store group names, such as *I""trumpets
std::map<int, string> m_group_name;
std::map<int, std::string> m_group_name;

// m_group_name_tok == used to store group names, such as *I""trumpets
std::map<int, hum::HTp> m_group_name_tok;

// m_group_abbr == used to store group abbreviations, such as *I""trps.
std::map<int, string> m_group_abbr;
std::map<int, std::string> m_group_abbr;

// m_group_abbr_tok == used to store group abbreviations, such as *I""trps.
std::map<int, hum::HTp> m_group_abbr_tok;
Expand Down Expand Up @@ -1275,7 +1274,7 @@ class HumdrumInput : public vrv::Input {
pugi::xml_document m_madsDoc;
pugi::xml_node m_madsCollection;

vector<string> m_standardHumdrumKeys = {
std::vector<string> m_standardHumdrumKeys = {
"COM", // composer's name
"COA", // attributed composer
"COS", // suspected composer
Expand Down Expand Up @@ -1371,7 +1370,7 @@ class HumdrumInput : public vrv::Input {
"HTX", // freeform translation of vocal text
"RLN", // Extended ASCII language code
"RNB", // a note about the representation
"RWB" // a warning about the representation
"RWB" // a warning about the representation
};

#endif /* NO_HUMDRUM_SUPPORT */
Expand Down
Loading

0 comments on commit 52abee0

Please sign in to comment.