Category Archives: Zong! Development

Swing component: Combobox for font selection

There are many great Swing components around, but we could not find a nice combobox for font selection, that includes not only the font names but also some preview characters and maybe a history of the recently selected fonts. You know such a combobox from OpenOffice.org and other word processors.

Well, here it is now. Our FontChooserComboBox offers font preview, customizable preview strings, optionally a list of the recent fonts and even auto completion for the font name. And best of all, the code is public domain, so you can use it for whatever you want. However, if you improve it, please share your work with us!

Here is a demo video:

[youtube=http://www.youtube.com/watch?v=8pOVB0jRXuA]

A webstart demo:

Here are the files:

Comments are welcome πŸ™‚

Conducting a virtual symphony orchestra using Zong!

This blog has been quiet for the last four months. Not because the project is dead or frozen, but because I had to concentrate on my master thesis. Luckily I managed to find a topic that is related to music notation, and so I was also able to integrate Zong! into the project and bring it a little bit forward.

The project is called Pinocchio. It is a serious game that should allow young children to become acquainted with classical music by conducting a virtual symphony orchestra. The videos on the website (very outdated) give a good idea about how it works. However, as you can see, conducting was not really realistic yet and the interpretation of the gestures seemed a little bit randomly. So my task during the thesis was to extend the repertoire of conducting gestures, and introduce the ability to load and understand any piece of digital sheet music. This allows a better interpretation of the gestures, since now the context (the score) is known to the system. For displaying the score and rendering it into audio, Zong! is used in the background. It allows to open all MusicXML files, then it computes the needed information and provides it to Pinocchio.

Unfortunately, the project is not open source, and it is not finished yet. So there is no demo I can provide here, but maybe there will be some videos in the future.

Since this was my master thesis, and I needed a lot of time to do it, I had nearly no additional resources left for Zong!. This will change dramatically now πŸ™‚ As the available prototypes show, the technology works and is still easy to extend, so now it is time to move forward to a really useable product, and of course, begin with the editor component. We will post a plan for the upcoming release here within the next days, so stay tuned!

Iteration 52 is out

The new version of Zong! contains an updated layout engine. It was not extended yet, but we cleaned up the code and gave it a more functional style. There is also a big map showing all classes involved in the layouting process:

In the next two iterations we will improve both the layout engine (features like cue and grace notes, multi-staff beams) and the MIDI output (tempo, transposition, repetitions, voltas, dynamics).

Welcome, developers!

The last days I have replaced the old, quite complex Ant build script by a much simpler configuration file written in Java, that is based on Xenoage Build, a quick & dirty extension to Ant. I did this, because I really had problems in Ant when having multiple subprojects with different dependencies on each other. I think, the lines 34 to 58 in the new config file describe this dependencies much nicer than the old Ant script.

Additionally, I have added a tiny tutorial how to set up Zong! in Eclipse. Following these three steps, you can run and debug Zong! within two minutes on any operating system.

Developers are welcome! If there are other things we can do for you, please don’t hesitate to tell us what you need.

Iteration 51 is out

After many weeks of work, Zong! p0.4.51 is finally out. Although there are no new features which are interesting from a user’s perspective, there are two important changes which are essential for the future development of the project:

  • The core has been completely replaced. While it was based on mutable Java classes and operations using many side effects before, the core is now completely functional. It is now much easier to test and maintain, and undo/redo is now a trivial task. The new core wouldn’t be possible without the excellent work of the pcollections project, which I can really recommend for Java projects of any kind.
  • The musicxml project replaces proxymusic. While this is also a great library which I can recommend to all Java+MusicXML projects, we had problems with the Reflection techniques it is using (applets must be signed then), JAXB’s not-so-optimal XML-to-Java conversion and its speed (on my machine proxymusic needs about 2 minutes to load all official MusicXML 1.1 and MusicXML 2.0 samples, while our new musicxml library needs about 5 seconds). The two projects do basically the same, but proxymusic is automatically generated from the MusicXML schema, while our library is written by hand, which is really a very boring task, but finally it was worthwhile.

The goal for the next iterations is to rewrite the layout engine so that it fits to the functional core. Then, we can continue to improve the layout engine and support more music notation features. We also plan to offer a web service that converts MusicXML to PDF (and possibly other formats).

1229 errors left to solve for iteration 50

Although it was a little quiet in this blog during the last weeks, this doesn’t mean that we aren’t working hard on the next iteration. Haydn (Iteration 50) is really a hard nut to crack! Currently we are completely replacing the core of Zong! which allows to store and manipulate musical data. While this core part was heavily relying on side effects and mutable data, we are now moving to a core that contains only immutable, persisent data structures and embraces a much more functional style.

The idea to do that arised when I was learning Clojure. Although we do not use Clojure (yet), since it is still too complicated to call from the Java side, it is always a good idea to learn new languages and to gain insight into different programming concepts. This makes you even a better programmer in the language you are coming from! But now, what are the advantages of a functional core?

One good reason is the testability. Since there are no side effects, it is much easier to understand and debug the code. The same input always results in the same output, without influence of outer effects. Another reason is concurrency: Persistent data structures are thread safe by design, and it is never necessary to create defensive copies of your objects, because it is guaranteed that they can never be changed. But the biggest advantage from a user’s point of view is undo/redo functionality. While we wracked our brains how to undo side-effect based actions up to now, it is now trivial to undo each action: Just remember the root object before performing the action. This is brain-dead easy!

Unfortunately, Java was not designed for using immutable objects, so the code for implementing these classes is not as nice as it could be like when using Clojure for example. Neverless it is possible and often results in much nicer code when using these classes. We decided to use the pcollections library and it does a great job so far! Although it is still quite unknown, I am sure that it will get more attention soon, because the advantages of persisent data structures are really groundbreaking in my eyes.

How does the persistent core works? Basically, we have a tree of musical classes with the Score class as its root. It is immutable (nothing can be changed), so no backward links are possible. This is kind of a problem, since for example a chord belongs to a slur and a slur contains chords. This can not be directly modelled with immutable data structures. Therefor, we have a big hashtable at the root which save all Globals (beams, slurs, ties, attached elements like dynamics, musical positions of each element for very fast lookup, and so on). The staves, measures, voices and its element are represented in a tree structure like one would probably expect it.

Let’s say we want to add a note to an existing chord, which is beamed. Therefor, we create a new score, based on the old one (and of course sharing as much data as possible, which is never a problem since everything is immutable :)). When “changing” a chord, we also have to “change” its voice, then the measure the voice belongs to, then the staff the measure belongs to, and so on, up to the root. After that we have to update the Globals since our chord now has a new reference of course. This sounds more complicated at first, but the hierarchy of the elements in the tree is quite flat, and we are not using (much) more memory than we would need for the side-effect
based solution. Remember: While it is more efficient to work with side effects when performing some action, it may be a nightmare to undo it again! This is absolutely trivial using persistent data structures: Just remember the Score instance, perform your changes, and if you want to undo them again, just take the old Score instance. Cool, isn’t it? 8)

