[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Modifying multi-measure rests
From: |
Kim Shrier |
Subject: |
Re: Modifying multi-measure rests |
Date: |
Thu, 10 Oct 2002 05:14:33 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.0.0) Gecko/20020911 |
I have redone the patch and used a boolean variable, mm-rest-breve, that
is set by
multi-measure-rest-engraver.cc when the duration of a measure is a breve
or longer.
This flag is examined by multi-measure-rest.cc to decide which rest to
use to
represent 1 measure. I have also added some sketchy comments in
grob-description.scm
and grob-property-description.scm. what else should I update?
Kim
Han-Wen Nienhuys wrote:
[moving discussion to lilypond-devel.]
address@hidden writes:
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.
You're putting musical information into the backend by copying
measureLength into measure-length, and in general, this decreases the
flexibility of the system. Can you adapt the patch such that the
engraver simply sets a flag (eg. a boolean) in the grob? AFAICT, you
only use measure-length to examine wether it's main_part_ is bigger
than 2.
--
Kim Shrier - principal, Shrier and Deihl - mailto:address@hidden
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 Thu Oct 10 01:40:09 2002
@@ -162,6 +162,17 @@
int cur = gh_scm2int (get_property ("currentBarNumber"));
lastrest_->set_grob_property ("measure-count",
gh_int2scm (cur - start_measure_));
+ SCM sml = get_property ("measureLength");
+ Rational ml = (unsmob_moment (sml)) ? unsmob_moment (sml)->main_part_ :
Rational (1);
+ if (ml < Rational (2))
+ {
+ lastrest_->set_grob_property ("mm-rest-breve", SCM_BOOL_F);
+ }
+ else
+ {
+ lastrest_->set_grob_property ("mm-rest-breve", SCM_BOOL_T);
+ }
+
mmrest_ = 0;
}
}
@@ -178,9 +189,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 Thu Oct 10 04:49:41 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,32 @@
Font_metric *musfont
= Font_interface::get_font (me,style_chain);
+ SCM sml = me->get_grob_property ("mm-rest-breve");
+
if (measures == 1)
{
- Molecule s = musfont->find_by_name (Rest::glyph_name (me, 0, ""));
+ if (sml == SCM_BOOL_T)
+ {
+ Molecule s = musfont->find_by_name (Rest::glyph_name (me, -1, ""));
+
+ 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, 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);
+ s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS);
- return s ;
+ return s ;
+ }
}
else
{
@@ -222,37 +236,62 @@
int l = measures;
int count = 0;
Real symbols_width = 0.0;
+
+ SCM sml = me->get_grob_property ("mm-rest-breve");
+
while (l)
{
- int k;
- if (l >= 4)
- {
- l-=4;
- k = -2;
- }
- else if (l>= 2)
+ if (sml == SCM_BOOL_T)
{
- l -= 2;
- k = -1;
+ 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);
}
else
{
- k = 0;
- l --;
+ 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);
}
- 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));
@@ -333,4 +372,4 @@
",
- "expand-limit measure-count number-threshold padding thickness");
+ "expand-limit measure-count number-threshold padding thickness
mm-rest-breve");
--- scm/grob-description.scm.orig Mon Sep 9 03:45:26 2002
+++ scm/grob-description.scm Thu Oct 10 04:55:20 2002
@@ -528,6 +528,7 @@
(number-threshold . 1)
(padding . 1)
(thickness . 6.6)
+ (mm-rest-breve . #f)
(font-family . number)
(padding . 1)
(meta . ((interfaces . (multi-measure-rest-interface rest-interface
font-interface staff-symbol-referencer-interface spanner-interface))))
--- scm/grob-property-description.scm.orig Thu Sep 26 06:08:25 2002
+++ scm/grob-property-description.scm Thu Oct 10 05:00:40 2002
@@ -330,6 +330,7 @@
FIXME: also pair? (cons LEFT RIGHT)
")
+(grob-property-description 'mm-rest-breve boolean? "boolean that tells
multi-measure-rest to use a breve rest to represent the duration of 1 measure
instead of w whole rest. It defaults to false. It is set to true when the
duration of a measure is a breve or longer.")
(grob-property-description 'molecule-callback procedure? "Function
taking grob as argument, returning a smobbed Molecule.