This module is a IIFE (Immediately Invoked Function Expression) and it returns a var with the name of lpAdapter. This document contains its public API. The lilyPondAdapter.js module contains functions used to translate from lilypond format to Tone.js and vice versa.
use the script tag to add this file
<script src="path/to/lilyPondAdapter.js"></script>
this sets the score values on the lilyPondAdapter object
(object)
any:
nothing
// an example of the json parameter
var jsonConfig = {
"jsonType": "ScaleAssignment",
"keySig": "c \\major",
"clef": "treble",
"timeSig": "4/4",
"title": "Assignment",
"name": "Assignment on "+timeStamp,
"notes": notes,
"durations": durations,
"pickup": "",
"pickupLength": "",
"tempo": ' \"moderato\" 4 = 90',
"opus": assignmentNumber,
"composer": studentName
};
lpAdapter.setScoreParameters(jsonConfig);
this sets the score values on the lilyPondAdapter object
(object)
any:
nothing
// after the auto generated melody is created the following
// json is created as a parameter.
var jsonConfig = {
"jsonType": "CPMelody",
"keySig": keySig,
"clef": clef,
"timeSig": timeSig,
"title": title,
"name": title+" on "+timeStamp,
"notes": notes,
"durations": durations,
"notes2": notes2,
"durations2": durations2,
"diceStaff": myOrnStaff,
"pickup": pickup,
"pickupLength": "",
"tempo": tempo
};
lpAdapter.setCPMelodyParameters(jsonConfig);
this sets the chorale score values on the lilyPondAdapter object
(object)
any:
nothing
// example of json parameter for 4-part chorale
var jsonConfig = {
"jsonType": "chorale",
"keySig": keySig,
"clef": clef,
"timeSig": timeSig,
"title": title,
"name": title+" on "+timeStamp,
"notes1": voicesNotesAndDurations[0][0].slice(),
"durations1": voicesNotesAndDurations[0][1].slice(),
"notes2": voicesNotesAndDurations[1][0].slice(),
"durations2": voicesNotesAndDurations[1][1].slice(),
"notes3": voicesNotesAndDurations[2][0].slice(),
"durations3": voicesNotesAndDurations[2][1].slice(),
"notes4": voicesNotesAndDurations[3][0].slice(),
"durations4": voicesNotesAndDurations[3][1].slice(),
"pickup": pickup,
"pickupLength": "",
"tempo": tempo
};
lpAdapter.setChoraleScoreParameters(jsonConfig);
this sets the grand staff score values on the lilyPondAdapter object
any:
nothing
// example of json parameter for grand staff score
var json conFig = {
"jsonType": "pianoCadence",
"keySig": keySig,
"clef": clef,
"timeSig": timeSig,
"title": title,
"name": title+" on "+timeStamp,
"notes1": LeftRightNotesAndDurations[0][0].slice(),
"durations1": LeftRightNotesAndDurations[0][1].slice(),
"notes2": LeftRightNotesAndDurations[1][0].slice(),
"durations2": LeftRightNotesAndDurations[1][1].slice(),
"pickup": pickup,
"pickupLength": "",
"tempo": tempo,
"opus": assignmentNumber,
"composer": studentName
}
this function creates a lilypond file using the prevously save data
(boolean)
true includes an evaluation of the score compared to the correct answer
string:
the lilypond file
this function takes a lilypond string and turns it into two arrays of notes and durations used with ToneJS
(string)
object:
multi-dimensional array of notes and durations
var lilycode = "\\relative c' {c4 d e f g1}";
var results = translateLilyToToneJS(lilycode);
// results[0] = ["C4","D4","E4","F4","G4"]
// results[1] = ["4n","4n","4n","4n","1n"]
this function returns the keySig, tempo and timeSig from the lilyPondAdapter object
object: