Closed derkveen closed 9 months ago
You can use an additional filter to convert **kern-comp
into **kern
before converting to MusicXML:
composite | shed -e s/kern-comp/kern/X
The |
character is call a "pipe" which takes the output of composite
and sends it to the shed
tool (there is documentation for the shed tool, but it needs improvement, and one way would be to add this particular case).
The shed
tool is modeled after the unix sed
tool, but has some enhancements for processing Humdrum data. The search and replace string in shed/sed has this form s/original/repacement/
, where original can be plain text (as in the above example, or can be generalized to a regular expression.. The shed
tool uses extended regular expressions as implemented in PERL (specifically it is using the default in C++ which almost 100% matches the implementation in Javascript, so there are features such as \s
which means any whitespace character (space, newline, tab), and \d
means any digit ([0-9]
).
The shed
tool has additional features specific to Humdrum data. For example the search and replace string allows options which are place after the third slash in the search-and-replace string s/ / /
. In this case X
means only apply the search and replace to eXclusive interpretations. So if there were any text "kern-comp" elsewhere in the file in a comment or reference record, for example, it will not be changed.
The purpose of this categorization of **kern
data is to make it possible to allow multiple analysis tools to work on the same original data. The output of the composite tool could be sent to another analysis tool which ignores **kern-comp
to do some additional analysis of the original data.
More generally for any kern-?????
labels to regular kern:
composite | shed -e s/kern-.*/kern/X
where .*
means any text after the dash should be removed (such as in **kern-beat
or **kern-xxx
).
Exclusive interpretations usually do not include -
, and I use it for qualifying data spines to mark them as analysis data (such as perhaps **text-comp
, so the most general use of shed to remove the analytic qualifiers would be:
composite | shed -e s/(.*?)-.*/$1/X
Which would remove -?????
from any exclusive interpretation. .*?
means that cases such as **kern-comp-xxx
transforms to **kern
rather than **kern-comp
. Removing the ?
would result in **kern-comp
as the replacement string. $1
is the first capture group, indicated in the search string with parentheses.
So since there is a way of automatically converting analysis spines to regular spines using shed
, this filter needs to be done before converting to MusicXML if you want to export analytic spines.
Thanks, it works when using it in the editor: !!!filter: composite | shed -e s/kern-comp/kern/X and then compiling it and exporting it to musicXML.
When I create an additional spine by applying the 'compound rhythm' option, it is called '**kern-comp'. When I export to musicXML, this spine is skipped. If I remove the addition '-comp', it does export to musicXML nicely. It might be a small improvement if this could be done through a command, like with 'compile filters'?