Problem with headers

23 views
Skip to first unread message

Daniel Nicault

unread,
Mar 10, 2015, 4:11:32 AM3/10/15
to ab...@googlegroups.com
Hi,

I'm newbee to abc4j, if I get an ABC from the session like :

X: 1
T: Morrison's
R: jig
M: 6/8
L: 1/8
K: Edor
|:E3 B3|EBE AFD|EDE B3|dcB AFD|
E3 B3|EBE AFD|G3 FGA|dAG FED:|
Bee fee|aee fee|Bee fee|a2g fed|
Bee fee|aee fee|gfe d2A|BAG FGA|
Bee fee|aee fee|Bee fee|faf def|
g3 gfe|def g2d|edc d2A|BAG FED|
I put it in a a file like "sample.abc", abc4j don't like the space after ":" in the headers. 

this code (in groovy) :

def abcFile = new File("/home/daniel/Dropbox/fichiers_ABC/sample.abc")
def book = new TuneBook(abcFile)
println("Nb of tunes in ${abcFile.name} : ${book.size()}")
println("the headers are : ${book.tunesHeaders}")
def aTune = book.getTune(1)
println(" Tune properties : ${aTune.properties} " )

give this output :

/usr/lib/jvm/java-7-openjdk-amd64/bin/java Nb of tunes in sample.abc : 1
the headers are : [(-1)@1426434633]
Exception in thread "main" java.lang.NullPointerException: Cannot get property 'properties' on null object

after I remove all spaces after ":" in the headers the output is what I expect:
 
