updated Granados example

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

updated Granados example

Werner LEMBERG

Attached you can find my revised version of the three bars from the
Granados piece.  The staff size is still smaller than the original
since it is not possible currently to typeset that dense with LilyPond
(while getting an optically pleasing result) – but it is larger than
previously :-)

Note that for testing purposes I've applied Dave Nalesnik's patch for
tuplet slurs
(http://lilypond.1069038.n5.nabble.com/tuplet-slurs-td199904.html).
Interestingly, this was never added to the tracker; I've asked David
to do that now.[*]


    Werner


[*] What's available in the link is not his latest patch, according to
    the e-mail thread.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is a brief passage from Enrique Granados %
% Goyescas, "Coloquio en la Reja."              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\version "2.19.83"

\include "example-header.ily"

#(set-global-staff-size 14)


\paper {
  paper-height = 70\mm
}


csh = \change Staff = "high"
csm = \change Staff = "middle"
csl = \change Staff = "low"

crmolto = \markup { \italic "cresc. molto" }
appassmolto = \markup { \whiteout \italic "appassionato molto" }

#(ly:set-option 'point-and-click #f)


global = { \time 3/4 }


upperVoiceOne = \relative {
  \override TupletBracket.bracket-visibility = ##t
  \override TupletBracket.tuplet-slur = ##t
  \override TupletNumber.padding = #0

  % 1
  \voiceOne
  <aes' f'>8\tweak height-limit #4 ([ \tuplet 5/4 { g'32 aes g f g] }
  <es aes>8[ \tuplet 5/4 { <d bes'>32 c' bes aes bes] }
  <es, aes es'>8 <d fis bes d>) |

  % 2
  <c g' c>4( \voiceTwo
  <bes es bes'>4)\arpeggio
  <aes aes'>16^( <bes bes'> <g g'>8) |

  % 3
  \voiceOne
  <f aes d f>8\tweak height-limit #4 ([ \tuplet 5/4 { <g g'>32 aes' g f g] }
  <aes, aes'>16
    \set stemRightBeamCount = #1
    <c f>
    \set stemLeftBeamCount = #1
    \tuplet 5/4 { bes'32 c bes aes bes] }
  \ottava #1 <es es'>16 <f f'> <d d'> \slashedGrace f8 <es es'>16) |
}

upperVoiceTwo = \relative {
  % 1
  \voiceTwo s8 c''8\<
  <bes, f'>[ <bes aes'>
  c' <bes, d fis>\!] |

  % 2
  s4_\tweak X-offset #1 -\appassmolto
  \voiceOne a'''8\rest <bes, es bes'>->
  s4 |

  % 3
  s8 \voiceTwo \crossStaff { g,8
  aes4 }
}

middleVoiceOne = \relative {
  % 1
  \crossStaff { d'!8 } s8
  s8 s8\offset Y-offset #-2 _\crmolto
  s4 |

  % 2
  s4
  <g bes>8[ <es' g>]
  \voiceOne e,8( dis16 e) |

  % 3
  \once \override VoiceFollower.bound-details.left.Y = #-10
  \showStaffSwitch \csh \stemUp f4
}

middleVoiceTwo = \relative {
  % 1
  s2. |

  % 2
  s4
  \hideNotes \stemUp bes'\arpeggio \unHideNotes
  \voiceTwo \crossStaff { e,!4 } |

  % 3
  s4
  <bes c es f>8 <f' aes es'>16 d'
  <bes, f' aes c>8 <bes' fis'> |
}

lowerVoiceOne = \relative {
  \mergeDifferentlyHeadedOn
  \mergeDifferentlyDottedOn

  % 1
  \once \override Beam.damping = #5
  bes,,8 \csm \stemDown <bes'' c es>8
  s2 |

  % 2
  \csl \stemUp s8
    \hideNotes \stemDown es,,64^( s64 s \unHideNotes \stemUp
    g'64\offset positions #'(-0.7 . -0.7)
        \tweak damping #3 [
    \set stemLeftBeamCount = #1
    bes c d c])
  s2 |

  % 3
  \once \override Beam.damping = #3
  bes,,8 \csm \stemDown <bes'' c es>8 s2 |
}

lowerVoiceTwo = \relative {
  % 1
  \voiceTwo bes,,2. |

  % 2
  \csh
  \once \override Beam.damping = #+inf.0
  % XXX Currently, cross-staff beaming support is partially broken.  This
  %     means we have to adjust the vertical beam position manually.
  \once \override Beam.positions = #'(-30 . -30)
  <bes'' es g>8 \csl es,,64 bes' es g s32. c64
  s4
  <bes des>4

  % 3
  bes,,2.
}


\score {
  \new PianoStaff <<
    \set PianoStaff.connectArpeggios = ##t
    \override PianoStaff.Arpeggio.stencil = #ly:arpeggio::brew-chord-bracket
    \override PianoStaff.Arpeggio.padding = #-0.5

    \new Staff = "high" <<
      \global
      \context Voice = "upperVoiceOne" { \upperVoiceOne }
      \context Voice = "upperVoiceTwo" { \upperVoiceTwo }
    >>
    \new Staff = "middle" <<
      \global
      \context Voice = "middleVoiceOne" { \middleVoiceOne }
      \context Voice = "middleVoiceTwo" { \middleVoiceTwo }
    >>
    \new Staff = "low" <<
      \clef bass
      \global
      \context Voice = "lowerVoiceOne" { \lowerVoiceOne }
      \context Voice = "lowerVoiceTwo" { \lowerVoiceTwo }
    >>
  >>

  \layout {
    \context {
      \Score
      \omit TimeSignature
      \remove "Bar_number_engraver"
    }
    \context {
      \PianoStaff
      \consists #Span_stem_engraver
    }
    \context {
      \Staff
      \override Accidental.extra-spacing-width = #'(0 . 0)
    }
  }
}

diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc
index 14689eca25..e070db0b0a 100644
--- a/lily/tuplet-bracket.cc
+++ b/lily/tuplet-bracket.cc
@@ -60,6 +60,7 @@
 #include "lookup.hh"
 #include "paper-column.hh"
 #include "moment.hh"
+#include "bezier.hh"
 
 static Item *
 get_x_bound_item (Grob *me_grob, Direction hdir, Direction my_dir)
@@ -252,6 +253,55 @@ Tuplet_bracket::calc_x_positions (SCM smob)
   return ly_interval2scm (x_span - me->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS));
 }
 
+Bezier
+tuplet_slur_shape (Offset l, Offset r, Real h_limit, Real ratio, Direction d)
+{
+  Real indent;
+  Real height;
+
+  Real width = (r[X_AXIS] - l[X_AXIS]);
+
+  get_slur_indent_height (&indent, &height, width, h_limit, ratio);
+
+  Bezier curve;
+
+  curve.control_[0] = l;
+  curve.control_[1] = Offset (l[X_AXIS] + indent, l[Y_AXIS] + height * d);
+  curve.control_[2] = Offset (r[X_AXIS] - indent, r[Y_AXIS] + height * d);
+  curve.control_[3] = r;
+
+  return curve;
+}
+
+Stencil
+make_tuplet_slur (Grob *me, Offset l, Offset r, Drul_array<Real> shorten)
+{
+  SCM dash_definition = me->get_property ("dash-definition");
+  Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
+
+  /* ad-hoc values based on visual inspection */
+  Real height_limit = 1.5;
+  Real ratio = .33;
+
+  Direction dir = get_grob_direction (me);
+
+  Offset dz = r - l;
+  Real length = dz.length ();
+
+  l += shorten[LEFT] / length * dz;
+  r -= shorten[RIGHT] / length * dz;
+
+  Bezier curve = tuplet_slur_shape (l, r, height_limit, ratio, dir);
+
+  Stencil mol (Lookup::slur (curve, lt, lt, dash_definition));
+
+  Grob *tn = unsmob<Grob> (me->get_object ("tuplet-number"));
+  Real padding = robust_scm2double (tn->get_property ("padding"), 0.3);
+
+  mol.translate_axis (padding * dir, Y_AXIS);
+  return mol;
+}
+
 /*
   TODO:
 
@@ -265,6 +315,8 @@ Tuplet_bracket::print (SCM smob)
   Spanner *me = unsmob<Spanner> (smob);
   Stencil mol;
 
+  bool tuplet_slur = ly_scm2bool (me->get_property ("tuplet-slur"));
+
   extract_grob_set (me, "note-columns", columns);
   bool equally_long = false;
   Grob *par_beam = parallel_beam (me, columns, &equally_long);
@@ -332,74 +384,89 @@ Tuplet_bracket::print (SCM smob)
   if (bracket_visibility)
     {
       Drul_array<Real> zero (0, 0);
-      Real ss = Staff_symbol_referencer::staff_space (me);
-      Drul_array<Real> height
-        = robust_scm2drul (me->get_property ("edge-height"), zero);
-      Drul_array<Real> flare
-        = robust_scm2drul (me->get_property ("bracket-flare"), zero);
+
       Drul_array<Real> shorten
         = robust_scm2drul (me->get_property ("shorten-pair"), zero);
-      Drul_array<Stencil> edge_stencils;
-
-      Direction dir = get_grob_direction (me);
 
-      scale_drul (&height, -ss * dir);
-      scale_drul (&flare, ss);
+      Real ss = Staff_symbol_referencer::staff_space (me);
       scale_drul (&shorten, ss);
 
-      Drul_array<bool> connect_to_other
-        = robust_scm2booldrul (me->get_property ("connect-to-neighbor"),
-                               Drul_array<bool> (false, false));
+      Stencil brack;
 
-      for (LEFT_and_RIGHT (d))
+      if (tuplet_slur)
         {
-          if (connect_to_other[d])
-            {
-              height[d] = 0.0;
-              flare[d] = 0.0;
-              shorten[d] = 0.0;
+          brack = make_tuplet_slur (me, points[LEFT], points[RIGHT], shorten);
+          mol.add_stencil (brack);
+        }
+      else
+        {
+          Drul_array<Stencil> edge_stencils;
+
+          Drul_array<Real> height
+            = robust_scm2drul (me->get_property ("edge-height"), zero);
+          Drul_array<Real> flare
+            = robust_scm2drul (me->get_property ("bracket-flare"), zero);
+
+          Direction dir = get_grob_direction (me);
+
+          scale_drul (&height, -ss * dir);
+          scale_drul (&flare, ss);
 
-              SCM edge_text = me->get_property ("edge-text");
+          Drul_array<bool> connect_to_other
+            = robust_scm2booldrul (me->get_property ("connect-to-neighbor"),
+                                   Drul_array<bool> (false, false));
 
-              if (scm_is_pair (edge_text))
+          for (LEFT_and_RIGHT (d))
+            {
+              if (connect_to_other[d])
                 {
-                  SCM properties = Font_interface::text_font_alist_chain (me);
-                  SCM text = index_get_cell (edge_text, d);
-                  if (Text_interface::is_markup (text))
+                  height[d] = 0.0;
+                  flare[d] = 0.0;
+                  shorten[d] = 0.0;
+
+                  SCM edge_text = me->get_property ("edge-text");
+
+                  if (scm_is_pair (edge_text))
                     {
-                      SCM t
-                        = Text_interface::interpret_markup (pap->self_scm (),
-                                                            properties, text);
-
-                      Stencil *edge_text = unsmob<Stencil> (t);
-                      edge_text->translate_axis (x_span[d] - x_span[LEFT],
-                                                 X_AXIS);
-                      edge_stencils[d] = *edge_text;
+                      SCM properties
+                        = Font_interface::text_font_alist_chain (me);
+                      SCM text = index_get_cell (edge_text, d);
+
+                      if (Text_interface::is_markup (text))
+                        {
+                          SCM t = Text_interface::interpret_markup (
+                                    pap->self_scm (), properties, text);
+
+                          Stencil *edge_text = unsmob<Stencil> (t);
+                          edge_text->translate_axis (x_span[d] - x_span[LEFT],
+                                                     X_AXIS);
+                          edge_stencils[d] = *edge_text;
+                        }
                     }
                 }
             }
-        }
 
-      Stencil brack =
-        Bracket::make_bracket (
-          me, Y_AXIS, points[RIGHT] - points[LEFT], height,
-          /*
-            0.1 = more space at right due to italics
-            TODO: use italic correction of font.
-          */
-          Interval (-0.5, 0.5) * gap + 0.1,
-          flare, shorten);
+          brack =
+            Bracket::make_bracket (
+              me, Y_AXIS, points[RIGHT] - points[LEFT], height,
+              /*
+                0.1 = more space at right due to italics
+                TODO: use italic correction of font.
+              */
+              Interval (-0.5, 0.5) * gap + 0.1,
+              flare, shorten);
+
+          for (LEFT_and_RIGHT (d))
+            {
+              if (!edge_stencils[d].is_empty ())
+                brack.add_stencil (edge_stencils[d]);
+            }
 
-      for (LEFT_and_RIGHT (d))
-        {
-          if (!edge_stencils[d].is_empty ())
-            brack.add_stencil (edge_stencils[d]);
+          mol.add_stencil (brack);
+          mol.translate (points[LEFT]);
         }
-
-      mol.add_stencil (brack);
     }
 
-  mol.translate (points[LEFT]);
   return mol.smobbed_copy ();
 }
 
@@ -791,6 +858,7 @@ ADD_INTERFACE (Tuplet_bracket,
                "note-columns "
                "padding "
                "tuplet-number "
+               "tuplet-slur "
                "scripts "
                "shorten-pair "
                "staff-padding "
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index 6ccac5317c..9991fc1e90 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -1139,6 +1139,8 @@ direction and it is associated with a @code{ScriptColumn} object.
 @code{0.0} means centered on the note head (the default position of
 most scripts); @code{1.0} means centered on the stem.  Interpolated
 values are possible.")
+     (tuplet-slur ,boolean? "Draw a slur instead of a bracket for
+tuplets.")
      (transparent ,boolean? "This makes the grob invisible.")
 
 
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 3db84f320b..04c747bc50 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -2658,6 +2658,7 @@
         (staff-padding . 0.25)
         (stencil . ,ly:tuplet-bracket::print)
         (thickness . 1.6)
+        (tuplet-slur . #f)
         (vertical-skylines . ,grob::unpure-vertical-skylines-from-stencil)
         (X-positions . ,ly:tuplet-bracket::calc-x-positions)
 

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel

granados-orig.png (88K) Download Attachment
granados-old.png (45K) Download Attachment
granados-new.png (51K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: updated Granados example

Urs Liska-3
Hi Werner,

thanks for working on this.

I have the impression it would be nice to add at least one example with an alternative notation font to the example page. Here is the list of freely available fonts: https://github.com/openlilylib-resources/lilypond-notation-fonts/tree/master/fonts (note that while it is *legal* to use Abraham's other fonts for which he revoked the free license we shouldn't use them on our website (which is unfortunate since Haydn or Gutenberg1939 would make really nice examples.

Considering the existing content of the examples page we should probably limit this to one example, and for that it would probably make sense to use LilyJAZZ since that might be the most-wanted feature. Maybe reuse this "piece"? https://github.com/frescobaldi/frescobaldi/pull/1075#issuecomment-529471468

Also, I think section 3.4.4 of the NR should be updated to be much more explicit and suggestive. If I can find the time I'd volunteer to do this.
http://lilypond.org/doc/v2.19/Documentation/notation/replacing-the-notation-font.html

Urs

26. September 2019 22:35, "Werner LEMBERG" <[hidden email]> schrieb:

> Attached you can find my revised version of the three bars from the
> Granados piece. The staff size is still smaller than the original
> since it is not possible currently to typeset that dense with LilyPond
> (while getting an optically pleasing result) – but it is larger than
> previously :-)
>
> Note that for testing purposes I've applied Dave Nalesnik's patch for
> tuplet slurs
> (http://lilypond.1069038.n5.nabble.com/tuplet-slurs-td199904.html).
> Interestingly, this was never added to the tracker; I've asked David
> to do that now.[*]
>
> Werner
>
> [*] What's available in the link is not his latest patch, according to
> the e-mail thread.
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> % This is a brief passage from Enrique Granados %
> % Goyescas, "Coloquio en la Reja." %
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> \version "2.19.83"
>
> \include "example-header.ily"
>
> #(set-global-staff-size 14)
>
> \paper {
> paper-height = 70\mm
> }
>
> csh = \change Staff = "high"
> csm = \change Staff = "middle"
> csl = \change Staff = "low"
>
> crmolto = \markup { \italic "cresc. molto" }
> appassmolto = \markup { \whiteout \italic "appassionato molto" }
>
> #(ly:set-option 'point-and-click #f)
>
> global = { \time 3/4 }
>
> upperVoiceOne = \relative {
> \override TupletBracket.bracket-visibility = ##t
> \override TupletBracket.tuplet-slur = ##t
> \override TupletNumber.padding = #0
>
> % 1
> \voiceOne
> <aes' f'>8\tweak height-limit #4 ([ \tuplet 5/4 { g'32 aes g f g] }
> <es aes>8[ \tuplet 5/4 { <d bes'>32 c' bes aes bes] }
> <es, aes es'>8 <d fis bes d>) |
>
> % 2
> <c g' c>4( \voiceTwo
> <bes es bes'>4)\arpeggio
> <aes aes'>16^( <bes bes'> <g g'>8) |
>
> % 3
> \voiceOne
> <f aes d f>8\tweak height-limit #4 ([ \tuplet 5/4 { <g g'>32 aes' g f g] }
> <aes, aes'>16
> \set stemRightBeamCount = #1
> <c f>
> \set stemLeftBeamCount = #1
> \tuplet 5/4 { bes'32 c bes aes bes] }
> \ottava #1 <es es'>16 <f f'> <d d'> \slashedGrace f8 <es es'>16) |
> }
>
> upperVoiceTwo = \relative {
> % 1
> \voiceTwo s8 c''8\<
> <bes, f'>[ <bes aes'>
> c' <bes, d fis>\!] |
>
> % 2
> s4_\tweak X-offset #1 -\appassmolto
> \voiceOne a'''8\rest <bes, es bes'>->
> s4 |
>
> % 3
> s8 \voiceTwo \crossStaff { g,8
> aes4 }
> }
>
> middleVoiceOne = \relative {
> % 1
> \crossStaff { d'!8 } s8
> s8 s8\offset Y-offset #-2 _\crmolto
> s4 |
>
> % 2
> s4
> <g bes>8[ <es' g>]
> \voiceOne e,8( dis16 e) |
>
> % 3
> \once \override VoiceFollower.bound-details.left.Y = #-10
> \showStaffSwitch \csh \stemUp f4
> }
>
> middleVoiceTwo = \relative {
> % 1
> s2. |
>
> % 2
> s4
> \hideNotes \stemUp bes'\arpeggio \unHideNotes
> \voiceTwo \crossStaff { e,!4 } |
>
> % 3
> s4
> <bes c es f>8 <f' aes es'>16 d'
> <bes, f' aes c>8 <bes' fis'> |
> }
>
> lowerVoiceOne = \relative {
> \mergeDifferentlyHeadedOn
> \mergeDifferentlyDottedOn
>
> % 1
> \once \override Beam.damping = #5
> bes,,8 \csm \stemDown <bes'' c es>8
> s2 |
>
> % 2
> \csl \stemUp s8
> \hideNotes \stemDown es,,64^( s64 s \unHideNotes \stemUp
> g'64\offset positions #'(-0.7 . -0.7)
> \tweak damping #3 [
> \set stemLeftBeamCount = #1
> bes c d c])
> s2 |
>
> % 3
> \once \override Beam.damping = #3
> bes,,8 \csm \stemDown <bes'' c es>8 s2 |
> }
>
> lowerVoiceTwo = \relative {
> % 1
> \voiceTwo bes,,2. |
>
> % 2
> \csh
> \once \override Beam.damping = #+inf.0
> % XXX Currently, cross-staff beaming support is partially broken. This
> % means we have to adjust the vertical beam position manually.
> \once \override Beam.positions = #'(-30 . -30)
> <bes'' es g>8 \csl es,,64 bes' es g s32. c64
> s4
> <bes des>4
>
> % 3
> bes,,2.
> }
>
> \score {
> \new PianoStaff <<
> \set PianoStaff.connectArpeggios = ##t
> \override PianoStaff.Arpeggio.stencil = #ly:arpeggio::brew-chord-bracket
> \override PianoStaff.Arpeggio.padding = #-0.5
>
> \new Staff = "high" <<
> \global
> \context Voice = "upperVoiceOne" { \upperVoiceOne }
> \context Voice = "upperVoiceTwo" { \upperVoiceTwo }
>>>
> \new Staff = "middle" <<
> \global
> \context Voice = "middleVoiceOne" { \middleVoiceOne }
> \context Voice = "middleVoiceTwo" { \middleVoiceTwo }
>>>
> \new Staff = "low" <<
> \clef bass
> \global
> \context Voice = "lowerVoiceOne" { \lowerVoiceOne }
> \context Voice = "lowerVoiceTwo" { \lowerVoiceTwo }
>>>
>>>
>
> \layout {
> \context {
> \Score
> \omit TimeSignature
> \remove "Bar_number_engraver"
> }
> \context {
> \PianoStaff
> \consists #Span_stem_engraver
> }
> \context {
> \Staff
> \override Accidental.extra-spacing-width = #'(0 . 0)
> }
> }
> }
>
> _______________________________________________
> lilypond-devel mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/lilypond-devel

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: updated Granados example

Urs Liska-3
27. September 2019 08:55, "Urs Liska" <[hidden email]> schrieb:

> Hi Werner,
>
> thanks for working on this.
>
> I have the impression it would be nice to add at least one example with an alternative notation
> font to the example page. Here is the list of freely available fonts:
> https://github.com/openlilylib-resources/lilypond-notation-fonts/tree/master/fonts (note that while
> it is *legal* to use Abraham's other fonts for which he revoked the free license we shouldn't use
> them on our website (which is unfortunate since Haydn or Gutenberg1939 would make really nice
> examples.
>
> Considering the existing content of the examples page we should probably limit this to one example,
> and for that it would probably make sense to use LilyJAZZ since that might be the most-wanted
> feature. Maybe reuse this "piece"?
> https://github.com/frescobaldi/frescobaldi/pull/1075#issuecomment-529471468
>

PS: the source for this can be found here: https://github.com/frescobaldi/frescobaldi/blob/master/frescobaldi_app/fonts/templates/musicfont-realbook.ly

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: updated Granados example

Werner LEMBERG
In reply to this post by Urs Liska-3

> I have the impression it would be nice to add at least one example
> with an alternative notation font to the example page.  [...]  Maybe
> reuse this "piece"?
> https://github.com/frescobaldi/frescobaldi/pull/1075#issuecomment-529471468

Sounds like a good idea.

> Also, I think section 3.4.4 of the NR should be updated to be much
> more explicit and suggestive.  If I can find the time I'd volunteer
> to do this.
> http://lilypond.org/doc/v2.19/Documentation/notation/replacing-the-notation-font.html

Go, go, go :-)


    Werner

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel