Skip to content

Commit

Permalink
Added initial implementation of **mens to MEI conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
craigsapp committed May 5, 2018
1 parent 686bba6 commit 36f3df3
Show file tree
Hide file tree
Showing 5 changed files with 533 additions and 75 deletions.
20 changes: 19 additions & 1 deletion 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: Wed Apr 25 12:08:23 PDT 2018
// Last Modified: Sat May 5 00:28:09 PDT 2018
// Filename: humlib.h
// URL: https://github.com/craigsapp/humlib/blob/master/include/humlib.h
// Syntax: C++11
Expand Down Expand Up @@ -1214,6 +1214,7 @@ class HumdrumToken : public string, public HumHash {
const string& getDataType (void) const;
bool isDataType (string dtype) const;
bool isKern (void) const;
bool isMens (void) const;
string getSpineInfo (void) const;
int getTrack (void) const;
int getSubtrack (void) const;
Expand Down Expand Up @@ -2506,6 +2507,23 @@ class Convert {
static int base7ToBase40 (int base7);
static int base40IntervalToDiatonic(int base40interval);


// **mens, white mensual notation, defiend in Convert-mens.cpp
static bool isMensRest (const string& mensdata);
static bool isMensNote (const string& mensdata);
static bool hasLigatureStart (const string& mensdata);
static bool hasLigatureEnd (const string& mensdata);
static bool getMensStemDirection (const string& mensdata);
static HumNum mensToDuration (const string& mensdata,
HumNum scale = 4,
const string& separator = " ");
static string mensToRecip (const string& mensdata,
HumNum scale = 4,
const string& separator = " ");
static HumNum mensToDurationNoDots(const string& mensdata,
HumNum scale = 4,
const string& separator = " ");

// Harmony processing, defined in Convert-harmony.cpp
static vector<int> minorHScaleBase40(void);
static vector<int> majorScaleBase40 (void);
Expand Down
15 changes: 12 additions & 3 deletions include/vrv/iohumdrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ class HumdrumInput : public vrv::FileInputStream {
std::string automaticHeaderRight(
std::vector<std::pair<string, string> > &biblist, std::map<std::string, std::string> &refmap, int &linecount);
std::string getLayoutParameter(hum::HTp token, const std::string &category, const std::string &keyname);
void convertMensuralToken(
std::vector<string> &elements, std::vector<void *> &pointers, hum::HTp token, int staffindex);

// header related functions: ///////////////////////////////////////////
void createHeader();
Expand All @@ -432,6 +434,7 @@ class HumdrumInput : public vrv::FileInputStream {
template <class PARENT, class CHILD> void appendElement(PARENT parent, CHILD child);
template <class ELEMENT> void addArticulations(ELEMENT element, hum::HTp token);
template <class ELEMENT> hum::HumNum convertRhythm(ELEMENT element, hum::HTp token, int subtoken = -1);
template <class ELEMENT> hum::HumNum convertMensuralRhythm(ELEMENT element, hum::HTp token, int subtoken = -1);
template <class ELEMENT> hum::HumNum setDuration(ELEMENT element, hum::HumNum duration);
template <class ELEMENT> void setStaff(ELEMENT element, int staffnum);
template <class ELEMENT> void setN(ELEMENT element, int nvalue);
Expand Down Expand Up @@ -513,9 +516,10 @@ class HumdrumInput : public vrv::FileInputStream {
// converted.
std::vector<std::vector<std::vector<hum::HTp> > > m_layertokens;

// m_kernspines == list of tracks in Humdrum file being parsed which
// contain **kern data.
std::vector<hum::HTp> m_kernstarts;
// m_staffstarts == list of tracks in Humdrum file being parsed which
// contain **kern, **mens data or whatever other data types
// will be converted into a staff in the conversion to MEI.
std::vector<hum::HTp> m_staffstarts;

// m_rkern == reverse mapping of Humdrum track to staff number..
std::vector<int> m_rkern;
Expand Down Expand Up @@ -560,6 +564,11 @@ class HumdrumInput : public vrv::FileInputStream {
// converted into <string> elements in the MEI conversion.
bool m_string = false;

// m_mens == state variable for keeping track of whether or not
// the file to convert contains **mens spines that should be
// converted into mensuration notation staves.
bool m_mens = false;

// 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.
Expand Down
Loading

1 comment on commit 36f3df3

@craigsapp
Copy link
Contributor Author

@craigsapp craigsapp commented on 36f3df3 May 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Accidentally committed to develop branch before develop-humdrum branch)

Example:

screen shot 2018-05-05 at 3 05 55 am

Input Humdrum data:

!!!OTL: Willi Apel, pg. 101
**mens
!Example
*clefC3
*k[]
*M4/4
*met(C)
S:f
<s:e
sd>
mc/
Me/
md/
me/
Mf/
me/
md/
mc/
MB/
sc
Md/
Se
*-

Output MEI data:

verovio -atmei test.mens
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="4.0.0">
    <meiHead>
        <fileDesc>
            <titleStmt>
                <title>Willi Apel, pg. 101</title>
            </titleStmt>
            <pubStmt />
        </fileDesc>
        <encodingDesc>
            <appInfo>
                <application isodate="2018-05-05T03:07:42" version="2.0.0-dev-686bba6-dirty">
                    <name>Verovio</name>
                    <p>Transcoded from Humdrum</p>
                </application>
            </appInfo>
        </encodingDesc>
        <workDesc>
            <work>
                <titleStmt>
                    <title xml:id="title-L1" analog="humdrum:OTL" type="main">Willi Apel, pg. 101</title>
                </titleStmt>
            </work>
        </workDesc>
        <extMeta>
            <frames xmlns:humxml="http://www.humdrum.org/ns/humxml">
                <metaFrame n="0" token="!!!OTL: Willi Apel, pg. 101" xml:id="loc0">
                    <frameInfo>
                        <startTime float="0" />
                        <frameType>reference</frameType>
                        <referenceKey>OTL</referenceKey>
                        <referenceValue>Willi Apel, pg. 101</referenceValue>
                    </frameInfo>
                </metaFrame>
            </frames>
        </extMeta>
    </meiHead>
    <music>
        <body>
            <mdiv xml:id="mdiv-0000000461857801">
                <score xml:id="score-0000000009822035">
                    <scoreDef xml:id="scoredef-0000001747677682" midi.bpm="400">
                        <staffGrp xml:id="staffgrp-0000001104264287">
                            <staffDef xml:id="staffdef-0000002044850301" clef.shape="C" clef.line="3" key.sig="0" meter.count="4" meter.unit="4" meter.sym="common" n="1" notationtype="mensural" lines="5">
                                <label xml:id="label-0000002084210917" />
                            </staffDef>
                        </staffGrp>
                        <pgHead xml:id="pghead-0000001112504625">
                            <rend xml:id="rend-0000001211019963" halign="center" valign="middle">
                                <rend xml:id="rend-0000001517128065" fontsize="x-large">Willi Apel, pg. 101</rend>
                                <lb xml:id="lb-0000001903758275" /> 
<lb xml:id="lb-0000000726541584" /> </rend>
                        </pgHead>
                    </scoreDef>
                    <section xml:id="section-0000000752852218">
                        <measure xml:id="measure-L2" right="invis" n="0">
                            <staff xml:id="staff-0000000482747003" n="1">
                                <layer xml:id="layer-L2F1N1" n="1">
                                    <note xml:id="note-L8F1" dots="1" dur="brevis" oct="4" pname="f" accid.ges="n" />
                                    <dot xml:id="dot-0000000438017232" />
                                    <note xml:id="note-L9F1" dots="1" dur="semibrevis" oct="4" pname="e" accid.ges="n" />
                                    <dot xml:id="dot-0000001820836230" />
                                    <note xml:id="note-L10F1" dur="semibrevis" oct="4" pname="d" accid.ges="n" />
                                    <note xml:id="note-L11F1" dur="semiminima" oct="4" pname="c" stem.dir="up" accid.ges="n" />
                                    <note xml:id="note-L12F1" dur="minima" oct="4" pname="e" stem.dir="up" accid.ges="n" />
                                    <note xml:id="note-L13F1" dur="semiminima" oct="4" pname="d" stem.dir="up" accid.ges="n" />
                                    <note xml:id="note-L14F1" dur="semiminima" oct="4" pname="e" stem.dir="up" accid.ges="n" />
                                    <note xml:id="note-L15F1" dur="minima" oct="4" pname="f" stem.dir="up" accid.ges="n" />
                                    <note xml:id="note-L16F1" dur="semiminima" oct="4" pname="e" stem.dir="up" accid.ges="n" />
                                    <note xml:id="note-L17F1" dur="semiminima" oct="4" pname="d" stem.dir="up" accid.ges="n" />
                                    <note xml:id="note-L18F1" dur="semiminima" oct="4" pname="c" stem.dir="up" accid.ges="n" />
                                    <note xml:id="note-L19F1" dur="minima" oct="3" pname="b" stem.dir="up" accid.ges="n" />
                                    <note xml:id="note-L20F1" dur="semibrevis" oct="4" pname="c" accid.ges="n" />
                                    <note xml:id="note-L21F1" dur="minima" oct="4" pname="d" stem.dir="up" accid.ges="n" />
                                    <note xml:id="note-L22F1" dur="brevis" oct="4" pname="e" accid.ges="n" />
                                </layer>
                            </staff>
                        </measure>
                    </section>
                </score>
            </mdiv>
        </body>
    </music>
</mei>

Mensuration signs and ligature still to be implemented in the converter (angle brackets indicate a ligature). Augmentation dot on first note of ligature will probably generate an issue :-)

Original rendering:

screen shot 2018-05-05 at 1 21 14 am

Please sign in to comment.