I have made some source patches against multi-measure-rest-engraver.cc and
multi-measure-rest.cc to modify the rest used to represent 1 measure in a
multi-measure rest.  It uses the value of the measureLength property to
determine if it should use a whole or breve rest.  If the length of the
a measure is a breve or more, it uses a breve.  Otherwise it uses a whole
rest like it normally does.  I am including patches against both 1.6.5 and
1.7.2 as well as mmrest_test.ly which shows the behaviour.  I would 
appreciate
any feedback you might have on these changes.

One other question.  In measure 206, the dotted whole rest places the dot
in the space above the rest.  This is how lilypond typeset this before I
made any changes.  Is this the desired result?  Shouldn't the dot be in
the space next to the rest?

Thanks
Kim


Kim Shrier wrote:

> Hello,
>    I am new to LilyPond and I have a question about the best way to 
> approach
> a problem.  I am typesetting some music and the time signature is 4/2.  I
> would like to modify the behaviour of multi-measure rests to use a breve
> rest to represent 1 measure instead of a whole rest since the duration of
> 1 measure is a breve.  I have looked at the church_rest method in
> multi-measure-rest.cc and I think I see how to modify it as well as the
> symbol_molecule method.  I would also have to define a parameter to get
> the information to these methods so they would know whether they were 
> using
> a whole or breve rest as their base.  This seems like a lot of work.
>
> Since one of the nice things about LilyPond is how flexible it is and you
> have hooks to get at almost everything, I was wondering if there is a 
> better
> way to approach this problem.  As I said earlier, I am new to LilyPond 
> and
> I don't have a good feel for what is possible without modifying the 
> source.
>
> Thanks,
> Kim
>


-- 
 Kim Shrier - principal, Shrier and Deihl - mailto:[EMAIL PROTECTED]
Remote Unix Network Admin, Security, Internet Software Development
  Tinker Internet Services - Superior FreeBSD-based Web Hosting
                     http://www.tinker.com/


--- lily/multi-measure-rest-engraver.cc.orig    Sun Aug  4 11:56:18 2002
+++ lily/multi-measure-rest-engraver.cc Wed Oct  9 10:19:02 2002
@@ -162,6 +162,9 @@
       int cur = gh_scm2int (get_property ("currentBarNumber"));
       lastrest_->set_grob_property ("measure-count",
                                     gh_int2scm (cur - start_measure_));
+      SCM sml = get_property ("measureLength");
+      lastrest_->set_grob_property ("measure-length", sml);
+
       mmrest_ = 0;
     }
 }
@@ -178,9 +181,10 @@
 
 ENTER_DESCRIPTION(Multi_measure_rest_engraver,
 /* descr */       "Engraves multi-measure rests that are produced with @code{R}.  
Reads
-measurePosition and currentBarNumber to determine what number to print over the 
MultiMeasureRest
+measurePosition and currentBarNumber to determine what number to print over the 
+MultiMeasureRest.
+Reads measureLength to determine if it should use a whole rest or a breve rest to 
+represent 1 measure
 ",
 /* creats*/       "MultiMeasureRest",
 /* acks  */       "",
-/* reads */       "currentBarNumber currentCommandColumn measurePosition",
+/* reads */       "currentBarNumber currentCommandColumn measurePosition 
+measureLength",
 /* write */       "");
--- lily/multi-measure-rest.cc.orig     Sun Aug  4 11:56:18 2002
+++ lily/multi-measure-rest.cc  Wed Oct  9 11:12:00 2002
@@ -15,6 +15,7 @@
 #include "rest.hh"
 #include "molecule.hh"
 #include "misc.hh"
+#include "moment.hh"
 #include "spanner.hh"
 #include "staff-symbol-referencer.hh"
 #include "text-item.hh"
@@ -163,19 +164,33 @@
   Font_metric *musfont
     = Font_interface::get_font (me,style_chain);
 
+  SCM sml = me->get_grob_property ("measure-length");
+  Moment ml = (unsmob_moment (sml)) ? *unsmob_moment (sml) : Moment (0);
+
   if (measures == 1)
     {
-      Molecule s = musfont->find_by_name (Rest::glyph_name (me, 0, ""));
+      if (ml.main_part_ < Rational (2))
+       {
+         Molecule s = musfont->find_by_name (Rest::glyph_name (me, 0, ""));
 
-      /*
-       ugh.
-       */
-      if (Staff_symbol_referencer::get_position (me) == 0.0)
-       s.translate_axis (staff_space, Y_AXIS);
+          /*
+           ugh.
+           */
+         if (Staff_symbol_referencer::get_position (me) == 0.0)
+           s.translate_axis (staff_space, Y_AXIS);
+
+          s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS);
+      
+          return s ;
+       }
+      else
+       {
+         Molecule s = musfont->find_by_name (Rest::glyph_name (me, -1, ""));
 
-      s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS);
+          s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS);
       
