Skip to content

Commit

Permalink
Preparation for <harm> labels in Humdrum-to-MEI converter.
Browse files Browse the repository at this point in the history
  • Loading branch information
craigsapp committed Dec 27, 2022
1 parent 99f570b commit bd5fc8c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/vrv/iohumdrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "dir.h"
#include "ending.h"
#include "ftrem.h"
#include "harm.h"
#include "io.h"
#include "keysig.h"
#include "label.h"
Expand Down Expand Up @@ -795,6 +796,8 @@ class HumdrumInput : public vrv::Input {
void setClefBasicShape(Clef *clef, hum::HTp token);
void setClefStaffLine(Clef *clef, hum::HTp token);
std::u32string cleanDegreeString(hum::HTp token);
void analyzeKeyLabels(hum::HTp starttok);
void addHarmLabel(Harm *harm, const std::string &label);

// header related functions: ///////////////////////////////////////////
void createHeader();
Expand Down
58 changes: 58 additions & 0 deletions src/iohumdrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,12 +824,15 @@ bool HumdrumInput::convertHumdrum()
m_mens = true;
}
else if (it->isDataType("**harm")) {
analyzeKeyLabels(it);
m_harm = true;
}
else if (it->isDataType("**deg")) {
analyzeKeyLabels(it);
m_degree = true;
}
else if (it->isDataType("**degree")) {
analyzeKeyLabels(it);
m_degree = true;
}
else if (it->isDataType("**rhrm")) { // **recip + **harm
Expand Down Expand Up @@ -920,6 +923,47 @@ bool HumdrumInput::convertHumdrum()
return status;
}

//////////////////////////////
//
// HumdrumInput::analyzeKeyLabels --
//

void HumdrumInput::analyzeKeyLabels(hum::HTp starttok)
{
hum::HTp current = starttok;
while (current) {
current = current->getNextToken();
if (!current) {
break;
}
if (!current->isInterpretation()) {
continue;
}
if (!current->isKeyDesignation()) {
continue;
}
hum::HTp keydesig = current;
while (current) {
current = current->getNextToken();
if (!current) {
break;
}
if (current->isKeyDesignation()) {
keydesig = current;
continue;
}
if (!current->isData()) {
continue;
}
if (current->isNull()) {
continue;
}
current->setValue("auto", "meilabel", keydesig->substr(1));
break;
}
}
}

//////////////////////////////
//
// HumdrumInput::prepareFingerings -- Mark fingerings with explicit
Expand Down Expand Up @@ -7729,12 +7773,26 @@ void HumdrumInput::addHarmFloatsForMeasure(int startline, int endline)

hum::HumNum tstamp = getMeasureTstamp(token, xstaffindex);
harm->SetTstamp(tstamp.getFloat());
std::string meilabel = token->getValue("auto", "meilabel");
if (!meilabel.empty()) {
addHarmLabel(harm, meilabel);
}

setLocationId(harm, token);
}
}
}

//////////////////////////////
//
// HumdrumInput::addHarmLabel --
//

void HumdrumInput::addHarmLabel(Harm *harm, const std::string &label)
{
cerr << "ADD HARM LABEL " << label << " HERE" << endl;
}

//////////////////////////////
//
// HumdrumInput::getTrackText --
Expand Down

0 comments on commit bd5fc8c

Please sign in to comment.