]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/mozart-hrn3-defs.ly (startGraceContext): Customize grace init.
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 24 Apr 2002 13:51:58 +0000 (13:51 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 24 Apr 2002 13:51:58 +0000 (13:51 +0000)
* scm/grob-property-description.scm (beam-space): Junk.

* lily/beam.cc (space_function): New method.
(get_interbeam): Call space-function.

* scm/grob-description.scm (Beam): Initialize space-function with
Beam::space_function.

* ly/grace-init.ly (startGraceMusic, stopGraceMusic): Set/revert
Beam.space-function.  Don't quantise grace beams.

ChangeLog
input/mozart-hrn3-defs.ly
lily/beam.cc
lily/include/beam.hh
ly/grace-init.ly
scm/grob-description.scm
scm/grob-property-description.scm

index c37daf9b07d4cdddfe46473e18268cd259a955de..f42cd102de4dc73838449e01d2852bd9dadab07d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2002-04-24  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * input/mozart-hrn3-defs.ly (startGraceContext): Customize grace init.
+
+       * scm/grob-property-description.scm (beam-space): Junk.
+
+       * lily/beam.cc (space_function): New method.
+       (get_interbeam): Call space-function.
+
+       * scm/grob-description.scm (Beam): Initialize space-function with
+       Beam::space_function.
+
+       * ly/grace-init.ly (startGraceMusic, stopGraceMusic): Set/revert
+       Beam.space-function.  Don't quantise grace beams.
+
 2002-04-23  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
        * mf/feta-nummer-code.mf (code): tweaks for three, fixes for 6
index 96dfe0b9a157d6598e95f5fee60f376e31f5c399..288e6020365d869932338c9dca1b2efdb9751a33 100644 (file)
@@ -27,6 +27,52 @@ cresc = \notes {
     \property Voice.crescendoSpanner = #'dashed-line
 }
 
+startGraceContextOrig = \startGraceContext
+
+startGraceContext = {
+    %% Huh?
+    %% \startGraceContextOrig
+
+    
+    %%URG copy from original
+    \property Voice.Stem \override  #'direction = #1
+    \property Voice.Stem \override #'length = #6
+    \property Voice.Stem \override #'lengths = 
+        #(map (lambda (x) (* 0.8 x)) '(3.5 3.5 3.5 4.5 5.0))
+    \property Voice.Stem \override #'beamed-lengths =
+        #(map (lambda (x) (* 0.8 x)) '(0.0 2.5 2.0 1.5))
+    \property Voice.Stem \override #'beamed-minimum-lengths =
+        #(map (lambda (x) (* 0.8 x)) '(0.0 1.5 1.25 1.0))
+    \property Voice.Stem \override #'no-stem-extend = ##t
+    \property Voice.Stem \override #'flag-style  = #"grace"
+    \property Voice.Beam \override #'thickness = #0.384
+
+    %% Instead of calling Beam::space_function, we should invoke
+    %% the previously active beam function...
+    \property Voice.Beam \override #'space-function =
+      #(lambda (beam mult) (* 0.8 (Beam::space_function beam mult)))
+
+    \property Voice.Beam \override #'position-callbacks =
+      #`(,Beam::least_squares
+        ,Beam::check_concave
+        ,Beam::slope_damping)
+    
+    % Can't use Staff.fontSize, since time sigs, keys sigs, etc. will
+    % be smaller as well.
+
+    \property Voice.fontSize = #-2
+    \property Staff.Accidentals \override #'font-relative-size = #-2
+    \property Voice.Slur \override #'direction = #-1
+    %% end copy
+    
+    
+    \property Voice.Beam \revert #'space-function
+    \property Voice.Beam \override #'space-function
+       = #(lambda (beam mult) (* 0.8 0.8))
+    \property Voice.Beam \revert #'thickness
+    \property Voice.Beam \override #'thickness = #(* 0.384 (/ 0.6 0.48))
+}
+
 \paper{
     \stylesheet #my-sheet
     \translator {
@@ -39,7 +85,7 @@ cresc = \notes {
         MultiMeasureRest \override #'number-threshold = #1
         
         Beam \override #'thickness = #0.6
-        Beam \override #'beam-space = #0.8
+        Beam \override #'space-function = #(lambda (beam mult) 0.8)
         Slur \override #'beautiful = #0.3
     }
     \translator {
index 898c9e0ce3f7aa10215c413c905855b7a6d6c5d2..8c360baede26e72566579fb2340910e5a642d24a 100644 (file)
@@ -67,33 +67,12 @@ Beam::add_stem (Grob *me, Grob *s)
   add_bound_item (dynamic_cast<Spanner*> (me), dynamic_cast<Item*> (s));
 }
 
-
-/*
-  TODO: fix this for grace notes.
- */
 Real
 Beam::get_interbeam (Grob *me)
 {
-  int multiplicity = get_multiplicity (me);
-  Real ss = Staff_symbol_referencer::staff_space (me);
-  
-  SCM s = me->get_grob_property ("beam-space");
-  if (gh_number_p (s))
-    return gh_scm2double (s) * ss;
-  else if (s != SCM_EOL && gh_list_p (s))
-    return gh_scm2double (scm_list_ref (s,
-                                       gh_int2scm (multiplicity - 1
-                                                   <? scm_ilength (s) - 1)))
-      * ss;
-  
-  Real slt = me->paper_l ()->get_var ("linethickness");
-  Real thickness = gh_scm2double (me->get_grob_property ("thickness")) * ss;
-
-  Real interbeam = multiplicity < 4
-    ? (2*ss + slt - thickness) / 2.0
-    : (3*ss + slt - thickness) / 3.0;
-  
-  return interbeam;
+  SCM func = me->get_grob_property ("space-function");
+  SCM s = gh_call2 (func, me->self_scm (), gh_int2scm (get_multiplicity (me)));
+  return gh_scm2double (s);
 }
 
 int
@@ -110,6 +89,25 @@ Beam::get_multiplicity (Grob *me)
   return m;
 }
 
+MAKE_SCHEME_CALLBACK (Beam, space_function, 2);
+SCM
+Beam::space_function (SCM smob, SCM multiplicity)
+{
+  Grob *me = unsmob_grob (smob);
+  
+  Real staff_space = Staff_symbol_referencer::staff_space (me);
+  Real line = me->paper_l ()->get_var ("linethickness");
+  Real thickness = gh_scm2double (me->get_grob_property ("thickness"))
+    * staff_space;
+  
+  Real interbeam = gh_scm2int (multiplicity) < 4
+    ? (2*staff_space + line - thickness) / 2.0
+    : (3*staff_space + line - thickness) / 3.0;
+  
+  return gh_double2scm (interbeam);
+}
+
+
 /* After pre-processing all directions should be set.
    Several post-processing routines (stem, slur, script) need stem/beam
    direction.
@@ -1379,5 +1377,5 @@ the ideal slope, how close the result is to the ideal stems, etc.). We
 take the best scoring combination.
 
 ",
-  "position-callbacks beam-space concaveness-gap concaveness-threshold dir-function quant-score auto-knee-gap gap chord-tremolo beamed-stem-shorten shorten least-squares-dy direction damping flag-width-function neutral-direction positions thickness");
+  "position-callbacks concaveness-gap concaveness-threshold dir-function quant-score auto-knee-gap gap chord-tremolo beamed-stem-shorten shorten least-squares-dy direction damping flag-width-function neutral-direction positions space-function thickness");
 
index dcc7ba17905d98930d84933f0902c53bcd0acbd2..e8ace6dcceda6215657006974d305289a4eb8476 100644 (file)
@@ -26,9 +26,10 @@ public:
   static void set_stemlens (Grob*);
   static int get_multiplicity (Grob*me);
   static Real get_interbeam (Grob*me);
-  DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM ));
-  DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM ));
-  DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM ));
+  DECLARE_SCHEME_CALLBACK (space_function, (SCM, SCM));
+  DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM));
+  DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
+  DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
 
   /* position callbacks */
   DECLARE_SCHEME_CALLBACK (least_squares, (SCM));
index 858e4d005793ad48ec5c9e0e864d03bf4f662f53..39079b3396f6ab0b67197ad4546df3705d3d7184 100644 (file)
@@ -11,6 +11,16 @@ startGraceMusic = {
     \property Voice.Stem \override #'no-stem-extend = ##t
     \property Voice.Stem \override #'flag-style  = #"grace"
     \property Voice.Beam \override #'thickness = #0.384
+
+    %% Instead of calling Beam::space_function, we should invoke
+    %% the previously active beam function...
+    \property Voice.Beam \override #'space-function =
+      #(lambda (beam mult) (* 0.8 (Beam::space_function beam mult)))
+
+    \property Voice.Beam \override #'position-callbacks =
+      #`(,Beam::least_squares
+        ,Beam::check_concave
+        ,Beam::slope_damping)
     
     % Can't use Staff.fontSize, since time sigs, keys sigs, etc. will
     % be smaller as well.
@@ -32,6 +42,9 @@ stopGraceMusic = {
     \property Voice.Stem \revert #'lengths    
     \property Voice.Stem \revert #'length
     \property Voice.Stem \revert #'direction    
+    \property Voice.Beam \revert #'space-function
+    
+    \property Voice.Beam \revert #'position-callbacks
     
     % Can't use Staff.fontSize, since time sigs, keys sigs, etc. will
     % be smaller as well.
index 351859214f73272eba46fbe5fccadc035114d733..5a93c2a8d4c3e0973d00a25922366c4161f3d6cd 100644 (file)
        (damping . 1)
        (auto-knee-gap . 7)
        (font-name . "cmr10")
+       (space-function . ,Beam::space_function)
        (meta . ((interfaces . (staff-symbol-referencer-interface beam-interface))))
        ))
 
