lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue 5036: 128 beaming output not producing output as expected (?) (iss


From: torsten . haemmerle
Subject: Issue 5036: 128 beaming output not producing output as expected (?) (issue 559700043 by address@hidden)
Date: Tue, 24 Mar 2020 11:21:06 -0700

Reviewers: ,

Message:
Please review.

TIA,
Torsten

Description:
Issue 5036: 128 beaming output not producing output as expected (?)

In case of more than 4 normal-sized beams, a grid shift correction
will be applied to the outside-staff quants so that the inner beams
within the staff can be neatly aligned to the staff lines.

If all the beams fall outside the staff (cf. stem shortening), this
grid shift will ensure a consistent vertical alignment of beams.
See regtest beam-shortened-lengths.ly

regression beam-shortened-lengths.ly: new durations 256, 512, and 1024
added.

new regression beaming-more-than-4-beams-normal-size.ly

Please review this at https://codereview.appspot.com/559700043/

Affected files (+66, -7 lines):
  M input/regression/beam-shortened-lengths.ly
  A input/regression/beaming-more-than-4-beams-normal-size.ly
  M lily/beam-quanting.cc
  M lily/include/beam-scoring-problem.hh


Index: input/regression/beam-shortened-lengths.ly
diff --git a/input/regression/beam-shortened-lengths.ly 
b/input/regression/beam-shortened-lengths.ly
index 
057e602963f7386ff6db72911c342d036d7fe799..cc4d5fb78bcd4db0f2f093b08a219cde5beab8ff
 100644
--- a/input/regression/beam-shortened-lengths.ly
+++ b/input/regression/beam-shortened-lengths.ly
@@ -1,4 +1,4 @@
-\version "2.16.0"
+\version "2.21.0"
 
 \header{
   texidoc="Beams in unnatural direction, have shortened stems, but do not look 
too short."
@@ -8,5 +8,5 @@
 
 \relative c'{
   \stemUp
-  f'4  f8[ f]  f16[ f]  f32[ f]  f64[ f]  f128[ f] 
+  f'4  f8[ f]  f16[ f]  f32[ f]  f64[ f]  f128[ f] f256[ f] f512[ f] f1024[ f]
 }
Index: input/regression/beaming-more-than-4-beams-normal-size.ly
diff --git a/input/regression/beaming-more-than-4-beams-normal-size.ly 
b/input/regression/beaming-more-than-4-beams-normal-size.ly
new file mode 100644
index 
0000000000000000000000000000000000000000..dc63626e771aab501059275441b10f2c016e0427
--- /dev/null
+++ b/input/regression/beaming-more-than-4-beams-normal-size.ly
@@ -0,0 +1,39 @@
+
+\version "2.21.0"
+
+\header{
+texidoc="
+Inside-staff beams should align with staff lines (sit, straddle, hang) as
+smoothly as possible (standard-sized beams).  The outide-staff beams will
+not interfere with staff lines, so the inside-staff beams are more important
+when it comes to beam quanting/scoring/positioning."
+}
+
+\layout {
+  indent = 0
+  line-width = 100
+  ragged-right = ##t
+  \context {
+    \Staff
+    \omit Clef
+    \omit TimeSignature
+  }
+}
+
+testMusic = {
+  \cadenzaOn
+   a8[ 8]
+   16[ 16]
+   32[ 32]
+   64[ 64]
+   128[ 128]
+   256[ 256]
+   512[ 512]
+   1024[ 1024]
+   128[ 64 32 16 8]
+}
+
+<<
+  \new Staff \testMusic
+  \new Staff \transpose a c''' \testMusic
+>>
Index: lily/beam-quanting.cc
diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc
index 
8657bac2f7eb66957aaa09fc2fa1112bb8c5d758..852cedf9063b8da4af014ac0d6969d03e6cd7d66
 100644
--- a/lily/beam-quanting.cc
+++ b/lily/beam-quanting.cc
@@ -220,7 +220,8 @@ void Beam_scoring_problem::init_instance_variables (Grob 
*me, Drul_array<Real> y
   staff_space_ = Staff_symbol_referencer::staff_space (beam_);
   beam_thickness_ = Beam::get_beam_thickness (beam_) / staff_space_;
   line_thickness_ = Staff_symbol_referencer::line_thickness (beam_) / 
staff_space_;
-
+  length_fraction_
+    = robust_scm2double (beam_->get_property ("length-fraction"), 1.0);
   // This is the least-squares DY, corrected for concave beams.
   musical_dy_ = robust_scm2double (beam_->get_property ("least-squares-dy"), 
0);
 
@@ -876,6 +877,17 @@ Beam_scoring_problem::generate_quants 
(vector<unique_ptr<Beam_configuration>> *s
   Real hang = 1.0 - (beam_thickness_ - line_thickness_) / 2;
   Real base_quants [] = {straddle, sit, inter, hang};
   int num_base_quants = int (sizeof (base_quants) / sizeof (Real));
+  int max_beam_count = std::max (edge_beam_counts_[LEFT],
+                                 edge_beam_counts_[RIGHT]);
+
+  /* for normal-sized beams, in case of more than 4 beams, the outer beam
+     used for generating quants will never interfere with staff lines, but
+     prevent the inside-staff beams from being neatly positioned.
+     A correctional grid_shift has to be applied to compensate. */
+  Real grid_shift = 0.0;
+  /* grid shift only makes sense for widened normal-sized beams: */
+  if (!is_knee_ && max_beam_count > 4 && length_fraction_ == 1.0)
+    grid_shift = (max_beam_count - 4) * (1.0 - beam_translation_);
 
   /*
     Asymetry ? should run to <= region_size ?
@@ -890,10 +902,17 @@ Beam_scoring_problem::generate_quants 
(vector<unique_ptr<Beam_configuration>> *s
   for (vsize i = 0; i < unshifted_quants.size (); i++)
     for (vsize j = 0; j < unshifted_quants.size (); j++)
       {
-        auto c
-          = Beam_configuration::new_config (unquanted_y_,
-                                            Interval (unshifted_quants[i],
-                                                      unshifted_quants[j]));
+        Interval corr (0.0, 0.0);
+        if (grid_shift)
+          for (LEFT_and_RIGHT (d))
+            /* apply grid shift if quant outside 5-line staff: */
+            if ((unquanted_y_[d] + unshifted_quants[i]) * edge_dirs_[d] > 2.5)
+              corr[d] = grid_shift * edge_dirs_[d];
+        auto c = Beam_configuration::new_config (unquanted_y_,
+                                                 Interval (unshifted_quants[i]
+                                                           - corr[LEFT],
+                                                           unshifted_quants[j]
+                                                           - corr[RIGHT]));
 
         for (LEFT_and_RIGHT (d))
           {
Index: lily/include/beam-scoring-problem.hh
diff --git a/lily/include/beam-scoring-problem.hh 
b/lily/include/beam-scoring-problem.hh
index 
d8cca50a736497b132c021364ef26e1128d3ce28..aef5feb90d76926d24d54997d57f867c1d36494b
 100644
--- a/lily/include/beam-scoring-problem.hh
+++ b/lily/include/beam-scoring-problem.hh
@@ -167,6 +167,7 @@ private:
   // end.  This is used for quickly weeding out invalid
   // Beam_configurations.
   Drul_array<Interval> quant_range_;
+  Real length_fraction_;
   Real beam_translation_;
   std::vector<Beam_collision> collisions_;
   std::vector<Beam_segment> segments_;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]