The library contains some helper functions.
Function | Explanation |
setResult(sText, nRowLength) | Writes a string to the result field in the melody HTML file. Expects as parameters the string to display and optionally a maximal length per row. |
inputID() | Prompts the user to enter EsAC-ID and returns the corresponding Song-object, if found. |
init() | Reads all songs in an array of Song-objects and formats the HTML file. Needs to be called after file is completely loaded. |
getSongByEsacId(sEsacID) | Expects Esac-ID as parameter and returns the corresponding Song-object, if found. |
getPitchClass(sToneName) | Expects a tone name as parameter and returns the corresponding pitch class (C=0, C#=1, ...). Valid Tone names start with C,D,E etc or with a digit from "1"-"7", followed by one or no accidential ("b" or "#"). |
This object holds all information about a EsAC song.
Member | Explanation |
title | The title of the song. |
key | The key of the song. |
sig | The signature of the song. |
unit | The unit of the song. |
code | The EsAC code of the melody, as found in the HTML file, so needs normalization. |
valid | If all relevant membersof the song object are filled, this variable is set to true otherwise to false |
This object provides useful functions for parsing EsAC-code. The EsacParser-object should be constructed with an EsAC-code string as argument like this:
var parser = new EsacParser(sCode)The EsAC-Code will be normalized by calling the constructor.
Member | Explanation |
code | Contains the code to be parsed. If this member is set manually, a subsequent call to normalize() is needed to assure correct parsing. |
The EsacParser object contains the following methods:
Method | Explanation |
isDigit(sChar) | Returns true if sChar equals "0", "1", "2", "3", "4", 5", "6", or "7", false otherwise. |
isOctaver(sChar) | Returns true if sChar equals "+", or "-", false otherwise. |
isProlongation(sChar) | Returns true if sChar equals "_", or ".", false otherwise. |
isAccidential(sChar) | Returns true if sChar equals "b", or "#", false otherwise. |
isCR(sChar) | Returns true if sChar equals carriage return ("\n"), false otherwise. |
isSpace(sChar) | Returns true if sChar equals a space " ", false otherwise. |
isCaret(sChar) | Returns true if sChar equals "^", false otherwise. |
isWS(sChar) | Returns true if sChar equals "\n" or " ", false otherwise. |
removeAccidentials(sCode) | Returns the EsAC-code with all accidentials removed (diatonic classes). Without argument, the code given to the EsacParser is used. |
removeOctave(sCode) | Returns the EsAC-code with all octave modifiers ("+","-") removed (pitch classes). Without argument, the code given to the EsacParser is used. |
removeRhythm(sCode) | Returns the EsAC-code with all rhythm, phrase and bar indicators ("_",".", " ", "\n") removed (pitch string). Without argument, the code given to the EsacParser is used. |
removePunctuation(sCode) | Returns the EsAC-code with all phrase and bar indicators (" ", "\n") removed (pitch/rhythm string). Without argument, the code given to the EsacParser is used. |
getPhraseCount() | Returns number of phrases found in the EsAC code of the parser. |
getPhrase(nIdx) | Returns a string with the EsAC code of the phrase indicated by nIdx. |
getBarCount() | Returns number of bar found in the EsAC code of the parser. Note, that any upbeats at the beginning are counted as bar 1. |
getBar(nIdx) | Returns a string with the EsAC code of the bar indicated by nIdx. Note, that any upbeats at the beginning are counted as bar 1. |
getNote(nIdx) | Returns a string with the note found at nIdx. If nIdx does not point at the beginning of a note, then the function returns the next possible note. A note has the form [oct]*dig[acc][prol]* (no or several octave signs, a digit, no or several accidentials, no or more prolongation signs. |
getNotesAsArray(nIdx) | Returns an array of strings with the notes of the parser's Esac-Code. |