2 spacing-options.cc -- implement Spacing_options
4 source file of the GNU LilyPond music typesetter
6 (c) 2006--2009 Han-Wen Nienhuys <hanwen@lilypond.org>
10 #include "spacing-options.hh"
11 #include "spacing-spanner.hh"
18 Spacing_options::init_from_grob (Grob
*me
)
20 increment_
= robust_scm2double (me
->get_property ("spacing-increment"), 1);
22 packed_
= to_boolean (me
->get_property ("packed-spacing"));
23 stretch_uniformly_
= to_boolean (me
->get_property ("uniform-stretching"));
24 float_nonmusical_columns_
25 = to_boolean (me
->get_property ("strict-note-spacing"));
27 = to_boolean (me
->get_property ("strict-grace-spacing"));
28 shortest_duration_space_
= robust_scm2double (me
->get_property ("shortest-duration-space"), 1);
31 Moment shortest_dur
= robust_scm2moment (me
->get_property ("common-shortest-duration"),
32 Moment (Rational (1,8), Rational (1,16)));
34 if (shortest_dur
.main_part_
)
35 global_shortest_
= shortest_dur
.main_part_
;
37 global_shortest_
= shortest_dur
.grace_part_
;
40 Spacing_options::Spacing_options ()
43 stretch_uniformly_
= false;
44 float_nonmusical_columns_
= false;
45 float_grace_columns_
= false;
47 shortest_duration_space_
= 2.0;
50 global_shortest_
= Rational (1, 8);
56 Get the measure wide ant for arithmetic spacing.
59 Spacing_options::get_duration_space (Rational d
) const
61 Real k
= shortest_duration_space_
;
63 if (d
< global_shortest_
)
66 We don't space really short notes using the log of the
67 duration, since it would disproportionally stretches the long
68 notes in a piece. In stead, we use geometric spacing with constant 0.5
71 This should probably be tunable, to use other base numbers.
73 In Mozart hrn3 by EB., we have 8th note = 3.9 mm (total), 16th note =
74 3.6 mm (total). head-width = 2.4, so we 1.2mm for 16th, 1.5
75 mm for 8th. (white space), suggesting that we use
77 (1.2 / 1.5)^{-log2(duration ratio)}
81 Rational ratio
= d
/ global_shortest_
;
83 return ((k
- 1) + double (ratio
)) * increment_
;
88 John S. Gourlay. ``Spacing a Line of Music, '' Technical
89 Report OSU-CISRC-10/87-TR35, Department of Computer and
90 Information Science, The Ohio State University, 1987.
92 Real log
= log_2 (global_shortest_
);
95 return (log_2 (d
) + k
) * increment_
;