/usr/lib/jvm/java-7-openjdk-amd64/bin/java 
the headers are : [[Morrisons](1)@1757708679]
 Tune properties : [transcriptionNotes:null, multiPartsDefinition:null, origin:null, titles:[Morrisons], elemskip:0, music:[6/8, {AccidentalType.SHARP, AccidentalType.NATURAL, AccidentalType.NATURAL, AccidentalType.SHARP, AccidentalType.NATURAL, AccidentalType.NATURAL, AccidentalType.NATURAL}, |:, E @(L:7, C:3; 43)(l=2), abc.notation.NotesSeparator@6cedb374, B @(L:7, C:6; 46)(l=2), |, E @(L:7, C:9; 49)(l=1), B @(L:7, C:10; 50)(l=1), E @(L:7, C:11; 51)(l=1), abc.notation.NotesSeparator@69a0bc8a, A @(L:7, C:13; 53)(l=1), F @(L:7, C:14; 54)(l=1), D @(L:7, C:15; 55)(l=1), |, E @(L:7, C:17; 57)(l=1), D @(L:7, C:18; 58)(l=1), E @(L:7, C:19; 59)(l=1), abc.notation.NotesSeparator@37ba3e33, B @(L:7, C:21; 61)(l=2), |, D' @(L:7, C:24; 64)(l=1), C' @(L:7, C:25; 65)(l=1), B @(L:7, C:26; 66)(l=1), abc.notation.NotesSeparator@2449a2da, A @(L:7, C:28; 68)(l=1), F @(L:7, C:29; 69)(l=1), D @(L:7, C:30; 70)(l=1), |, abc.notation.EndOfStaffLine@5e62a8d2, E @(L:8, C:1; 73)(l=2), abc.notation.NotesSeparator@1f39a367, B @(L:8, C:4; 76)(l=2), |, E @(L:8, C:7; 79)(l=1), B @(L:8, C:8; 80)(l=1), E @(L:8, C:9; 81)(l=1), abc.notation.NotesSeparator@116cf35, A @(L:8, C:11; 83)(l=1), F @(L:8, C:12; 84)(l=1), D @(L:8, C:13; 85)(l=1), |, G @(L:8, C:15; 87)(l=2), abc.notation.NotesSeparator@7da122, F @(L:8, C:18; 90)(l=1), G @(L:8, C:19; 91)(l=1), A @(L:8, C:20; 92)(l=1), |, D' @(L:8, C:22; 94)(l=1), A @(L:8, C:23; 95)(l=1), G @(L:8, C:24; 96)(l=1), abc.notation.NotesSeparator@37ddbf6e, F @(L:8, C:26; 98)(l=1), E @(L:8, C:27; 99)(l=1), D @(L:8, C:28; 100)(l=2), :|, abc.notation.EndOfStaffLine@3f42eb69, B @(L:9, C:1; 104)(l=1), E' @(L:9, C:2; 105)(l=1), E' @(L:9, C:3; 106)(l=1), abc.notation.NotesSeparator@426d5af1, F' @(L:9, C:5; 108)(l=1), E' @(L:9, C:6; 109)(l=1), E' @(L:9, C:7; 110)(l=1), |, A' @(L:9, C:9; 112)(l=1), E' @(L:9, C:10; 113)(l=1), E' @(L:9, C:11; 114)(l=1), abc.notation.NotesSeparator@196da649, F' @(L:9, C:13; 116)(l=1), E' @(L:9, C:14; 117)(l=1), E' @(L:9, C:15; 118)(l=1), |, B @(L:9, C:17; 120)(l=1), E' @(L:9, C:18; 121)(l=1), E' @(L:9, C:19; 122)(l=1), abc.notation.NotesSeparator@6dc00fa9, F' @(L:9, C:21; 124)(l=1), E' @(L:9, C:22; 125)(l=1), E' @(L:9, C:23; 126)(l=1), |, A' @(L:9, C:25; 128)(l=2), G' @(L:9, C:27; 130)(l=1), abc.notation.NotesSeparator@5c445889, F' @(L:9, C:29; 132)(l=1), E' @(L:9, C:30; 133)(l=1), D' @(L:9, C:31; 134)(l=1), |, abc.notation.EndOfStaffLine@b10b9b2, B @(L:10, C:1; 137)(l=1), E' @(L:10, C:2; 138)(l=1), E' @(L:10, C:3; 139)(l=1), abc.notation.NotesSeparator@770f5aca, F' @(L:10, C:5; 141)(l=1), E' @(L:10, C:6; 142)(l=1), E' @(L:10, C:7; 143)(l=1), |, A' @(L:10, C:9; 145)(l=1), E' @(L:10, C:10; 146)(l=1), E' @(L:10, C:11; 147)(l=1), abc.notation.NotesSeparator@1111c0d7, F' @(L:10, C:13; 149)(l=1), E' @(L:10, C:14; 150)(l=1), E' @(L:10, C:15; 151)(l=1), |, G' @(L:10, C:17; 153)(l=1), F' @(L:10, C:18; 154)(l=1), E' @(L:10, C:19; 155)(l=1), abc.notation.NotesSeparator@248b6c02, D' @(L:10, C:21; 157)(l=2), A @(L:10, C:23; 159)(l=1), |, B @(L:10, C:25; 161)(l=1), A @(L:10, C:26; 162)(l=1), G @(L:10, C:27; 163)(l=1), abc.notation.NotesSeparator@3d600a0c, F @(L:10, C:29; 165)(l=1), G @(L:10, C:30; 166)(l=1), A @(L:10, C:31; 167)(l=1), |, abc.notation.EndOfStaffLine@6c33b94e, B @(L:11, C:1; 170)(l=1), E' @(L:11, C:2; 171)(l=1), E' @(L:11, C:3; 172)(l=1), abc.notation.NotesSeparator@37cae761, F' @(L:11, C:5; 174)(l=1), E' @(L:11, C:6; 175)(l=1), E' @(L:11, C:7; 176)(l=1), |, A' @(L:11, C:9; 178)(l=1), E' @(L:11, C:10; 179)(l=1), E' @(L:11, C:11; 180)(l=1), abc.notation.NotesSeparator@6a1cade4, F' @(L:11, C:13; 182)(l=1), E' @(L:11, C:14; 183)(l=1), E' @(L:11, C:15; 184)(l=1), |, B @(L:11, C:17; 186)(l=1), E' @(L:11, C:18; 187)(l=1), E' @(L:11, C:19; 188)(l=1), abc.notation.NotesSeparator@dc8a29, F' @(L:11, C:21; 190)(l=1), E' @(L:11, C:22; 191)(l=1), E' @(L:11, C:23; 192)(l=1), |, F' @(L:11, C:25; 194)(l=1), A' @(L:11, C:26; 195)(l=1), F' @(L:11, C:27; 196)(l=1), abc.notation.NotesSeparator@ef28a30, D' @(L:11, C:29; 198)(l=1), E' @(L:11, C:30; 199)(l=1), F' @(L:11, C:31; 200)(l=1), |, abc.notation.EndOfStaffLine@554e5cfa], referenceNumber:1, group:null, notes:null, class:class abc.notation.Tune, key:{AccidentalType.SHARP, AccidentalType.NATURAL, AccidentalType.NATURAL, AccidentalType.SHARP, AccidentalType.NATURAL, AccidentalType.NATURAL, AccidentalType.NATURAL}, composer:null, information:null, book:null, history:null, discography:null, source:null, area:null, rhythm:jig]  

 

Is there a way to change that ?

thanks

Daniel 

iubito

unread,
Mar 11, 2015, 3:40:16 AM3/11/15
to ab...@googlegroups.com
Hi Daniel,
Are you using the downloaded JAR or the latest SVN version ?
The JAR is ABC 1.6 compatible more or less,
the latest SVN is ABC 1.6, 2, and allow some badly written ABC files. Not sure I've tested the "X: 1" vs "X:1".

Sylvain

Daniel Nicault

unread,
Mar 13, 2015, 8:46:10 PM3/13/15
to ab...@googlegroups.com
Hi Sylvain,

I gaot the SVN version and with this source (from tutorial) :

import abc.parser.TuneBook


public class ReadABC {
public static void main(String[] arg) {

def abcFile = new File("/home/daniel/Dropbox/fichiers_ABC/PSEA_4athome.abc")
def book = new TuneBook(abcFile)
def tunesNb = book.size()
println("Nb of tunes in ${abcFile.name} : ${tunesNb}")
def aTune = book.getTune(1)
println("Title is ${aTune.titles[0]}" )
println("key is : ${aTune.key}" )
}
}


and this ABC source :

X:1 
T:Brenda Stubbert's 
D:Altan - "The Red Crow" Brenda Stubbert's/Breen's-the ; 
M:4/4 
L:1/8 
R:highland 
K:Ador 
|:B|"Am"A/A/A (BA) GAAB|"Am"A/A/A (BA) edde|"G"G2 (BA) BGGB| "C"c2 (BA) "G"BGGB| |"Am"A/A/A (BA) GAAB|"Am"A/A/A (BA) edda|"G"gedB GABd|"Em"{d}e2 dB e"Am"AA:| |:B|"Am"A/A/A a2 A/A/A g2| "Am"Aage ageg|"G"G2 (BA) BGGB| "C"c2 (BA) "G"BGGB| |[1 "Am"A/A/A a2 A/A/A g2| "Am"Aage agea| "G"gedB GABd|"Em"{B}e2 dB "Am"eAA| |[2 "Am"A/A/A (BA) GAAB|"Am"A/A/A (BA) edda| "G"gedB GABd|"Em"{d}e2 dB "Am"eAA|]

here is the output :

/usr/lib/jvm/java-7-openjdk-amd64/bin/java -Didea.launcher.port=7536 -Didea.launcher.bin.path=/home/daniel/apps/idea-IC-139.1117.1/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/compilefontconfig.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/javazic.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rhino.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/java-atk-wrapper.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/icedtea-sound.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/zipfs.jar:/home/daniel/IdeaProjects/test/out/production/TinulacABCT:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-sql-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-jmx-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/commons-cli-1.2.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-xml-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/ant-1.9.4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-groovysh-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/jline-2.12.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/ant-launcher-1.9.4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/ant-antlr-1.9.4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-testng-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/commons-logging-1.1.1.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/servlet-api-2.4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-servlet-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/jsr166y-1.7.0.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/junit-4.11.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/xstream-1.4.7.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/ant-junit-1.9.4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-console-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/ivy-2.4.0-rc1.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/testng-6.8.8.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/xmlpull-1.1.3.1.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-bsf-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/jcommander-1.35.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-nio-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-swing-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/jansi-1.11.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-docgenerator-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/jsp-api-2.0.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-json-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/openbeans-1.0.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/bsf-2.4.0.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-templates-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-jsr223-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/multiverse-core-0.7.0.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-groovydoc-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-test-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/hamcrest-core-1.3.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/gpars-1.2.1.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/qdox-1.12.1.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-2.4.0-beta-4.jar:/home/daniel/apps/groovy-2.4.0-beta-4/lib/groovy-ant-2.4.0-beta-4.jar:/home/daniel/apps/abc4j/abc4j-read-only/lib/abc4j.jar:/home/daniel/apps/idea-IC-139.1117.1/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain ReadABC

Nb of tunes in PSEA_4athome.abc : 79
Exception in thread "main" java.lang.NullPointerException: Cannot invoke method getAt() on null object

the problem is that aTune alway return a null object.... 

Daniel

iubito

unread,
Mar 15, 2015, 5:30:54 AM3/15/15
to ab...@googlegroups.com
Strange, I 've no error with both tunes.

I'll commit my last work to the SVN.
Some things are "in progress", not finished.

One problematic bug known : if there is crashed tune in the book, the parser stops at this tune and doesn't parse the next ones... :-(

iubito

unread,
Mar 15, 2015, 6:29:04 AM3/15/15
to ab...@googlegroups.com
Check the last SVN, I've commited some changes
and tell me...

Daniel Nicault

unread,
Mar 15, 2015, 10:53:22 AM3/15/15
to ab...@googlegroups.com
WIth the las snv and the Oneill file provided ins the ressources directory this source work jus fine :
import abc.parser.TuneBook


public class ReadABC {
public static void main(String[] arg) {

        def abcFile = new File("/home/daniel/Dropbox/fichiers_ABC/OneillDos.abc")

def book = new TuneBook(abcFile)
        def tunesNb = book.size()
println("Nb of tunes in ${abcFile.name} : ${tunesNb}")
        def aTune = book.getTune(21)
//println("aTune : ${aTune}")
println("Title of tune 21 is ${aTune.titles[0]}" )

println("key is : ${aTune.key}" )
}
}

and produce  :

Nb of tunes in OneillDos.abc : 500
Title of tune 21 is : is The hag with the money
key is : null

Not realy.... ntice the key is : null

There is an error in the header of this tune :
 look at the m:.. just befor the M: line :
X:21
T:The hag with the money
C:anon.
O:Ireland
B:Francis O'Neill: The Dance Music of Ireland no. 21
R:Double jig
Z:Transcribed by Frank Nordberg - http://www.musicaviva.com
m:Mn = (3n/o/n/   
M:6/8
L:1/8
Q:3/8=128
K:D


after removing this line tue output is realy correct :

Nb of tunes in OneillDos.abc : 500
Title of tune 21 is The hag with the money
key is : {AccidentalType.SHARP, AccidentalType.NATURAL, AccidentalType.NATURAL, AccidentalType.SHARP, AccidentalType.NATURAL, AccidentalType.NATURAL, AccidentalType.NATURAL}

Probably some problems with  the parser ?

here is the tune (only one in the file) the produce the "NullPointerException: Cannot get property 'titles' on null object"

X:1
T:Brenda Stubbert's
M:4/4
L:1/8
K:Ador
|:B|"Am"A/A/A (BA) GAAB|"Am"A/A/A (BA) edde|"G"G2 (BA) BGGB| "C"c2 (BA) "G"BGGB|
|"Am"A/A/A (BA) GAAB|"Am"A/A/A (BA) edda|"G"gedB GABd|"Em"{d}e2 dB e"Am"AA:|
|:B|"Am"A/A/A a2 A/A/A g2| "Am"Aage ageg|"G"G2 (BA) BGGB| "C"c2 (BA) "G"BGGB|
|[1 "Am"A/A/A a2 A/A/A g2| "Am"Aage agea| "G"gedB GABd|"Em"{B}e2 dB "Am"eAA|
|[2 "Am"A/A/A (BA) GAAB|"Am"A/A/A (BA) edda| "G"gedB GABd|"Em"{d}e2 dB "Am"eAA|

I got overs abc with thesession.org and have the same error... 

If I replace the content of my file with the abc that produce a good output when in the original Oneill source, i have the same error ?

Well... I copy this brenda stubbert source in my file and put it in your ressources/OneillDos.abc and that produce the good aoutput  !

Nb of tunes in OneillDos.abc : 500
aTune : [Shandon bells](1)@803220424
Title of tune 1 is Shandon bells
key is : {AccidentalType.SHARP, AccidentalType.NATURAL, AccidentalType.NATURAL, AccidentalType.SHARP, AccidentalType.NATURAL, AccidentalType.NATURAL, AccidentalType.NATURAL}

Can I suspect a problem of file encoding ? 

There is somefing curious here : the TuneBook is alway loaded and  the number of tune in the book is alway correct, 
if there is no error in the abc file,  the Tune ca be loaded or not depending of the file where it is.... 
Reply all
Reply to author
Forward
0 new messages