← Back to experiments

Unity Notation Engine

Custom notation engraving engine built in Unity

UnityMusicXML

As an avid user or Dorico (and once Finale) I’ve always been fascinated by how music notation software handles engraving algorithmically. To bring music notation into Unity I’ve been working on a custom music notation layout engine. It parses MusicXML files (a standard exported by the leading music notation softwares), generates a layout based on various heuristics, and then renders each musical element as a Unity sprite. This paves the way for dynamic animations of note heads, custom fonts/styles and more.

The layout algorithm I designed is based on fundamental principles of engraving and considers:

  • Spacing: The distance between notes is based on the duration of the note and a custom spacing factor
  • Beaming: Optimal beam and stem angles are calculated based on the constituent notes
  • Chord clusters: Notes in a chord are assigned either to right or left hand of the stem for best readability
  • Accidentals: Horizontal space is allocated for accidentals to prevent overlap

Elements as Unity sprites