alexanderkoller / aaba

Automatic generation of barbershop arrangements
3 stars 0 forks source link

String index out of range: 0 #7

Closed felleg closed 2 years ago

felleg commented 3 years ago

I am seeing an error when running the 1.1 release of the aaba program:

$ java -jar aaba-1.1.jar ~/Downloads/input.abc -o output.abc
Using default configuration.
Reading melody and chords from: /home/legerf/Downloads/input.abc
Writing arrangement to: output.abc

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47)
    at java.base/java.lang.String.charAt(String.java:693)
    at de.saar.coli.arranger.abc.AbcParser.parseAbcNote(AbcParser.java:119)
    at de.saar.coli.arranger.abc.AbcParser.read(AbcParser.java:96)
    at de.saar.coli.arranger.Arrange.main(Arrange.java:59)

The content of my abc file is the following:

X:1
T:Title
%%scale 0.83
%%pagewidth 21.01cm
%%leftmargin 1.00cm
%%rightmargin 1.00cm
L:1/8
M:4/4
I:linebreak $
K:C
V:1 treble nm="Piano" snm="Pno."
V:1
 z6 z"C" C- | CCA,G,"C7" CCA,G, |"G7" D"Gm7b5"^C-C"G7"D- D3 D- | DDA,G, DDA,G, | %4
"C" CA,-A,G,- G,3"C7" C- |$ CCA,G, CCA,G, |"G7" D"Gm7b5"^C-C"G7"D- D3"Em" E |"D7" ^FEDE"G7" =FEDE | %8
"C" C8 | z8 | z8 | z8 | z8 | z8 |$ z8 | z8 | z8 | z8 | z8 | z8 | z8 | z8 | z8 | z8 | z8 | z8 | z8 | %27
 z8 | z8 | z8 | z8 | z8 |] %32

The abc file was generated through these steps:

  1. Create a score in Musescore 3 (treble clef only, 1 voice only)
  2. Export as uncompressed MusicXML file
  3. Use https://wim.vree.org/js/xml2abc-js.html to convert the musicxml file to .abc

Here is a screenshot of the score in MuseScore 3 image

alexanderkoller commented 3 years ago

Hi Félix,

thanks for your interest in aaba, and also for the detailed bug report!

Can you give me a few days to look into this?

My first guess would be that the ABC format is really quite finicky, and it is possible that my ABC parser makes different assumptions than the xml2abc conversion tool. At first glance, I find the chords that are just squished without spaces in between the notes in measure 3 a bit suspicious, but I'll look at it in more detail.

felleg commented 3 years ago

Of course! :)

felleg commented 3 years ago

Just FYI, I gave the latest release another go and despite slow chord changes (see attachment), the same error arises.

I ran the java runtime in this docker image: https://hub.docker.com/_/openjdk

bonjour.abc.txt

image

alexanderkoller commented 2 years ago

Hi, I finally had some time to look into this issue. As it turns out, your ABC file uses a lot of features that are allowed by the ABC notation, but that aaba's parser for ABC files can't handle yet. I have opened separate issues for these, which are listed above.

I have broken down your ABC file to make it readable for aaba; it then looks as in #13. However, for some reason it doesn't get rendered correctly by the ABC Converter.

The upshot is that I'll have to do a bit more work to support the ABC generated by xml2abc. This may take me a few weeks. If you have the time to try out other tools for rendering ABC files, you could check if it's maybe just a problem with the ABC Converter and the arrangement in #13 can be rendered correctly by other ABC viewers. That would help me figure out what's happening there.

felleg commented 2 years ago

I see! Thanks for the diagnosis, I will see what I can find.

alexanderkoller commented 2 years ago

Hi, I reimplemented the ABC parser, and it can now read and arrange your file. There are still some limitations: I don't handle rests and ties yet, and I'm not sure the chords are treated correctly. But at least we get something.

Here is the best arrangement, you can visualize it with ABC converter:

%abc-2.1
X:1
T:Title
C:Automatically arranged by AABA
M:4/4
L:1/8
K:C
V:Tn middle=B, clef=treble-8 name="Tn"  snm=""
V:Ld middle=B, clef=treble-8 name="Ld"  snm=""
V:Br clef=bass name="Br"  snm=""
V:Bs clef=bass name="Bs"  snm=""
%%score (Tn Ld) (Br Bs)
V:Tn
   G1 G1 G1 E1 E1 E1 E1 E1 | E1 F1 F1 F1 F1 F3 | F1 F1 F1 G1 F1 F1 F1 G1 | F1 G1 G1 G1 G1 E3 | E1 E1 E1 E1 E1 E1 E1 E1 | E1 F1 F1 F1 F1 F3 | G1 A1 ^F1 ^F1 ^F1 G1 F1 F1 | F1 G8 |]
V:Ld
   C1 C1 C1 A,1 G,1 C1 C1 A,1 | G,1 D1 ^C1 C1 D1 D3 | D1 D1 D1 A,1 G,1 D1 D1 A,1 | G,1 C1 A,1 A,1 G,1 G,3 | C1 C1 C1 A,1 G,1 C1 C1 A,1 | G,1 D1 ^C1 C1 D1 D3 | E1 ^F1 E1 D1 E1 ^F1 E1 D1 | E1 C8 |]
w: 
V:Br
   E1 E1 E1 C1 C1 ^A,1 ^A,1 C1 | ^A,1 B,1 _B,1 _B,1 B,1 B,3 | B,1 B,1 B,1 B,1 B,1 B,1 B,1 B,1 | B,1 E1 E1 E1 E1 C3 | ^A,1 ^A,1 ^A,1 C1 ^A,1 ^A,1 ^A,1 C1 | ^A,1 B,1 _B,1 _B,1 B,1 B,3 | B,1 C1 C1 C1 C1 B,1 B,1 B,1 | D1 E8 |]
V:Bs
   C,1 G,1 C,1 G,1 C,1 G,1 G,1 G,1 | C,1 G,1 G,1 G,1 G,1 G,3 | G,1 G,1 G,1 D,1 D,1 G,1 G,1 D,1 | D,1 C,1 C,1 G,1 C,1 C,3 | G,1 G,1 G,1 G,1 C,1 G,1 G,1 G,1 | C,1 G,1 G,1 G,1 G,1 G,3 | G,1 D,1 A,1 A,1 A,1 D,1 G,1 G,1 | G,1 G,8 |]
felleg commented 2 years ago

Thanks a ton! I will mark this issue as closed until proved otherwise :)