Features Help Download

Lomse Hacking Guide

7.1. Algorithm 1 for score layouting

The initial approach for score layouting (algorithm-1) was a first-fit algorithm: line breaks are decided as systems are beign set, by filling a line until no more columns can be added. Algorithm 1 was the algorithm used in LenMus (until version 4.3 included) and in Lomse (up to SVN rev.23 included). The line breaks algorthm is too simple and it do not justify the last system. Breaking a line when no more columns can be added doesn’t allow for any optimization, and there are great chances that last system is too short to be justifiable.

The algorithm is as follows (method names refer to Lomse code):

Preparation [prepare_to_start_layout()]:

    * Score layouter creates instrument engravers [create_instrument_engravers()]
        and they decide on systems indentation [decide_systems_indentation()]


Page filling [layout_in_box()]:

    * When score layouter is asked to fill one page it enters
        in a loop to create systems until the page is full.

    * To create a system [create_system()] it:
        * creates and saves a system layouter
        * creates a system box [create_system_box()]
        * fill_current_system_with_columns()
            * create_column_boxes() :
                * create_slice_box()
                * for each instrument, creates a slice:
                        * system layouter creates a slice for the instrument
                        * if it is_the first column in the system, instrument
                            engraver is requested to engrave staff lines,
                            instrument name/abbreviation and brace/bracket.
                * with this, the system size get fixed.

            * collect_content_for_this_bar() :
                * Score layouter adds prolog to current system
                * Score layouter explores staff objs collection and creates
                    columns, filling current system, until the system is ready.

            * measure_this_bar()

        * justify_current_system()
        * engrave_system_details()
            * Score layouter engraves Aux Objs for current system

It has some advantages:

  • It is fast and simple
  • It can, automatically, adapt to different page sizes or, even, to change line size in middle of a page.