Cleaning up the Cruft
I spent most of this weekend cleaning up the HTML5 music notation code - tests, refactoring, style fixes, etc. While doing this, I threw away lots of cruft, and started rewriting almost all the layout and formatting code. After looking at and studying lots of scores and tabs, it turned out that I really had to rethink the architecture of the layout management pieces, to allow for the correct formatting and placement of modifiers, accidentals, multi-voice note-heads etc.
I now have a much nicer design that should accommodate for these intricacies nicely, and am part way through implementing it. The design involves maintaining separate contexts for groups of Tickables (which is an abstraction for anything with a duration, such as notes, tabs, lyric-pieces, or chords) and Modifiers (an abstraction which includes accidentals, dots, bends, etc.) Higher-level formatters can be plugged in that work within these contexts to size, kern, and position the glyphs.
On the testing front, I have about 75 tests in, which its still barely enough to test the different scenarios and edge cases that occur in musical notation. I tend to add the tests for different components as I have a clearer picture of what the API looks like, primarily to avoid having to incessantly rejiggle the test code. One thing's for sure - I love QUnit, which is jQuery's JavaScript unit-testing suite. It's functional, elegant, and extremely simple to use.
All you need to do is write your tests, and QUnit takes care of managing, running, and reporting.
Anyhow, I do have a few things to show for all of this. First, is the support for note bends in tablature. Notice how the lower bend is pushed further to the right? This is because they're in the same ModifierContext.
I also added slides, hammerons, and pulloffs.
I fixed the size of the accidentals. (I hope this is correct.)
And finally, note-heads are correctly displaced for notes that are right next to each other.
That's all for this week, folks!






6 comments (imported from blogger)
http://edition-kainhofer.com/musicxml/
Nice work!
@atorox Yes, my current plan is to support Staves, Tabs, Chords, Lyrics, and Rhythm slashes.
As a musician and otherwise geek I truly appreciate the work you have done here. I can't wait until you get it up on a repository.
The first thought I had was you could make a bouncing ball type of play back where you could set a certain tempo. Really the possibilities are almost endless. I'm really kicking myself for not having previously thought of this.
genius.