-      return s ;
+          return s ;
+       }
     }
   else
     {
@@ -222,37 +237,63 @@
   int l = measures;
   int count = 0;
   Real symbols_width = 0.0;
+
+  SCM sml = me->get_grob_property ("measure-length");
+  Moment ml = (unsmob_moment (sml)) ? *unsmob_moment (sml) : Moment (0);
+
   while (l)
     {
-      int k;
-      if (l >= 4)
-       {
-         l-=4;
-         k = -2;
-       }
-      else if (l>= 2)
+      if (ml.main_part_ < Rational (2))
        {
-         l -= 2;
-         k = -1;
+         int k;
+         if (l >= 4)
+           {
+             l-=4;
+             k = -2;
+           }
+         else if (l>= 2)
+           {
+             l -= 2;
+             k = -1;
+           }
+         else
+           {
+             k = 0;
+             l --;
+           }
+
+         Molecule r (musfont->find_by_name ("rests-" + to_string (k)));
+         if (k == 0)
+           {
+             Real staff_space = Staff_symbol_referencer::staff_space (me);
+             r.translate_axis (staff_space, Y_AXIS);
+           }
+         symbols_width += r.extent (X_AXIS).length ();
+         mols = gh_cons (r.smobbed_copy (), mols);
        }
       else
        {
-         k = 0;
-         l --;
+         int k;
+         if (l >= 2)
+           {
+             l-=2;
+             k = -2;
+           }
+         else
+           {
+             l -= 1;
+             k = -1;
+           }
+
+         Molecule r (musfont->find_by_name ("rests-" + to_string (k)));
+         symbols_width += r.extent (X_AXIS).length ();
+         mols = gh_cons (r.smobbed_copy (), mols);
        }
 
-      Molecule r (musfont->find_by_name ("rests-" + to_string (k)));
-      if (k == 0)
-       {
-         Real staff_space = Staff_symbol_referencer::staff_space (me);
-         r.translate_axis (staff_space, Y_AXIS);
-       }
-      symbols_width += r.extent (X_AXIS).length ();
-      mols = gh_cons (r.smobbed_copy (), mols);
       count ++;
     }
 
-  
+
 
   Real outer_padding_factor = 1.5; //     make outer padding this much bigger.
   Real inner_padding = (space - symbols_width) / (2 * outer_padding_factor + 
(count-1)); 
--- lily/multi-measure-rest-engraver.cc.orig    Mon Sep 30 04:23:42 2002
+++ lily/multi-measure-rest-engraver.cc Wed Oct  9 12:19:49 2002
@@ -158,6 +158,9 @@
       int cur = gh_scm2int (get_property ("currentBarNumber"));
       lastrest_->set_grob_property ("measure-count",
                                     gh_int2scm (cur - start_measure_));
+      SCM sml = get_property ("measureLength");
+      lastrest_->set_grob_property ("measure-length", sml);
+
       mmrest_ = 0;
     }
 }
@@ -174,10 +177,11 @@
 
 ENTER_DESCRIPTION(Multi_measure_rest_engraver,
 /* descr */       "Engraves multi-measure rests that are produced with @code{R}.  
Reads
-measurePosition and currentBarNumber to determine what number to print over the 
MultiMeasureRest
+measurePosition and currentBarNumber to determine what number to print over the 
+MultiMeasureRest.
+Reads measureLength to determine if it should use a whole rest or a breve rest to 
+represent 1 measure
 ",
 /* creats*/       "MultiMeasureRest",
 /* accepts */     "multi-measure-rest-event",
 /* acks  */      "",
-/* reads */       "currentBarNumber currentCommandColumn measurePosition",
+/* reads */       "currentBarNumber currentCommandColumn measurePosition 
+measureLength",
 /* write */       "");
--- lily/multi-measure-rest.cc.orig     Mon Aug  5 04:37:21 2002
+++ lily/multi-measure-rest.cc  Wed Oct  9 12:18:16 2002
@@ -15,6 +15,7 @@
 #include "rest.hh"
 #include "molecule.hh"
 #include "misc.hh"
+#include "moment.hh"
 #include "spanner.hh"
 #include "staff-symbol-referencer.hh"
 #include "text-item.hh"
@@ -163,19 +164,33 @@
   Font_metric *musfont
     = Font_interface::get_font (me,style_chain);
 
