lilypond-devel
[Top][All Lists]
Advanced

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

Re: accidentals - double, editorial and invisible


From: Rune Zedeler
Subject: Re: accidentals - double, editorial and invisible
Date: Mon, 16 Jun 2003 14:47:30 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312

Han-Wen Nienhuys wrote:

[stuff snipped]


(are we going to see a patch?)

Attached.
Notice that I have not changed the new-accidental-engraver (sigh) so the patch does not compile the docu because it complains about the old properties. If one removes the new-accidental-engraver then it compiles.

Should really find some better names for accidenal-count and cautionary-count; - currently cautionary-count is the total number of accidentlas; and accidental-count is the number of un-cautionary accidentals. un-cautionary-count is not a word that i like.

Invisible accidentals? What are those for?

I don't remember who, but someone mentioned that in older editions one often didn't always insert all accidentals; if everybody knew that the accidental was to be there then there was no need to explicitly insert it into the music. Well, in the attached patch, one can say cis!!! to omit the accidental (all it took was a few %3 in the parser).


probably something like ges-\editorialSharp.  One could use a scheme
function or a special Performer to select which accidentals to use.

Hmmm, Theese accidentals would not transpose, would they?

-Rune
? bah.patch
? my.patch
? patch.diff
? input/les-nereides.dvi
? input/star-spangled-banner.dvi
? input/star-spangled-banner.midi
? input/twinkle-pop.dvi
? input/twinkle.dvi
? input/twinkle.midi
? input/mutopia/R.Schumann/romanze-op28-2.dvi
? input/mutopia/R.Schumann/romanze-op28-2.midi
? input/regression/chords-funky-ignatzek.dvi
? input/regression/custos.dvi
? input/regression/glissando.dvi
? input/regression/lyrics-multi-stanza.dvi
? input/sondag-morgen/sondag-morgen.dvi
? input/sondag-morgen/sondag-morgen.midi
? input/sondag-morgen/sondag-morgen.pdf
? input/sondag-morgen/sondag-morgen.ps
? input/template/piano-dynamics.dvi
? input/template/piano-dynamics.midi
? input/test/ac-extra-voice.dvi
? input/test/ac-extra-voice.midi
? input/test/beam-chord.dvi
? input/test/beam-pos.dvi
? input/test/beam-second.dvi
? input/test/blank-notes.dvi
? input/test/chord-names-german.dvi
? input/test/embedded-postscript.dvi
? input/test/lyric-hyphen.dvi
? input/test/lyric-phrasing.dvi
? input/test/lyrics.dvi
? input/test/metronome.dvi
? input/test/missfont.log
? input/test/music-box.dvi
? input/test/music-box.midi
? input/test/repeat-manual.dvi
? input/test/rest-test.dvi
? input/test/to-xml.latex
? input/test/to-xml.tex
? lily/new-accidental-engraver.not
? mf/feta13.dvi
Index: ChangeLog
===================================================================
RCS file: /cvsroot/lilypond/lilypond/ChangeLog,v
retrieving revision 1.994
diff -p -u -r1.994 ChangeLog
--- ChangeLog   16 Jun 2003 08:35:34 -0000      1.994
+++ ChangeLog   16 Jun 2003 12:36:40 -0000
@@ -1,3 +1,27 @@
+2003-06-16  Rune Zedeler  <address@hidden>
+
+       * lily/parser.yy (chord_body_element, simple_element): make '?' and
+       '!' set music properties "cautionary-count" and "accidental-count"
+       instead of "force-accidental" and "cautionary".
+       Now cis!! cis?? and cis?! forces double accidentals.
+       cis!!! makes the accidental invisible.
+
+       * lily/accidental.cc (brew_molecule): Read grob properties
+       "cautionary-count", "accidental-count" and "accidental" instead of
+       "cautionary" and "accidentals".
+       TODO: mixed fonts when having cis?! with reduced-size-cautionaries
+
+       * lily/accidental-engraver.cc (process_acknowledged_grobs): Read
+       and set the new properties instead of the old ones: If
+       "accidental-count" and "cautionary-count" are both unset, then
+       calculate them; otherwise use them.
+
+       * scm/define-grob-properties.scm: Describe new properties and
+       scrap old ones.
+
+       * scm/define-music-properties.scm: Describe new properties and
+       scrap old ones.
+
 2003-06-16  Han-Wen Nienhuys  <address@hidden>
 
        * lily/slur.cc: remove slur over rest warnings.
