ssb22 / jianpu-ly

Jianpu in Lilypond
http://ssb22.user.srcf.net/mwrhome/jianpu-ly.html
Apache License 2.0
70 stars 18 forks source link

Whatever to jianpu-ly converter please #41

Open suntong opened 1 year ago

suntong commented 1 year ago

Hi @ssb22, I know there is an unfinished + undocumented converter from MusicXML. I don't know if it is practically useful at this stage or not, would you check the XML at
https://www.hymnsandcarolsofchristmas.com/Hymns_and_Carols/angels_we_have_heard_on_high2.htm
please? There is an XML link in that page, and if you want to check more, there are tons of songs in XML as well on that site.

When I put "whatever" in the title, I didn't mean that we need to convert anything and everything, I meant whatever can be converted will do.

The reason I'm asking is that I had been hoping to have such tool to prepare my Christmas Carols before the end of the year (by which we only have about 2~3 months left), and I don't think the MusicXML can be finished within that time frame IMHO.

Thus, I'm proposing to convert from ABC notations instead, which would be 10 to 100 times simpler than handling/importing-from the XML files.

Take a look at this a simple example, the children's song Skip to my Lou:

X:1
T:Skip to my Lou
C:Traditional
M:4/4
R:reel
L:1/4
Q:1/2=90
K:G
"G"B2G2 | BB/B/d2 | "D"A2F2 | AA/A/ "C"c2 |
"G"B2G2 | BB/B/d2 | "C"Ac/c/ "D"AD | "G"G2 G2 |]

Which can be transcoded to jianpu-ly almost one-to-one, and a month or two will be far more than necessary to implement it. Please consider, if you don't have time now and cannot finish it before the end of the year it is still OK too. I just want to collect those famous songs I know (and keep them to myself).

More on ABC:
https://github.com/econrad003/music-abc

Further explanation can be found at
https://www.liturgytools.net/2014/01/abc-low-cost-music-notation-tools-for.html

scroll down to the section of
QUICK-REFERENCE GUIDE TO KEY ABC MUSIC NOTATION FEATURES FOR CHURCH-MUSICIANS

which begins with

This is not a full list of ABC commands.   It's simply a quick summary of some items that I've needed to look up often when writing up scores of religious music.

For the for the official ABC 2.1 standard, check out:
http://abcnotation.com/wiki/abc:standard:v2.1

Thanks

suntong commented 1 year ago

Oh, besides the aforementioned urls that contain musics in abc notation, the following collections do as well, if you need more test cases:

https://github.com/Bill-Gray/abc/blob/master/xmas.abc https://github.com/Bill-Gray/abc/blob/master/xmas2.abc https://github.com/Bill-Gray/abc/blob/master/xmas3.abc

and there're tons of tons of other music in abc notation besides these.

suntong commented 12 months ago

Which can be transcoded to jianpu-ly almost one-to-one

As POC, check out the one-to-one conversion implemented in Perl, abc2jp.pl

NB, to prevent recursive dead loop, the "crotchet" is coded as XZM first then converted by sed next:

$ abc2jp.pl test1.abc | sed 's/XZM/c/g'
title=Skip to my Lou
4/4
%% tempo: 2=90
1=G
c7 - c5 -  | c7 q7 q7 c2' -  | c6 - c4 -  | c6 q6 q6  c1' -  |
c7 - c5 -  | c7 q7 q7 c2' -  | c6 q1' q1'  c6 c2  | c5 -  c5 -  

It can be directly used by jianpu-ly --

Commit: add Skip-to-my-Lou

ssb22 commented 12 months ago

Thanks but that won't work because it doesn't adjust the numbers to fit the key of the piece. You might hear that the second note in Bar 3 is flat as a result. Also I'm not sure about the rhythm handling.

The full ABC standard is quite a lengthy document: it looks like writing a parser that can cope with all of it is almost on the same level as writing a MusicXML parser, which makes me wonder if we should instead try the abc2xml tool and see if we can read the resulting MusicXML.

suntong commented 12 months ago

Oh, I had always thought that the MusicXML converter is unfinished; and besides, the usage is undocumented as well.

Would you give it a try please? Like this Silent Night, Holy Night for example; its MusicXML is available at https://abcnotation.com/getResource/downloads/code_/silent-night-holy-night.xml?a=www.stephenmerrony.co.uk/ABC/Carols/S/Silent_Night_28_Full/0000

Thanks

ssb22 commented 12 months ago

Yes MusicXML is unfinished. But ABC is not even started :) and I'm wondering if right now it would be easier to do more of MusicXML than to start ABC (because ABC is more complex than it looks, if you want to read all the possible things they might do)

ssb22 commented 12 months ago

That piece had 32nd notes in it, which weren't supported by our MusicXML parser, added now

ssb22 commented 12 months ago

It looks like the abc2xml they ran didn't set the clef properly (so too many ledger lines in the tenor). And we're not handling titles and things correctly.

(Incidentally the musicxml file is wrong: Gruber was not the lyricist. Gruber wrote the tune to lyrics by Mohr. This might be another abc2xml issue though.)

ssb22 commented 12 months ago

Tempted to add a "don't typeset it, just spit out the jianpu-ly format" option to this MusicXML converter, in case any edits need to be done. (The idea was to make it good enough so we won't need edits, but then if the musicxml itself is going to be wrong we might want to edit anyway....)

suntong commented 12 months ago

Yep, "whatever" that can help us reach the end goal. Since the abc2xml tool is also written in Python too, it might be easier to leverage that, but,

MusicXML is unfinished. But ABC is not even started

whatever the easiest route.