The changes are so radical, that I’m already working for more than 50 hours to integrate them into the other Zong! projects. There are still 1229 compile errors to solve… But I’m sure that the new core will bring Zong! a very big step forward – also because we solved the tremendous undo/redo problem by the way.

Tracker moved to new server

The exams are over – now it’s time to work on Zong! again. Since today, the bugtracker runs on our new homeserver and we also moved the private git repository to there. Thanks again to Phil for hosting them the last months (or even years)!

We are amazed how many people are interested already in this early stage of the project. Thanks to all the contributors that have sent us ideas, code and example files so far. I hope I’ll catch up soon and integrate them. If anyone would like to join the project, don’t hesitate to contact us πŸ™‚

Exam break

Due to our exams in the winter semester, we have currently no time left for developing Zong!. We are planning to continue in March. Our next big steps are the complete rewriting of the core (now only using persistent data structures, which makes for example undo/redo dead easy) and the setup of our own home server (running git and redmine for the tracker).

A little present

Merry Christmas πŸ™‚ As a little present, we are happy to announce the release of the alpha versions of the Zong! Viewer and Zong! Player, which are both licensed under the GPL.

Interested developers can check out the source code in our public Git repository. We have also prepared a demo for the Zong! Viewer. Notice, that you need Java 6 to run the applications.

We hope that this release encourages some people to join our development team. If you are interested, please don’t hesitate to contact us.