Index: lily/accidental-engraver.cc
===================================================================
RCS file: /cvsroot/lilypond/lilypond/lily/accidental-engraver.cc,v
retrieving revision 1.37
diff -p -u -r1.37 accidental-engraver.cc
--- lily/accidental-engraver.cc 26 Apr 2003 23:59:15 -0000      1.37
+++ lily/accidental-engraver.cc 16 Jun 2003 12:36:40 -0000
@@ -247,21 +247,32 @@ Accidental_engraver::process_acknowledge
          Translator_group * origin = accidentals_[i].origin_;
 
          Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch"));
-         int num = number_accidentals (note, pitch, origin, accidentals, 
barnum);
+         int num_acc = number_accidentals (note, pitch, origin, accidentals, 
barnum);
          int num_caut = number_accidentals (note, pitch, origin, cautionaries, 
barnum);
-         bool cautionary = to_boolean (note->get_mus_property ("cautionary"));
-         
-         if (abs (num_caut) > abs (num))
+         bool different = num_caut < 0 || num_acc < 0;
+         num_caut = abs (num_caut);
+         num_acc = abs (num_acc);
+
+         SCM forced_num_acc_s = note->get_mus_property ("accidental-count");
+         SCM forced_num_caut_s = note->get_mus_property ("cautionary-count");
+         if (gh_number_p(forced_num_caut_s) || gh_number_p(forced_num_acc_s))
            {
-             num = num_caut;
-             cautionary = true;
+             num_caut = gh_number_p(forced_num_caut_s) ?
+               gh_scm2int(forced_num_caut_s) : 0;
+             num_acc = gh_number_p(forced_num_acc_s) ?
+               gh_scm2int(forced_num_acc_s) : 0;
            }
+         else if(!extra_natural_b)
+           {
+             if(num_caut>1) num_caut = 1;
+             if(num_acc>1) num_acc = 1;
+           }
+
 
