Multi platform Music notation with Haxe NME – part 1 – Goals

Posted on September 6, 2012


I’ve been working on solutions for music notation for a long time. It all started in the mid 90-s when I had the opportunity to write a book about sight-singing for choir singers. For this I had to produce hundreds of music examples, and I needed a way to get them in an editable vector graphic format. At the time, there was no notation program that could create musical examples exportable in a suitable vector graphics format, so I created my own, using Visual Basic. The code was a mess, but it did the job! Next step was a project in Borland Delphi, where I learned the fundamentals in OOP, RAD programming, IDEs with modernities like code completion etc…

Now, several years later, after some years with Flash/Flex, I’m finally here using Haxe and NME. There’s now a working solution that runs under Html5, Flash and Windows — all with the same codebase — thanks to the fantastic Haxe NME project. I’m not ready yet, but the fundamentals are there. I can now produce music examples with what could be called professional level layout for both screen and print resolutions. And seeing the same codebase running on several platforms, both in the browser and on the desktop is really amazing!

Here’s the same testexample displayed using different resolutions in the browser (html5 target) and as a desktop app (windows target):

So, here I will try to describe what the goals are, what I’ve achieved this far, some about describing the challenges in transforming the exclusive esthetically demanding hand-craft-art called “music engraving” to objects, bezieer calculations, embeddable svgs etc. And also about the programming decisions, problems solved and unsolved etc.

Let’s start by saying that I’m not a professional programmer, I’m a musician/music teacher with musical theory as specialization. So don’t expect the most clever programming solutions in all situations. Sorry haxers, no fancy macros here! Nevertheless, I’m proud with what I’ve accomplished this far, and for sure I wouldn’t be if it was the combination of fantastic tools — Haxe (thank you Nicolas Cannasse!) and NME (Joshua Granick, Hugh Sanderson, Niel Drummond!) above others — and my own passionate visiondriven strive to get the ends of music/esthetics and logic/structure to meet…

So, what am I trying to achieve here? Talking about “features” we have the following:

  • Professional looking traditional music notation – no crappy mousedrawn clefs!
  • Formatting algorithms (object “anti-collision”, “allotment”, “aligning” and “justifying”) sophisticated enough to deal with the many tricky levels present in traditional notation and flexible enough to be used also for lyrics, dynamics and other more specialized notation elements.
  • Multi platform thanks to Haxe NME for use on web (html5 and flash), desktop (starting with windows) and maybe mobile.
  • Screen resolution and well as print resolution output.
  • Usable as a module in a spectrum of solutions and applications
  • Custom XML format for persistance

And what am I *not* trying to create:

  • A replacement for Sibelius, Finale or some of the other professional commercial music notation solutions able to deal with 50 page orchestral scores. Not a chance!

Also, the following are not a part of the solution today but might become:

  • Audio playback (planned)
  • Midi integration (maybe some day in some form)
  • MusicXML export/import (maybe)
  • (lots of stuff…)

When it comes to coding, I’m trying to

  • Solve the basics involved to get the features — figure out an answer to a thousands “how on earth should I code to make this happen?”-questions
  • Keep oo structure as clean and clear as I’m able to — avoid hitting the wall when the complexity rises
  • Find out, implement and stick to Haxe best practices, as well as my own coding style
  • Prioritize structure, separation of concerns, scalability etc before speed optimization

Sounds fine, doesn’t it! Well, at least I can say that I’m proud to be where I am right now: The core features are working, the most tricky parts in formatting algorithms are solved, and I can start using it for producing pedagogical teaching stuff for my students. At the same the code base today without doubt needs when it comes to

  • Some levels of refactorization
  • Decent code commenting

The code

The code still lives as the nx package in my all-purpose everyday work-in-progress Haxe github library cx — but don’t waste your time there unless you are really, really interested in all this. It will be forked out in a separate project library when the time is right…

In the next part I will try to present some of the interesting challenges that comes with computerized music notation, and how I try to tackle them.