There is one well-known rule, however: Never shorten a stem.
|Beams on Both Voices|
The algorithm I currently use to render beams seems to work pretty well. I use an approach where I iteratively update the slope and y-shift of the beam, based on the height of each stem.
In retrospect, this algorithm seems pretty obvious, but I really had to experiment a fair bit to derive it. The first few beams were just all over the place.
|More Beam Confusion|
|Close... But Still Wrong!|
After ironing out the iterative algorithm, I got this:
|Decently Rendered Beams|
Thanks to the context-based architecture, note-modifiers such as accidentals don't disturb beam positioning.
|Beam With Accidentals|
Anyhow, I also got slides and ties working again. These were gone after the rewrite, and I had to work them in using the new framework.
These actually make use of annotation-contexts which help determine the position of the annotation text above the stave.
I'm still a bit unsure of how to render ties across different note steps, with accidentals. What I have now looks like this:
That's all for now folks, and thanks very much for the comments. Keep 'em coming!