3 note-spacing-engraver.cc -- implement Note_spacing_engraver.
5 source file of the GNU LilyPond music typesetter
7 (c) 2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
13 #include "engraver.hh"
14 #include "note-spacing.hh"
15 #include "note-column.hh"
18 Originally, we tried to have this functionality at Staff_level
20 - by simply using the sequence of Separation-item as
21 spacing-sequences. Unfortunately, this fucks up if there are
22 different kinds of tuplets combined (8th and 8ths triplets combined
23 made the program believe there were 1/12 th notes.).
26 - We also created them from Rhythmic_column_engraver, but this has
27 the problem that voices can appear and disappear at will, leaving
28 lots of loose ends (the StaffSpacing don't know where to connect the
29 last note of the voice on the right with)
33 struct Grob_moment_tuple
35 Link_array<Grob> current_heads_;
36 Link_array<Grob> todo_heads_;
40 static int time_compare (Grob_moment_tuple const &a, Grob_moment_tuple const &b)
42 return Moment::compare (a.length_, b.length_);
46 class Note_spacing_engraver : public Engraver
49 TRANSLATOR_DECLARATIONS(Note_spacing_engraver);
53 Array<Grob_moment_tuple> lengths_found_;
55 virtual void acknowledge_grob (Grob_info);
58 Note_spacing_engraver::Note_spacing_engraver()
64 Note_spacing_engraver::acknowledge_grob (Grob_info gi)
66 if (Note_head::has_interface (gi.grob_l_))
68 Music *m = gi.music_cause();
69 Moment now = now_mom ();
70 Moment len = m->length_mom();
71 if (now.grace_part_ && len.main_part_)
73 len.grace_part_ += len.main_part_;
79 Note_column::has_interface (gi.grob_l_))
81 Grob *head =Note_column::first_head (gi.grob_l_);
89 ENTER_DESCRIPTION(Note_spacing_engraver,
90 /* descr */ "This engraver creates spacing objects. It should be placed at staff
91 level, but will also function at voice level.
94 /* creats*/ "NoteSpacing",
95 /* acks */ "rhythmic-column-interface",