humdrum-js

A Javascript parser for musical data in the Humdrum syntax

The HumdrumLine object is an interface for managing the contents of a Humdrum data line. All events in all spines that occur (or start) at the same time will be members of the same HumdrumLine, so it represents a unique time instant in the data. If spines posses duration information, such as **kern or **recip data, then the Humdrum content can be rhythmically analyzed and a specific timestamp assigned to the HumdrumLine (which will be stored in the timestamp property of the object).

A HumdrumLine object contains an array of HumdrumToken in its fields property. If the line consists of a global comment or reference record, fields will contain only one HumdrumToken object representing the entire line; otherwise, the line will be split into one or more spine tokens, each managed by a separate HumdrumToken object stored in the fields array. Empty lines are represented as a single empty HumdrumToken. Therefore, there will always be at least one HumdrumToken in an initialized HumdrumLine object’s fields property. Usually the getToken function should be used to access the HumdrumToken contained in the object.

Functions

getOwner — Returns the HumdrumBase object that contains the line.
getNextLine — Returns the next HumdrumLine object in the Humdrum data.
getPrevLine — Returns the next HumdrumLine object in the Humdrum data.
getToken — Return the token at a given index position.
getTokens — Return array of all HumdrumTokens on the line.


Line-type functions

getLineType — Returns a string describing the line type.
isBarline — Returns true if the line is a barline.
isComment — Returns true if the line is a comment.
isData — Returns true if the line is data.
isEmpty — Returns true if the line is empty.
isGlobal — Returns true if the line line starts with two or more exclamation marks.
isGlobalComment — Returns true if the line is a global comment.
isInterpretation — Returns true if the line is an interpretation.
isLocalComment — Returns true if the line is a local comment.
isRefRecord — Returns true if the line is a reference record.
isSpined — Returns true if the line has spined data.
isUniversalRefRecord — Returns true if the line is a universal reference record.


State variables

These properties are used to manage the HumdrumLine object. Prefer using the above functions to access or modify these variables unless you know what your are doing.

text — The pre-parsed text for the Humdrum data line stored in the object.
fields — Data fields in line (tokens or global/reference records).
nextLine — Reference to the next line in the Humdrum data.
prevLine — Reference to the previous line in the Humdrum data.
spines — Boolean for if the line has token data.
lineType — The basic category type of the line.
owner — Reference to the HumdrumBase object that contains this object.


Private functions

Here is a list of functions that are mostly intended for automatic processing of the HumdrumLine object, so they should not be used in general. These functions are mostly used by HumdrumBase.parse and HumdrumBase.stringify.

clear — Initialize object variables to an empty state.
parse — Load a string into the HumdrumLine object's contents.
stringify — Convert object to plain text.