-         if(num==0 && to_boolean (note->get_mus_property ("force-accidental")))
-            num=1;
-         
-         bool different = num < 0;
-         num = abs (num);
+         if (abs (num_caut) < abs (num_acc))
+           {
+             num_caut = num_acc;
+           }
 
          /* see if there's a tie that "changes" the accidental */
          /* works because if there's a tie, the note to the left
@@ -285,7 +296,7 @@ Accidental_engraver::process_acknowledge
                break;
              }
 
-         if (num)
+         if (num_caut)
            {
              Grob * a = new Item (get_property ("Accidental"));
              a->set_parent (support, Y_AXIS);
@@ -300,19 +311,10 @@ Accidental_engraver::process_acknowledge
              announce_grob (a, SCM_EOL);
 
              
-             SCM accs = gh_cons (scm_int2num (pitch->get_alteration ()), 
SCM_EOL);
-             if (num == 2 && extra_natural_b)
-               accs = gh_cons (scm_int2num (0), accs);
+             SCM acc = scm_int2num (pitch->get_alteration ());
 
-             /* TODO:
-
-             add cautionary option in accidental.
-              */
-
-             if (cautionary)
-               {
-                 a->set_grob_property ("cautionary", SCM_BOOL_T);
-               }
+             a->set_grob_property ("cautionary-count", gh_int2scm(num_caut));
+             a->set_grob_property ("accidental-count", gh_int2scm(num_acc));
              
              if (tie_break_reminder)
                {
@@ -323,7 +325,7 @@ Accidental_engraver::process_acknowledge
              
              support->set_grob_property ("accidental-grob", a->self_scm ());
 
-             a->set_grob_property ("accidentals", accs);
+             a->set_grob_property ("accidental", acc);
              accidentals_[i].accidental_ = a;
  /*
        We add the accidentals to the support of the arpeggio, so it is put 
left of the
Index: lily/accidental.cc
===================================================================
RCS file: /cvsroot/lilypond/lilypond/lily/accidental.cc,v
retrieving revision 1.12
diff -p -u -r1.12 accidental.cc
--- lily/accidental.cc  7 Dec 2002 12:40:49 -0000       1.12
+++ lily/accidental.cc  16 Jun 2003 12:36:40 -0000
@@ -9,7 +9,9 @@
 
   'accidentals should go, for a single 'accidental property -- see
   accidental-placement.cc
-
+  ---
+  ??? What was the idea with this? I saw nothing in accidental-placement.cc
+  -rz
 */
 
 
@@ -151,11 +153,14 @@ SCM
 Accidental_interface::brew_molecule (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
+  int num_caut  = gh_scm2int (me->get_grob_property ("cautionary-count"));
+  int num_acc  = gh_scm2int (me->get_grob_property ("accidental-count"));
+
   bool smaller = false;
   bool parens = false;
-
-  bool caut  = to_boolean (me->get_grob_property ("cautionary"));
-  if (caut)
+  
+  // Don't read properties if not needed
+  if(num_caut > num_acc)
     {
       SCM cstyle = me->get_grob_property ("cautionary-style");
       parens = gh_equal_p (cstyle, ly_symbol2scm ("parentheses"));
@@ -177,6 +182,7 @@ Accidental_interface::brew_molecule (SCM
     }
 
   Font_metric *fm = 0;
+  // TODO: Mixed fonts when having cis?!
   if (smaller)
     {
       SCM ac = Font_interface::font_alist_chain (me);
@@ -190,10 +196,10 @@ Accidental_interface::brew_molecule (SCM
     fm = Font_interface::get_default_font (me);
 
   Molecule mol;
-  for (SCM s = me->get_grob_property ("accidentals");
-       gh_pair_p (s); s = gh_cdr (s))
+  int acc_alt = gh_scm2int(me->get_grob_property ("accidental"));
+  for (int i=0; i<num_caut; i++)
     {
-      int alteration = gh_scm2int (gh_car (s));
+      int alteration = i==num_caut-1 ? acc_alt : 0;
       String font_char = get_fontcharname (style, alteration);
       Molecule acc (fm->find_by_name ("accidentals-" + font_char));
 
@@ -205,10 +211,13 @@ Accidental_interface::brew_molecule (SCM
        {
          mol.add_at_edge (X_AXIS,  RIGHT, acc, 0.1,0);
        }
+      if (i==num_caut-num_acc-1) {
+       if (parens)
+         mol = parenthesize (me, mol); 
+       // TODO: Else: select full size font
+      }
     }
 
-  if (parens)
-    mol = parenthesize (me, mol); 
 
   return mol.smobbed_copy();
 }
@@ -217,4 +226,4 @@ Accidental_interface::brew_molecule (SCM
 
 ADD_INTERFACE (Accidental_interface, "accidental-interface",
              "a single accidental",
-              "cautionary cautionary-style style tie accidentals");
+              "cautionary-count accidental-count cautionary-style style tie 
accidental");
Index: lily/parser.yy
===================================================================
RCS file: /cvsroot/lilypond/lilypond/lily/parser.yy,v
retrieving revision 1.241
diff -p -u -r1.241 parser.yy
--- lily/parser.yy      17 May 2003 23:26:30 -0000      1.241
+++ lily/parser.yy      16 Jun 2003 12:36:40 -0000
@@ -1262,15 +1262,16 @@ chord_body_elements:
        ;
 
 chord_body_element:
-       pitch exclamations questions post_events
+       pitch questions exclamations post_events
        {
                Music * n = MY_MAKE_MUSIC("NoteEvent");
                n->set_mus_property ("pitch", $1);
-               if ($3 % 2)
-                       n->set_mus_property ("cautionary", SCM_BOOL_T);
-               if ($2 % 2 || $3 % 2)
-                       n->set_mus_property ("force-accidental", SCM_BOOL_T);
-
+               if( $2 + $3 ) {
+                       n->set_mus_property ("cautionary-count",
+                               gh_int2scm( ( $2 + $3 ) % 3));
+                       n->set_mus_property ("accidental-count",
+                               gh_int2scm( $3 % 3 ));
+               }
                SCM arts = scm_reverse_x ($4, SCM_EOL);
                n->set_mus_property ("articulations", arts);
 
@@ -1922,7 +1923,7 @@ optional_rest:
        ;
 
 simple_element:
-       pitch exclamations questions optional_notemode_duration optional_rest {
+       pitch questions exclamations optional_notemode_duration optional_rest {
 
                Input i = THIS->pop_spot ();
                if (!THIS->lexer_->note_state_b ())
@@ -1937,11 +1938,12 @@ simple_element:
                n->set_mus_property ("pitch", $1);
                n->set_mus_property ("duration", $4);
 
-
-               if ($3 % 2)
-                       n->set_mus_property ("cautionary", SCM_BOOL_T);
-               if ($2 % 2 || $3 % 2)
-                       n->set_mus_property ("force-accidental", SCM_BOOL_T);
+               if( $2 + $3 ) {
+                       n->set_mus_property ("cautionary-count",
+                               gh_int2scm( ( $2 + $3 ) % 3));
+                       n->set_mus_property ("accidental-count",
+                               gh_int2scm( $3 % 3 ));
+               }
 
                Music *v = MY_MAKE_MUSIC("EventChord");
                v->set_mus_property ("elements", scm_list_n (n->self_scm (), 
SCM_UNDEFINED));
Index: scm/define-grob-properties.scm
===================================================================
RCS file: /cvsroot/lilypond/lilypond/scm/define-grob-properties.scm,v
retrieving revision 1.2
diff -p -u -r1.2 define-grob-properties.scm
--- scm/define-grob-properties.scm      13 Jun 2003 23:12:42 -0000      1.2
+++ scm/define-grob-properties.scm      16 Jun 2003 12:36:41 -0000
@@ -59,8 +59,9 @@ the grob to the nearest open space.
 (grob-property-description 'Y-extent-callback procedure? "see 
@code{X-extent-callback}.")
 (grob-property-description 'Y-offset-callbacks list? "see 
@code{X-offset-callbacks}.")
 
+(grob-property-description 'accidental number? "alteration number.")
+(grob-property-description 'accidental-count number? "The number of real - 
uncautionary - accidental-symbols to be typset in this Accidental.")
 (grob-property-description 'accidental-grobs list? "Alis with (NOTENAME . 
GROBLIST) entries")
-(grob-property-description 'accidentals list? "List of alteration numbers.")
 (grob-property-description 'add-stem boolean? "does this flexa shape require 
an additional stem on the left side?.")
 (grob-property-description 'adjust-if-on-staffline boolean? "If this grob is 
on a staff line, adjust its appearance, so that it better fits into the staff.  
E.g., if set true on stem grobs, flares of mensural flags will always be 
aligned with the staff lines, regardless if the associated note head is printed 
on a staff line or inbetween.")
 (grob-property-description 'after-line-breaking-callback procedure? "Procedure 
taking a grob as argument.
@@ -124,9 +125,8 @@ column as start/begin point. Only column
 (grob-property-description 'break-glyph-function procedure? "function taking 
glyph and break-direction, returning the glyph at a line break.")
 (grob-property-description 'breakable boolean? "boolean indicating if this is 
a breakable item (clef, barline, key sig, etc.).")
 (grob-property-description 'c0-position integer? "integer indicating the 
position of central C.")
+(grob-property-description 'cautionary-count number? "The total number of 
accidental-symbols to be typset in this Accidental. Including both cautionary 
accidentals and real accidentals.")
 (grob-property-description 'cautionary-style symbol? "style  of cautionary 
accidentals. Choices are 'smaller (one size smaller) or 'parentheses.")
-(grob-property-description 'cautionary boolean? "is this a cautionary 
accidentals.?")
-
 (grob-property-description 'center-element ly:grob? "grob which will
 be at the center of the group after aligning (when using
 Align_interface::center_on_element). .")
Index: scm/define-music-properties.scm
===================================================================
RCS file: /cvsroot/lilypond/lilypond/scm/define-music-properties.scm,v
retrieving revision 1.1
diff -p -u -r1.1 define-music-properties.scm
--- scm/define-music-properties.scm     17 May 2003 21:49:19 -0000      1.1
+++ scm/define-music-properties.scm     16 Jun 2003 12:36:41 -0000
@@ -27,13 +27,14 @@
 (music-property-description 'span-type string? "What kind of spanner should be 
created?
 
 TODO: consider making type into symbol") 
+(music-property-description 'accidental-count number? "The number of real - 
uncautionary - accidental-symbols to be typset in front of this note.")
 (music-property-description 'articulations music-list?
                            "Articulation events specifically for this note.")
 (music-property-description 'articulation-type string? "key for script 
definitions alist.
 
 TODO: consider making type into symbol ")
 (music-property-description 'bass boolean? "Set if this note is a bass note in 
a chord")
-(music-property-description 'cautionary boolean? "If set, this alteration 
needs cautionary accidental")
+(music-property-description 'cautionary-count number? "The total number of 
accidental-symbols to be typeset in front of this note. Including both 
cautionary accidentals and real accidentals.")
 (music-property-description 'change-to-id string? "name of the context to 
change to ")
 (music-property-description 'change-to-type string? "type of the context to 
change to.")
 (music-property-description 'compress-procedure procedure? "compress this 
music expression. Argument 1: the music, arg 2: factor")
@@ -47,7 +48,6 @@ TODO: consider making type into symbol "
 (music-property-description 'tonic ly:pitch? "Base of the scale")
 (music-property-description 'element ly:music? "The single child of a 
Music_wrapper music object, or the body of a repeat.")
 (music-property-description 'elements music-list? "A list of elements for 
sequential of simultaneous music, or the alternatives of repeated music. ")
-(music-property-description 'force-accidental boolean? "If set, a cautionary 
accidental should always be printed on this note")
 (music-property-description 'grob-property symbol? "The symbol of the grob 
property to set. ")
 (music-property-description 'grob-value scheme? "The value of the grob 
property to set")
 (music-property-description 'inversion boolean? "If set, this chord note is 
inverted.")

reply via email to

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