index e226f9082e1e888fcd48012e7a9a78383eb32a56..b8955a9bfcee9d0f280445d51b31d047753339a7 100644 (file)
@@ -48,8 +48,6 @@ This procedure is called (using dependency resolution) after line breaking. Retu
 (grob-property-description 'shortest-duration-space number? "Start
 with this much space for the shortest duration. This is explessed in @code{spacing-increment} as unit. See also
 @ref{spacing-spanner-interface}.")
-(grob-property-description 'spacing-increment number? "Add this much space for a doubled duration. Typically, the width of a note head. See also @ref{spacing-spanner-interface}.")
-
 (grob-property-description 'arpeggio ly-grob? "pointer to arpeggio object.") 
 (grob-property-description 'arpeggio-direction dir? "If set, put an
 arrow on the arpeggio squiggly line.")
@@ -71,7 +69,6 @@ In the case of alignment grobs, this should contain only one number.")
 (grob-property-description 'bass list? " musical-pitch, optional.")
 (grob-property-description 'beam ly-grob? "pointer to the beam, if applicable.")
 (grob-property-description 'beam-thickness number? "thickness, measured in staffspace.")
-(grob-property-description 'beam-space (or number? list?) "the vertical distance between two beams, indexed by multiplicity")
 (grob-property-description 'beam-width number? "width of the tremolo sign.")
 (grob-property-description 'beamed-lengths list? "list of stem lengths given beam multiplicity .")
 (grob-property-description 'beamed-minimum-lengths list? "list of minimum stem lengths given beam multiplicity.")
@@ -300,6 +297,8 @@ TODO: revise typing.")
 (grob-property-description 'space-alist list? "Alist of break align
 spacing tuples: format = (SYMBOL . (TYPE . DISTANCE)), where TYPE can be
 minimum-space or extra-space.")
+(grob-property-description 'space-function procedure? "return interbeam space given Beam grob and multiplicity.")
+(grob-property-description 'spacing-increment number? "Add this much space for a doubled duration. Typically, the width of a note head. See also @ref{spacing-spanner-interface}.")
 
 (grob-property-description 'spacing-procedure procedure? "procedure
 taking grob as argument. This is called after