Important structure change (read this if it doesn't compile after a SVN update!)

29 views
Skip to first unread message

iubito

unread,
Nov 21, 2010, 10:36:34 AM11/21/10
to abc4j
I've just commited in SVN trunk a major change in abc.notation
package.

Music is not in Tune.java, it has its own .java file.
Music no more extends Vector, it contains a collection of Voice
Voice extends Vector and contains the datas (music elements).

/!\ Your code may not compile /!\
the fixes should be easy :
1) replace : import abc.notation.Tune.Music;
by : import abc.notation.Music;
2) replace : Tune.Music myMusic = myTune.getMusic();
by : Music myMusic = myTune.getMusic();
3) replace : for (int i = 0; i<myMusic.size(); i++) { ...
myMusic.elementAt(i)... }
by : Voice voice = myMusic.getVoice(1);
for (int i = 0; i<voice.size(); i++) { ... voice.elementAt(i)... }

to iterate over all voices, use myMusic.getVoices().iterator();

To make it clear, here is the structure of a Tune
Tune :
- title(s)
- composer
- ... other textual infos
- defaultPart (if no P:x instruction it's the only Part of the Tune,
else it contains the data before P:A)
- parts
- getMusicForGraphicalRendition() <- optimised for printing/displaying
- getMusic() <- a bit raw...
- getMusicForAudioRendition() <- will (todo job) be optimised for
audio converting (MIDI)

Part :
- label
- music

Music :
- voices
- addElement(voiceNumber, musicElement)
- some Voice methods kept for compatibility, which apply on first
voice
- append(Music) <- used by Tune.getMusic...() to append parts

Voices (extends Vector) :
- vector of music element
- instrument, volume and other MIDI-like infos
- addElement(musicElement)
- getLowest/getHighest/... useful methods manipulating music elements

There is also a concept of Bar which is not yet used but will help to
know what is in bar number 2 on voice 1 and voice 2 for example.

This is just in the music model. Parser doesn't parse voices in ABC,
MusicXML and MIDI doesn't export them, or badly. JTune prints voice 1
then voice 2, there is some new job to there :-)

Wojtek Borzynski

unread,
Jan 19, 2011, 2:36:19 PM1/19/11
to abc4j
Hi.

Are there any plans to implement parsing voices, exporting them to
MIDI or displaying them in the generated scores?

On Nov 21 2010, 3:36 pm, iubito <iub...@gmail.com> wrote:
> I've just commited in SVN trunk a major change in abc.notation
> package.
>
> Music is not in Tune.java, it has its own .java file.
> Music no more extends Vector, it contains a collection ofVoiceVoiceextends Vector and contains the datas (music elements).
>
> /!\ Your code may not compile /!\
> the fixes should be easy :
> 1) replace : import abc.notation.Tune.Music;
> by : import abc.notation.Music;
> 2) replace : Tune.Music myMusic = myTune.getMusic();
> by : Music myMusic = myTune.getMusic();
> 3) replace : for (int i = 0; i<myMusic.size(); i++) { ...
> myMusic.elementAt(i)... }
> by :Voicevoice= myMusic.getVoice(1);
> for (int i = 0; i<voice.size(); i++) { ...voice.elementAt(i)... }
>
> to iterate over all voices, use myMusic.getVoices().iterator();
>
> To make it clear, here is the structure of a Tune
> Tune :
> - title(s)
> - composer
> - ... other textual infos
> - defaultPart (if no P:x instruction it's the only Part of the Tune,
> else it contains the data before P:A)
> - parts
> - getMusicForGraphicalRendition() <- optimised for printing/displaying
> - getMusic() <- a bit raw...
> - getMusicForAudioRendition() <- will (todo job) be optimised for
> audio converting (MIDI)
>
> Part :
> - label
> - music
>
> Music :
> - voices
> - addElement(voiceNumber, musicElement)
> - someVoicemethods kept for compatibility, which apply on firstvoice
> - append(Music) <- used by Tune.getMusic...() to append parts
>
> Voices (extends Vector) :
> - vector of music element
> - instrument, volume and other MIDI-like infos
> - addElement(musicElement)
> - getLowest/getHighest/... useful methods manipulating music elements
>
> There is also a concept of Bar which is not yet used but will help to
> know what is in bar number 2 onvoice1 andvoice2 for example.
>
> This is just in the music model. Parser doesn't parse voices in ABC,
> MusicXML and MIDI doesn't export them, or badly. JTune printsvoice1
> thenvoice2, there is some new job to there :-)

iubito

unread,
Jan 20, 2011, 2:59:24 AM1/20/11
to abc4j
Hi Wojtek
YES !! :)

first thing, as I work on the parser (see the other topic), is to
parse voice and put music element in the structure of part and voices.
Once done, I'll submit to the SVN.

Later *we* will have to build multi-voice MIDI export and score
rendering.

Wojtek Borzynski

unread,
Jan 21, 2011, 6:12:06 PM1/21/11
to abc4j
That's great!
I'm asking because I am currently working on my final year computer
science project,which deals with musical similarity. I chose to use
ABC as the data format and I found your library very useful, but I
need to be able to represent and interpret voice information. I'm sure
you are very busy, but do you have a rough idea of when the new
parser, etc will be made available?

iubito

unread,
Jan 22, 2011, 3:46:01 AM1/22/11
to abc4j
Very very soon :)

iubito

unread,
Feb 7, 2011, 3:36:31 PM2/7/11
to abc4j
The new parser is now available in the SVN.
With some more important code changes, especially about TuneParser and
TuneBook.

Here is the concept.
A new TuneParser().parse(...) creates a abc.notation.Tune
but the old TuneBook was a single object which did parsing, writing
(saveTo) and tunes collection. This is now exploded into parser,
abc.notation.TuneBook (the tune collection), and an extender
AbcTuneBook which keep tracks of the ABC source string, and saveTo
method...

Like a Tune, a TuneBook has header information (fields before the
first X:) such as B:My book... all these informations are in a
abc.notation.TuneInfos object. This should be transparent as I kept
all setBook/getBook methods in Tune object.

Parser listeners : as the "source to token" part is managed by
parboiled lib, listener no more listen for invalidToken, validToken...
there is tuneBegin(), tuneEnd(), and noTune().
tuneEnd had only one parameter, now it has a second, a AbcNode
structure of tokens/values created by the parser.

scanner package has been removed, no more used.
mostly all element are PositionableInCharStream, it makes more
elements than note (in previous version) selectable / clickable in
swing rendering (chords, key sig, tempo, barlines, decorations...)

Parsing error message should be improved.

In previous version, parsing header and not music was 10 times faster
than parsing the whole content. Now it's "only" 3 times faster.
Parboiled is slow for a very very tiny file but very very fast for big
files, and it parses more things than it existed before. You can
explore the AbcNode structure to discover what is parsed, set
AbcParserAbstract.DEBUG to true to print the parsing tree.

Some new objects in abc.notation package, such as MeasureRepeat.
A new package abc.instructions which will have meta-comment like %
%MIDI program 42

abcynth program was updated but not fully tested (e.g. tune book
saving)

I continue to check the grammar against a lot of files found on the
web, but some are really badly writed.
One bug I'll try to fix, the tunebook parsing stops when a tune has an
error.... it should continue to next tune.

Waiting for your comments and report!
Sylvain

Wojtek Borzynski

unread,
Feb 7, 2011, 5:12:49 PM2/7/11
to abc4j
Great ! Going to download and start testing with my project. Thanks
for all your hard work :)
Reply all
Reply to author
Forward
0 new messages