Skip to content

Commit

Permalink
Merge commit 'ffbb2d7d6e2544b65c1ef6095af5633805b8df85'
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed May 15, 2017
2 parents f95b8c6 + ffbb2d7 commit b2194a3
Show file tree
Hide file tree
Showing 20 changed files with 559 additions and 100 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ output.mei
main.class
leipzig-5.2.log
leipzig-5.2_data.ly

# MacOS
.DS_Store
1 change: 1 addition & 0 deletions include/hum/MxmlEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class MxmlEvent {
void reportVerseCountToOwner (int staffnum, int count);
void reportHarmonyCountToOwner (int count);
void reportMeasureStyleToOwner (MeasureStyle style);
void reportEditorialAccidentalToOwner(void);
void makeDummyRest (MxmlMeasure* owner,
HumNum startime,
HumNum duration,
Expand Down
2 changes: 2 additions & 0 deletions include/hum/MxmlMeasure.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ class MxmlMeasure {
void receiveStaffNumberFromChild (int staffnum, int voicenum);
void receiveTimeSigDurFromChild (HumNum duration);
void receiveMeasureStyleFromChild(MeasureStyle style);
void receiveEditorialAccidentalFromChild(void);
void reportStaffNumberToOwner (int staffnum, int voicenum);
void reportVerseCountToOwner (int count);
void reportVerseCountToOwner (int staffindex, int count);
void reportHarmonyCountToOwner (int count);
void reportEditorialAccidentalToOwner (void);

protected:
HumNum m_starttime; // start time of measure in quarter notes
Expand Down
3 changes: 3 additions & 0 deletions include/hum/MxmlPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ class MxmlPart {
void prepareVoiceMapping (void);
int getVoiceIndex (int voicenum);
int getStaffIndex (int voicenum);
bool hasEditorialAccidental(void) const;

private:
void receiveStaffNumberFromChild (int staffnum, int voicenum);
void receiveVerseCount (int count);
void receiveVerseCount (int staffnum, int count);
void receiveHarmonyCount (int count);
void receiveEditorialAccidental(void);

protected:
vector<MxmlMeasure*> m_measures;
Expand All @@ -77,6 +79,7 @@ class MxmlPart {
int m_maxstaff;
vector<int> m_verseCount;
int m_harmonyCount;
bool m_editorialAccidental;

// m_staffvoicehist: counts of staff and voice numbers.
// staff=0 is used for items such as measures.
Expand Down
6 changes: 3 additions & 3 deletions include/hum/humlib.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Sat Aug 8 12:24:49 PDT 2015
// Last Modified: Mon Feb 27 21:12:02 PST 2017
// Last Modified: Thu Apr 20 09:35:35 PDT 2017
// Filename: humlib.h
// URL: https://github.com/craigsapp/humlib/blob/master/include/humlib.h
// Syntax: C++11
Expand Down Expand Up @@ -2510,7 +2510,7 @@ class Options {
bool process (int argc, char** argv,
int error_check = 1,
int suppress = 0);
bool process (vector<string>& argv,
bool process (const vector<string>& argv,
int error_check = 1,
int suppress = 0);
bool process (string& argv, int error_check = 1,
Expand All @@ -2525,7 +2525,7 @@ class Options {
void setModified (const string& optionName,
const string& optionValue);
void setOptions (int argc, char** argv);
void setOptions (vector<string>& argv);
void setOptions (const vector<string>& argv);
void setOptions (string& args);
void appendOptions (int argc, char** argv);
void appendOptions (string& args);
Expand Down
5 changes: 5 additions & 0 deletions include/vrv/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ class FileInputStream : public std::ifstream {
*/
virtual void SetMdivXPathQuery(std::string &xPathQuery) {}

/**
* Set Humdrum import type option (Humdrum only)
*/
virtual void SetTypeOption(int value) {}

private:
/**
* Init values (called by the constructors)
Expand Down
29 changes: 24 additions & 5 deletions include/vrv/iohumdrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class HumdrumSignifiers {

// boolean switches:
char nostem = '\0'; // !!!RDF**kern: i = no stem
char cuesize = '\0'; // !!!RDF**kern: i = cue size
char editacc = '\0'; // !!!RDF**kern: i = editorial accidental
char below = '\0'; // !!!RDF**kern: i = below (previous signifier is "below")
char above = '\0'; // !!!RDF**kern: i = above (previous signifier is "above")
Expand Down Expand Up @@ -216,6 +217,9 @@ class HumdrumInput : public vrv::FileInputStream {
std::string GetHumdrumString(void);
std::string GetMeiString(void);

int GetTypeOption(void) { return m_type; }
void SetTypeOption(int value) { m_type = value; }

protected:
void clear(void);
bool convertHumdrum(void);
Expand All @@ -235,7 +239,7 @@ class HumdrumInput : public vrv::FileInputStream {
void setClef(StaffDef *part, const std::string &clef);
void setTimeSig(StaffDef *part, const std::string &timesig);
void setMeterSymbol(StaffDef *part, const std::string &metersig);
void fillPartInfo(hum::HTp partstart, int partnumber);
void fillPartInfo(hum::HTp partstart, int partnumber, int partcount);
void storeStaffLayerTokensForMeasure(int startline, int endline);
void calculateReverseKernIndex(void);
void prepareTimeSigDur(void);
Expand Down Expand Up @@ -292,16 +296,18 @@ class HumdrumInput : public vrv::FileInputStream {
void processSlurs(hum::HTp token);
int getSlurEndIndex(hum::HTp token, std::string targetid, std::vector<bool> &indexused);
void addHarmFloatsForMeasure(int startine, int endline);
void addFiguredBassForMeasure(int startline, int endline);
void processDynamics(hum::HTp token, int staffindex);
void processDirection(hum::HTp token, int staffindex);
void processChordSignifiers(Chord *chord, hum::HTp token, int staffindex);
hum::HumNum getMeasureTstamp(hum::HTp token, int staffindex, hum::HumNum frac = 0);
hum::HumNum getMeasureEndTstamp(int staffindex);
hum::HTp getPreviousDataToken(hum::HTp token);
hum::HTp getHairpinEnd(hum::HTp token, const std::string &endchar);
hum::HTp getDecrescendoEnd(hum::HTp token);
hum::HTp getCrescendoEnd(hum::HTp token);
int getMeasureDifference(hum::HTp starttok, hum::HTp endtok);
void storeOriginalClefApp(void);
void storeOriginalClefMensurationApp(void);
void addSpace(std::vector<std::string> &elements, std::vector<void *> &pointers, hum::HumNum duration);
void setLocationId(vrv::Object *object, hum::HTp token, int subtoken = -1);
void setLocationId(vrv::Object *object, int lineindex, int fieldindex, int subtokenindex);
Expand Down Expand Up @@ -329,9 +335,9 @@ class HumdrumInput : public vrv::FileInputStream {
void resolveTupletBeamTie(std::vector<humaux::HumdrumBeamAndTuplet> &tg);
void resolveTupletBeamStartTie(std::vector<humaux::HumdrumBeamAndTuplet> &tg, int index);
void resolveTupletBeamEndTie(std::vector<humaux::HumdrumBeamAndTuplet> &tg, int index);
void appendTypeTag(vrv::Note *note, const std::string &tag);
void embedQstampInClass(vrv::Note *note, hum::HTp token);
void embedBase40PitchInClass(vrv::Note *note, const std::string &token);
void embedQstampInClass(vrv::Note *note, hum::HTp token, const std::string &tstring);
void embedPitchInformationInClass(vrv::Note *note, const std::string &token);
void embedTieInformation(Note *note, const std::string &token);

// header related functions: ///////////////////////////////////////////
void createHeader(void);
Expand Down Expand Up @@ -359,6 +365,7 @@ class HumdrumInput : public vrv::FileInputStream {

template <class ELEMENT> void addTextElement(ELEMENT *element, const std::string &content);
template <class ELEMENT> void checkForAutoStem(ELEMENT element, hum::HTp token);
template <class ELEMENT> void appendTypeTag(ELEMENT *element, const std::string &tag);

/// Static functions ////////////////////////////////////////////////////
static std::string unescapeHtmlEntities(const std::string &input);
Expand All @@ -371,6 +378,7 @@ class HumdrumInput : public vrv::FileInputStream {
static std::string getReferenceValue(const std::string &key, std::vector<hum::HumdrumLine *> &references);
static bool replace(std::string &str, const std::string &oldStr, const std::string &newStr);
std::string cleanHarmString(const std::string &content);
std::vector<std::string> cleanFBString(const std::string &content);

private:
std::string m_filename; // Filename to read/was read.
Expand Down Expand Up @@ -444,6 +452,9 @@ class HumdrumInput : public vrv::FileInputStream {
// m_oclef == temporary variable for printing "original-clef" <app>
std::vector<std::pair<int, hum::HTp> > m_oclef;

// m_omet == temporary variable for printing "original-mensuration" <app>
std::vector<std::pair<int, hum::HTp> > m_omet;

// m_staffstates == state variables for each staff.
std::vector<humaux::StaffStateVariables> m_staffstates;

Expand All @@ -456,6 +467,11 @@ class HumdrumInput : public vrv::FileInputStream {
// converted into <harm> element in the MEI conversion.
bool m_harm;

// m_fb == state variable for keeping track of whether or not
// the file to convert contains **Bnum spines that should be
// converted into <harm> element in the MEI conversion.
bool m_fb;

// m_leftbarstyle is a barline left-hand style to store in the next measure.
// When processing a measure, this variable should be checked and used
// in @left="style" for the measure.
Expand All @@ -482,6 +498,9 @@ class HumdrumInput : public vrv::FileInputStream {
bool m_has_color_spine = false;

#endif /* NO_HUMDRUM_SUPPORT */

// m_type == true means add type markup in Humdrum-to-MEI conversion.
bool m_type = true;
};

} // namespace vrv
Expand Down
9 changes: 9 additions & 0 deletions include/vrv/toolkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ class Toolkit {
int GetNoLayout() { return m_noLayout; }
///@}

/**
* @name Include type attributes when importing from Humdrum
*/
///@{
void SetHumType(int l) { m_humType = l; }
int GetHumType() { return m_humType; }
///@}

/**
* @name Ignore all encoded layout information (if any)
* and fully recalculate the layout
Expand Down Expand Up @@ -404,6 +412,7 @@ class Toolkit {

bool m_noLayout;
bool m_ignoreLayout;
int m_humType = 0;
bool m_adjustPageHeight;
std::vector<std::string> m_appXPathQueries;
std::vector<std::string> m_choiceXPathQueries;
Expand Down
2 changes: 0 additions & 2 deletions src/artic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ int Artic::CalcArtic(FunctorParams *functorParams)
Chord *parentChord = dynamic_cast<Chord *>(this->GetFirstParent(CHORD, 2));
data_STEMDIRECTION stemDir = STEMDIRECTION_NONE;
data_STAFFREL place = STAFFREL_NONE;
bool drawingCueSize = false;

if (!parentChord) {
parentNote = dynamic_cast<Note *>(this->GetFirstParent(NOTE));
Expand All @@ -292,7 +291,6 @@ int Artic::CalcArtic(FunctorParams *functorParams)
assert(layer);

stemDir = parentNote ? parentNote->GetDrawingStemDir() : parentChord->GetDrawingStemDir();
drawingCueSize = parent->IsCueSize();

/************** placement **************/

Expand Down
8 changes: 6 additions & 2 deletions src/hum/GridSlice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,12 @@ void GridSlice::transferTokens(HumdrumFile& outfile, bool recip) {
token = new HumdrumToken("*");
empty = "*";
} else if (isMeasureSlice()) {
voice = this->at(0)->at(0)->at(0);
token = new HumdrumToken((string)*voice->getToken());
if (this->at(0)->at(0)->size() > 0) {
voice = this->at(0)->at(0)->at(0);
token = new HumdrumToken((string)*voice->getToken());
} else {
token = new HumdrumToken("=X");
}
//ggg
empty = (string)*token;
} else if (isInterpretationSlice()) {
Expand Down
28 changes: 28 additions & 0 deletions src/hum/MxmlEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,11 @@ void MxmlEvent::reportHarmonyCountToOwner(int count) {
}



//////////////////////////////
//
// MxmlEvent::reportMeasureStyleToOwner --
//

void MxmlEvent::reportMeasureStyleToOwner (MeasureStyle style) {
if (!m_owner) {
Expand All @@ -234,6 +236,20 @@ void MxmlEvent::reportMeasureStyleToOwner (MeasureStyle style) {



//////////////////////////////
//
// MxmlEvent::reportEditorialAccidentalToOwner --
//

void MxmlEvent::reportEditorialAccidentalToOwner(void) {
if (!m_owner) {
return;
}
m_owner->receiveEditorialAccidentalFromChild();
}



//////////////////////////////
//
// MxmlEvent::getPartNumber --
Expand Down Expand Up @@ -1168,6 +1184,7 @@ string MxmlEvent::getKernPitch(void) {
int octave = 4;
bool explicitQ = false;
bool naturalQ = false;
bool editorialQ = false;
// bool sharpQ = false;
// bool flatQ = false;
// bool doubleflatQ = false;
Expand Down Expand Up @@ -1211,6 +1228,13 @@ string MxmlEvent::getKernPitch(void) {
// doublesharpQ = true;
explicitQ = true;
}
xml_attribute paren = child.attribute("parentheses");
if (paren) {
if (strcmp(paren.value(), "yes") == 0) {
editorialQ = 1;
reportEditorialAccidentalToOwner();
}
}
}
child = child.next_sibling();
}
Expand Down Expand Up @@ -1251,6 +1275,10 @@ string MxmlEvent::getKernPitch(void) {
output += 'X';
}

if (editorialQ) {
output += "i";
}

return output;
}

Expand Down
27 changes: 27 additions & 0 deletions src/hum/MxmlMeasure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,33 @@ void MxmlMeasure::reportHarmonyCountToOwner(int count) {



//////////////////////////////
//
// MxmlMeasure::reportEditorialAccidentalToOwner --
//

void MxmlMeasure::reportEditorialAccidentalToOwner(void) {
if (!m_owner) {
return;
}
m_owner->receiveEditorialAccidental();
}



//////////////////////////////
//
// MxmlMeasure::receiveEditorialAccidentalFromChild --
//

void MxmlMeasure::receiveEditorialAccidentalFromChild(void) {
if (m_owner != NULL) {
m_owner->receiveEditorialAccidental();
}
}



//////////////////////////////
//
// MxmlMeasure::getPartNumber --
Expand Down
24 changes: 24 additions & 0 deletions src/hum/MxmlPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void MxmlPart::clear(void) {
m_maxstaff = 0;
m_verseCount.resize(0);
m_harmonyCount = 0;
m_editorialAccidental = false;
}


Expand Down Expand Up @@ -269,6 +270,18 @@ int MxmlPart::getHarmonyCount(void) const {



//////////////////////////////
//
// MxmlPart::hasEditorialAccidental -- Return true if part contains an editorial
// accidental (represented as parentheses around the accidental in MusicXML.
//

bool MxmlPart::hasEditorialAccidental(void) const {
return m_editorialAccidental;
}



//////////////////////////////
//
// MxmlPart::getVerseCount -- Return the number of verses in the part.
Expand Down Expand Up @@ -305,6 +318,17 @@ void MxmlPart::receiveHarmonyCount(int count) {



//////////////////////////////
//
// MxmlPart::receiveEditorialAccidental --
//

void MxmlPart::receiveEditorialAccidental(void) {
m_editorialAccidental = true;
}



//////////////////////////////
//
// MxmlPart::receiveVerseCount --
Expand Down
Loading

0 comments on commit b2194a3

Please sign in to comment.