+  SCM sml = me->get_grob_property ("measure-length");
+  Moment ml = (unsmob_moment (sml)) ? *unsmob_moment (sml) : Moment (0);
+
   if (measures == 1)
     {
-      Molecule s = musfont->find_by_name (Rest::glyph_name (me, 0, ""));
+      if (ml.main_part_ < Rational (2))
+       {
+         Molecule s = musfont->find_by_name (Rest::glyph_name (me, 0, ""));
 
-      /*
-       ugh.
-       */
-      if (Staff_symbol_referencer::get_position (me) == 0.0)
-       s.translate_axis (staff_space, Y_AXIS);
+          /*
+           ugh.
+           */
+         if (Staff_symbol_referencer::get_position (me) == 0.0)
+           s.translate_axis (staff_space, Y_AXIS);
+
+          s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS);
+      
+          return s ;
+       }
+      else
+       {
+         Molecule s = musfont->find_by_name (Rest::glyph_name (me, -1, ""));
 
-      s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS);
+          s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS);
       
-      return s ;
+          return s ;
+       }
     }
   else
     {
@@ -222,37 +237,63 @@
   int l = measures;
   int count = 0;
   Real symbols_width = 0.0;
+
+  SCM sml = me->get_grob_property ("measure-length");
+  Moment ml = (unsmob_moment (sml)) ? *unsmob_moment (sml) : Moment (0);
+
   while (l)
     {
-      int k;
-      if (l >= 4)
-       {
-         l-=4;
-         k = -2;
-       }
-      else if (l>= 2)
+      if (ml.main_part_ < Rational (2))
        {
-         l -= 2;
-         k = -1;
+         int k;
+         if (l >= 4)
+           {
+             l-=4;
+             k = -2;
+           }
+         else if (l>= 2)
+           {
+             l -= 2;
+             k = -1;
+           }
+         else
+           {
+             k = 0;
+             l --;
+           }
+
+         Molecule r (musfont->find_by_name ("rests-" + to_string (k)));
+         if (k == 0)
+           {
+             Real staff_space = Staff_symbol_referencer::staff_space (me);
+             r.translate_axis (staff_space, Y_AXIS);
+           }
+         symbols_width += r.extent (X_AXIS).length ();
+         mols = gh_cons (r.smobbed_copy (), mols);
        }
       else
        {
-         k = 0;
-         l --;
+         int k;
+         if (l >= 2)
+           {
+             l-=2;
+             k = -2;
+           }
+         else
+           {
+             l -= 1;
+             k = -1;
+           }
+
+         Molecule r (musfont->find_by_name ("rests-" + to_string (k)));
+         symbols_width += r.extent (X_AXIS).length ();
+         mols = gh_cons (r.smobbed_copy (), mols);
        }
 
-      Molecule r (musfont->find_by_name ("rests-" + to_string (k)));
-      if (k == 0)
-       {
-         Real staff_space = Staff_symbol_referencer::staff_space (me);
-         r.translate_axis (staff_space, Y_AXIS);
-       }
-      symbols_width += r.extent (X_AXIS).length ();
-      mols = gh_cons (r.smobbed_copy (), mols);
       count ++;
     }
 
-  
+
 
   Real outer_padding_factor = 1.5; //     make outer padding this much bigger.
   Real inner_padding = (space - symbols_width) / (2 * outer_padding_factor + 
(count-1)); 
\include "paper16.ly"
\paper  {
}

\score {
  \notes \relative c'' {
    \time 4/4
    r2 r |
    r1 |
    R1 |
    R1*4 |
    \property Score.skipBars = ##t
    R1*2
    R1*10
    R1*11
    R1*17
    R1*4
    \break
    \time 4/2
    \property Score.skipBars = ##f
    r1 r |
    r\breve |
    R\breve |
    R\breve*4 |
    \property Score.skipBars = ##t
    R\breve*2
    R\breve*10
    R\breve*11
    R\breve*17
    R\breve*4
    \break
    \time 4/4
    \property Score.skipBars = ##f
    r2 r |
    r1 |
    R1 |
    R1*4 |
    \property Score.skipBars = ##t
    R1*2
    R1*10
    R1*11
    R1*17
    R1*4
    \break
    \time 3/4
    \property Score.skipBars = ##f
    r4 r r |
    r2. |
    R2. |
    R2.*4 |
    \property Score.skipBars = ##t
    R2.*2
    R2.*10
    R2.*11
    R2.*17
    R2.*4
    \break
    \time 3/2
    \property Score.skipBars = ##f
    r2 r r |
    r1. |
    R1. |
    R1.*4 |
    \property Score.skipBars = ##t
    R1.*2
    R1.*10
    R1.*11
    R1.*17
    R1.*4
    \break
    \time 2/1
    \property Score.skipBars = ##f
    r1 r |
    r\breve |
    R\breve |
    R\breve*4 |
    \property Score.skipBars = ##t
    \property Score.MultiMeasureRest \set #'expand-limit = #5
    R\breve*2
    R\breve*5
    R\breve*6
    R\breve*17
    R\breve*4
  }
}

Attachment: mmrest_test.pdf
Description: Adobe PDF document

Reply via email to