Closed WolfgangDrescher closed 4 years ago
Am i correct that the xmlIds are taken from the MEI resource and if they are not set verovio is adding a random id?
Yes.
Are the xmlIds reliable to locate an elemente in the score?
Yes.
As far as i have seen verovio will not always return the same xmlId for an element if the id is not already set in the MEI file. Is this intended?
If the element does not have an XML:id in the MEI input data, verovio will generate a random-number ID. This random number ID will be different every time the score is loaded into verovio.
However, check out the --xml-id-seed
option which is designed for your usage case. This should allow the XML:ids to remain consistent. See issue https://github.com/rism-ch/verovio/issues/274
Would it not be more reliable the generate a hash out of the current note with for example pith, position, measure, etc. as an id instead of a random string?
That could be an interesting method of creating XML IDs. When I generate IDs for the Humdrum conversions to MEI, I use the location of the data within the original file as IDs. This allows graphical editing of the Humdrum data from the IDs that get passed to the SVG images of the notation.
Is it currently possible to render only a part of a score with the JavaScript toolkit? For example if i load a full [score] to verovio with loadData and then i only want to render [let's] say measure 4-8.
The official response is "yes, use XSLT" to extract the desired regions of music: https://www.w3schools.com/xml/xsl_client.asp Or if you are using node, then there are XML manipulation packages: https://stackoverflow.com/questions/14890655/the-best-node-module-for-xml-parsing
Of course, allowing such functionality within verovio would be useful (particularly when loading non-MEI data), although this would involve an ever-increasing code base that would make the JS toolkit larger in size and increase the complexity of maintenance over the long term. Adding such features should perhaps be to an optional module that contains C++ transformation and processing of MEI data that can be removed it not needed, or alternatively extractable to a separate toolkit for data-processing of MEI in C++ without the rendering code that is the main component of verovio.
Extraction of measures would become quite complex with XSLT (or other pre-processing systems), and the excerpt feature would be a useful feature for a wide range of projects, particularly for extracting musical examples for papers and similar, so embedding such a feature into verovio should be highly desireable. When extracting measures, there will be things like slurs, ties, octave lines, ligature lines, coloration lines, that need to be split that make the process quite complex to do as a preprocessing operation. Verovio internally already does all of the calculations that are necessary to extract a measure range, so it makes sense to add such a feature internally to verovio (and not as a pre-processing step).
In order to extract measures 4-8 from a score in the general case, the entire score needs to be rendered (without line breaks), and then line breaks need to be forced before measure 4 and after 8, and then the music on the resulting systems between measures 4 ad 8 would be output by verovio.
If not my current plan is to find the current page of the part i want to render with getPageWithElement and then render [that] page. Best case would be something like getMeasureWithElement(xmlId) or even getPositionWithElement(xmlId) that could return something like:
This will depend on what you are wanting. A general problem is that extracting measures would require relayout of the music. This is in particularly related to how to extract music that goes across system breaks. Do you want the original system breaks. Some of what you want could be done with post-processing of the SVG (such as with d3js.org). But I think you are wanting a more higher-level musical concept of extracted measures which is not possible as you are thinking here. The main problem being how to include broken ties, slurs, and other line-like objects.
Also when creating excerpts, there may be difference styles of the extraction. The main one being whether or not the time signature is included in the excerpt or not. MEI does not allow for an "invisible" time signature, but the @meter.unit
staffDef attribute must be preserved in order for the @tstamp
values to remain valid (hidden time signatures are implemented by removing @meter.count
).
Extraction of beats or partial measures adds the increased complexity of splitting notes/rests. This will also be related to how you want to display split notes, and different styles will be desired in different applications. Should a half note be displayed as a half note on beat 1 even though it extends off the end of the extraction range? Should it be converted to a quarter note with a hanging tie? If a half note is on the first beat but you want to extract the second beat, should there be no note visualized on beat two (as in the original music), or should there be a quarter note with a hanging tie to the left?
The Humdrum import to verovio has pre-processing that allows the extraction of measure ranges. Adding the line:
!!!filter: myank -m 4-8
to the data will extract the desired measures before converting into MEI for rendering in verovio:
The filter can also be added to the URL:
https://verovio.humdrum.org/?filter=myank%20-m4-8
Here is an example of extracting measures 4-8 in reverse (but not reversing the music within the measure):
I have not yet fully dealt with breaking items that have two endpoints. Extraction of measures is simpler in Humdrum and MusicXML compared to MEI, because MEI has single objects that may need to be split into a partial object, while Humdrum and MusicXML have two separate endpoints to describe the object (so when encountering an unclose/unopened object, that implied a partial object).
Move to the wishlist https://github.com/rism-ch/verovio/wiki/Low-priority-wish-list
For reference: this is implemented now in https://github.com/rism-digital/verovio/pull/2754 and can be crossed from the wishlist. Also note that for humdrum you can use myank -m 4-8
or a new -l
flag to select the range by line numbers: https://github.com/craigsapp/humlib/pull/55.
Is it currently possible to render only a part of a score with the JavaScript toolkit? For example if i load a full score to verovio with loadData and then i only want to render let's say measure 4-8.
If not my current plan is to find the current page of the part i want to render with
getPageWithElement
and then render that page. Best case would be something likegetMeasureWithElement(xmlId)
or evengetPositionWithElement(xmlId)
that could return something like:And then render only the specific part of the score
renderMeasure
/renderPosition(from, to)
.Am i correct that the xmlIds are taken from the MEI resource and if they are not set verovio is adding a random id? Are the xmlIds reliable to locate an elemente in the score? As far as i have seen verovio will not always return the same xmlId for an element if the id is not already set in the MEI file. Is this intended? Would it not be more reliable to generate a hash out of the current note with for example pitch, position, measure, etc. as an id instead of a random string?
Are there more methods on the JS toolkit that are not documented on the website (https://www.verovio.org/javascript.xhtml)? I saw that some methods are not marked as deprecated in the docs where in the code you get a deprecation warning. Like for example for
renderPage
.