GUIDO Engine Javascript
The GUIDO Engine services are available as a Javascript libray.
The Javascript library API is similar to the C/C++ API:
- data structures like GuidoLayoutSettings,
GuidoDate, GuidoPageFormat, ParserError, GuidoVersion or LimitParams carry the the same name on Javascript side, including for the structures fields.
- constants like GuidoErrCode or GuidoElementSelector carry the the same name on Javascript side
- C++ classes that provide the interface to the library service are also similar in name and in methods names. These classes are enumerated below, with the corresponding methods.
This short Javascript documentation is intended as a quick reference. For more details, you should refer to the
C/C++ API. Examples of use are provided in the examples folder.
Functions:
init
shutdown
ar2gr
ar2grSettings
updateGR
updateGRSettings
freeAR
freeGR
getErrorString
getDefaultLayoutSettings
countVoices
getPageCount
getSystemCount
duration
findEventPage
findPageAt
getPageDate
gr2SVG
abstractExport
binaryExport
javascriptExport
setDrawBoundingBoxes
getDrawBoundingBoxes
getPageFormat
setDefaultPageFormat
getDefaultPageFormat
unit2CM
cm2Unit
unit2Inches
inches2Unit
resizePageToMusic
getVersion
checkVersionNums
getLineSpace
markVoice
openParser
closeParser
file2AR
string2AR
getStream
stream2AR
parserGetErrorCode
openStream
closeStream
writeStream
resetStream
Functions:
getPageMap
getStaffMap
getVoiceMap
getSystemMap
getTime
getPoint
getTimeMap
getPianoRollMap
Functions:
ar2PianoRoll
destroyPianoRoll
setLimits
enableKeyboard
getKeyboardWidth
enableAutoVoicesColoration
setRGBColorToVoice
setHtmlColorToVoice
enableMeasureBars
setPitchLinesDisplayMode
svgExport
javascriptExport
Functions:
openMusic
closeMusic
openVoice
closeVoice
openChord
closeChord
insertCommata
openEvent
closeEvent
addSharp
addFlat
setEventDots
setEventAccidentals
setOctave
setDuration
openTag
openRangeTag
endTag
closeTag
addTagParameterString
addTagParameterInt
addTagParameterFloat
setParameterName
setParameterUnit
GuidoParser Opaque pointer
NodeAR Opaque pointer
NodeGR Opaque pointer
GuidoStream Opaque pointer
PianoRoll Opaque pointer
Sample code
Taken from examples/svgExport and making use of
jQuery
<script type="text/javascript" src="libGUIDOEngine.js"></script>
<script>
var guidoEngine;
function processGMN() {
var p = guidoEngine.openParser();
var ar = guidoEngine.string2AR(p, $("#gmnSandbox").val());
guidoEngine.closeParser(p);
var gr = guidoEngine.ar2gr(ar);
var result = guidoEngine.gr2SVG(gr, 1, true, 0);
guidoEngine.freeGR(gr);
guidoEngine.freeAR(ar);
$("#canvasContainer").html(result);
}
$( document ).ready(function() {
guidoEngine = new Module.GuidoEngineAdapter;
guidoEngine.init();
$("#gmnSandbox").on('keyup', processGMN);
});
$(window).unload(function(){
guidoEngine.shutdown();
delete guidoEngine;
});
</script>