Hi Jacques, Am Mo., 27. Sept. 2021 um 00:48 Uhr schrieb Jacques Menu <imj-muz...@bluewin.ch>: > > Hello folks, > > The recent posts on this subject show there is interest in the matter. Sorry > for the length of this one...
Tbh, most of the mor detailed stuff is way over my head.. > > My work was initially homed by Grame’s libmusicxml2 library as an example of > what it could be used for, in the lilypond branch at > https://github.com/grame-cncm/libmusicxml/tree/lilypond. > > Dom Fober, the author and maintainer of libmusicxml2, and I decided some time > ago to separate things for practical reasons, and I now push to the GitHub > repository I created at https://github.com/jacques-menu/musicformats. Good to know. > I’m currenly finalizing version 1.0.0, which explains why the test and master > branches are not up to date - only the dev branch is currently. > > The musicformats library is structured along the lines shown at page 16 in > https://github.com/jacques-menu/musicformats/blob/dev/doc/maintainersGuideToMusicFormats/maintainersGuideToMusicformats.pdf > (the users’s guide is not yet ‘usable’, sorry). > > The central component of musicformats is MSR (Music Score Representation), > from which various formats can be obtained. > > In this picture, we see that we could create MusicXML output from within the > LilyPond implementation going along the LilyPond - LPSR - MSR - MXSR - > MusicMXL path. The missing part would be the creation of an LPSR (LilyPond > Score Representation), the others already exist. > > As an example, the LPSR representation and LilyPond output produced by: > > xml2ly basic/HelloWorld.xml -display-lpsr > LPSR_contents.txt 2>&1 > > are in the attached LPSR_contents.txt file. > > The resulting score is: > > > Jean and I have had discussions as to how the export to MusicXML could be > tackled on the LilyPond side, but nothing concrete yet. Some of the > information needed is readily accessible inside LilyPond, but grabbing the > remaining part is not easy. > > The musicformats repository contains examples using the library to create > scores in C++ applications, among them: > > jacquesmenu@macmini: ~/musicformats-git-dev/files/musicxml > > Mikrokosmos3Wandering -a > What Mikrokosmos3Wandering does: > > This multi-pass generator creates a textual representation > of Zoltán Kodály's Mikrokosmos III Wandering score. > It performs various passes depending on the output generated. > > Other passes are performed according to the options, such as > displaying views of the internal data or printing a summary of the score. > > The activity log and warning/error messages go to standard error. > > jacquesmenu@macmini: ~/musicformats-git-dev/files/musicxml > > Mikrokosmos3Wandering -apropos generate > --- Help for atom "generate" in subgroup "Generated output" > -generate, -gen GENERATED_OUTPUT_KIND > Generate GENERATED_OUTPUT_KIND code to the output. > The 5 generated output kinds available are: > braille, guido, lilypond, midi and musicxml. > The default is 'LilyPond output'. > > (midi output is actually not yet available, though) > > For example, one can run: > > jacquesmenu@macmini: ~/musicformats-git-dev/files/musicxml > > Mikrokosmos3Wandering -generate musicxml -o Mikrokosmos3Wandering.xml > -trace=passes > > %-------------------------------------------------------------- > Pass 1: Creating the MSR score with the functions > %-------------------------------------------------------------- > *** MusicXML warning *** :91: The staffMeasuresSlicesSequence of staff > "Part_OnlyPart_Staff_One" is null > *** MusicXML warning *** :91: The staffMeasuresSlicesSequence of staff > "Part_OnlyPart_Staff_Two" is null > > %-------------------------------------------------------------- > Pass 2: Convert the MSR score into a second MSR > %-------------------------------------------------------------- > > %-------------------------------------------------------------- > Pass 3: Translating the MSR into an MXSR > %-------------------------------------------------------------- > > %-------------------------------------------------------------- > Pass 4: Convert the MXSR into MusicXML text > %-------------------------------------------------------------- > > Opening file 'Mikrokosmos3Wandering.xml' for writing > Warning message(s) were issued for input line 91 > > > This creates file Mikrokosmos3Wandering.xml, attached. > > > The functionality of musicformats is available as API C++ functions. For > example, conversion from MusicXML data to LilyPond, as used by xml2ly and > Grame’s experimental web site at https://libmusicxml.grame.fr, is available > through these functions: > > /*! > \brief Converts a MusicXML representation to the LilyPond format. > \param file a file name > \param out the output stream > \return an error code (\c musicFormatsError::k_NoError when success) > */ > EXP musicFormatsError musicxmlfile2lilypond ( > const char *file, const optionsVector& options, std::ostream& out, > std::ostream& err); > > /*! > \brief Converts a MusicXML representation to the LilyPond format. > \param fd a file descriptor > \param out the output stream > \return an error code (\c musicFormatsError::k_NoError when success) > */ > EXP musicFormatsError musicxmlfd2lilypond ( > FILE* fd, const optionsVector& options, std::ostream& out, std::ostream& > err); > > /*! > \brief Converts a MusicXML representation to the LilyPond format. > \param buffer a string containing MusicXML code > \param out the output stream > \return an error code (\c musicFormatsError::k_NoError when success) > */ > EXP musicFormatsError musicxmlstring2lilypond ( > const char *buffer, const optionsVector& options, std::ostream& out, > std::ostream& err); > > > I’m no Python nor Scheme developper, but I guess this can be used with > suitable interfaces from applications written in these languages. > > I’ll be happy to collaborate to using musicformats to export from within > LilyPond if such an attempt is done. Well, I'm afraid I can't help coding, C++ is not my world. Though, I'd really love to see LilyPond being able to do: lilypond --musicxml file.ly resulting in a correct file.xml. Best, Harm