X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fspacing-options.cc;h=dbf0587acdd7e6e98ae9110516d07a7b8cee222d;hb=b872748c6aa8bb721ced458691b38ac2fac5dfc8;hp=a3e512525b5c8352a825e08f81f2fc95cfbedcf5;hpb=7a32d3103c22d916cec37d1d7bb7e5cd4dc0463a;p=lilypond.git diff --git a/lily/spacing-options.cc b/lily/spacing-options.cc index a3e512525b..dbf0587acd 100644 --- a/lily/spacing-options.cc +++ b/lily/spacing-options.cc @@ -1,10 +1,21 @@ /* - spacing-options.cc -- implement Spacing_options + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2006--2015 Han-Wen Nienhuys - (c) 2006--2007 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "spacing-options.hh" @@ -27,9 +38,8 @@ Spacing_options::init_from_grob (Grob *me) = to_boolean (me->get_property ("strict-grace-spacing")); shortest_duration_space_ = robust_scm2double (me->get_property ("shortest-duration-space"), 1); - Moment shortest_dur = robust_scm2moment (me->get_property ("common-shortest-duration"), - Moment (Rational (1,8), Rational (1,16))); + Moment (Rational (1, 8), Rational (1, 16))); if (shortest_dur.main_part_) global_shortest_ = shortest_dur.main_part_; @@ -50,49 +60,44 @@ Spacing_options::Spacing_options () global_shortest_ = Rational (1, 8); } - - /* Get the measure wide ant for arithmetic spacing. */ Real Spacing_options::get_duration_space (Rational d) const { - Real k = shortest_duration_space_; + Real ratio = d / global_shortest_; - if (d < global_shortest_) + if (ratio < 1.0) { /* - We don't space really short notes using the log of the - duration, since it would disproportionally stretches the long - notes in a piece. In stead, we use geometric spacing with constant 0.5 - (i.e. linear.) + We don't space really short notes using the log of the + duration, since it would disproportionally stretches the long + notes in a piece. In stead, we use geometric spacing with constant 0.5 + (i.e. linear.) - This should probably be tunable, to use other base numbers. + This should probably be tunable, to use other base numbers. - In Mozart hrn3 by EB., we have 8th note = 3.9 mm (total), 16th note = - 3.6 mm (total). head-width = 2.4, so we 1.2mm for 16th, 1.5 - mm for 8th. (white space), suggesting that we use + In Mozart hrn3 by EB., we have 8th note = 3.9 mm (total), 16th note = + 3.6 mm (total). head-width = 2.4, so we 1.2mm for 16th, 1.5 + mm for 8th. (white space), suggesting that we use - (1.2 / 1.5)^{-log2(duration ratio)} + (1.2 / 1.5)^{-log2(duration ratio)} */ - Rational ratio = d / global_shortest_; - return ((k - 1) + double (ratio)) * increment_; + return (shortest_duration_space_ + ratio - 1) * increment_; } else { /* - John S. Gourlay. ``Spacing a Line of Music, '' Technical - Report OSU-CISRC-10/87-TR35, Department of Computer and - Information Science, The Ohio State University, 1987. + John S. Gourlay. ``Spacing a Line of Music, '' Technical + Report OSU-CISRC-10/87-TR35, Department of Computer and + Information Science, The Ohio State University, 1987. */ - Real log = log_2 (global_shortest_); - k -= log; - return (log_2 (d) + k) * increment_; + return (shortest_duration_space_ + log_2 (ratio)) * increment_; } }