CVSROOT:        /cvsroot/lilypond
Module name:    lilypond
Branch:         
Changes by:     Han-Wen Nienhuys <[EMAIL PROTECTED]>    05/07/21 12:14:35

Modified files:
        .              : ChangeLog THANKS 
        Documentation/topdocs: NEWS.tely 
        Documentation/user: instrument-notation.itely 
        lily           : accidental-engraver.cc engraver.cc 
        lily/include   : engraver.hh 
        scm            : define-context-properties.scm 
                         define-grob-interfaces.scm define-grobs.scm 
Added files:
        input/regression: accidental-suggestions.ly 

Log message:
        

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.3905&tr2=1.3906&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/THANKS.diff?tr1=1.134&tr2=1.135&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/Documentation/topdocs/NEWS.tely.diff?tr1=1.43&tr2=1.44&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/Documentation/user/instrument-notation.itely.diff?tr1=1.36&tr2=1.37&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/input/regression/accidental-suggestions.ly?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/accidental-engraver.cc.diff?tr1=1.103&tr2=1.104&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/engraver.cc.diff?tr1=1.71&tr2=1.72&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/include/engraver.hh.diff?tr1=1.54&tr2=1.55&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/define-context-properties.scm.diff?tr1=1.45&tr2=1.46&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/define-grob-interfaces.scm.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/define-grobs.scm.diff?tr1=1.214&tr2=1.215&r1=text&r2=text

Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.3905 lilypond/ChangeLog:1.3906
--- lilypond/ChangeLog:1.3905   Thu Jul 21 10:53:12 2005
+++ lilypond/ChangeLog  Thu Jul 21 12:14:34 2005
@@ -7,6 +7,17 @@
 
 2005-07-21  Han-Wen Nienhuys  <[EMAIL PROTECTED]>
 
+       * Documentation/topdocs/NEWS.tely (Top): add note about Musica ficta.
+
+       * Documentation/user/instrument-notation.itely (Musica ficta
+       accidentals): add section Musica ficta accidentals
+
+       * lily/accidental-engraver.cc (make_suggested_accidental): new function.
+       (make_standard_accidental): move into new function.
+       (create_accidental): new function.
+
+       * scm/define-grobs.scm (all-grob-descriptions): new Grob 
AccidentalSuggestion
+
        * lily/output-def-scheme.cc (LY_DEFINE): take default  argument.
 
        * lily/output-def.cc (lookup_variable): return SCM_UNDEFINED if 
undefined.
Index: lilypond/Documentation/topdocs/NEWS.tely
diff -u lilypond/Documentation/topdocs/NEWS.tely:1.43 
lilypond/Documentation/topdocs/NEWS.tely:1.44
--- lilypond/Documentation/topdocs/NEWS.tely:1.43       Mon Jul 18 23:41:58 2005
+++ lilypond/Documentation/topdocs/NEWS.tely    Thu Jul 21 12:14:35 2005
@@ -32,6 +32,18 @@
 
 
 @itemize @bullet
+
[EMAIL PROTECTED]
+Suggested accidentals (for notating musica ficta) may be switched on
+with @code{suggestAccidentals}
+
[EMAIL PROTECTED],fragment,relative=2]
+\set suggestAccidentals = ##t
+ais bis
[EMAIL PROTECTED] lilypond 
+
+This feature was sponsored by Nancho Alvarez.
+
 @item
 The setting @code{whichBar} and time-bookkeeping is now split into a
 @code{Default_bar_line_engraver} and @code{Timing_translator}
Index: lilypond/Documentation/user/instrument-notation.itely
diff -u lilypond/Documentation/user/instrument-notation.itely:1.36 
lilypond/Documentation/user/instrument-notation.itely:1.37
--- lilypond/Documentation/user/instrument-notation.itely:1.36  Tue Jun 14 
15:15:59 2005
+++ lilypond/Documentation/user/instrument-notation.itely       Thu Jul 21 
12:14:35 2005
@@ -1940,10 +1940,12 @@
 * Ligatures::                   
 * Gregorian Chant contexts::    
 * Mensural contexts::           
+* Musica ficta accidentals::    
 * Figured bass::                
 @end menu
 
 
+
 @node Ancient note heads
 @subsection Ancient note heads
 
@@ -3771,6 +3773,31 @@
 }
 @end lilypond
 
[EMAIL PROTECTED] Musica ficta accidentals
[EMAIL PROTECTED] Musica ficta accidentals
+
+In European music from before about 1600, singers were often expected
+to chromatically alter notes at their own initiative. This is called
+``Musica Ficta''. In modern transcriptions, these accidentals are
+usually printed over the note.
+
[EMAIL PROTECTED] Musica ficta
+
+Support for such suggested accidentals is included, and can be
+switched on by setting @code{suggestAccidentals} to true.
+
[EMAIL PROTECTED] @code{suggestAccidentals}
+
[EMAIL PROTECTED],fragment,relative=1]
+fis gis
+\set suggestAccidentals = ##t
+ais bis
[EMAIL PROTECTED] lilypond 
+
[EMAIL PROTECTED]
+
+Program reference: @internalsref{Accidental_engraver} engraver and the
[EMAIL PROTECTED] object.
 
 @node Figured bass
 @subsection Figured bass
Index: lilypond/THANKS
diff -u lilypond/THANKS:1.134 lilypond/THANKS:1.135
--- lilypond/THANKS:1.134       Wed Jul 20 10:55:26 2005
+++ lilypond/THANKS     Thu Jul 21 12:14:34 2005
@@ -21,6 +21,7 @@
 
 Jamie Bullock
 D. Josiah Boothby
+Nancho Alvarez
 Sven Axelsson
 
 
Index: lilypond/lily/accidental-engraver.cc
diff -u lilypond/lily/accidental-engraver.cc:1.103 
lilypond/lily/accidental-engraver.cc:1.104
--- lilypond/lily/accidental-engraver.cc:1.103  Mon Jul 18 23:37:24 2005
+++ lilypond/lily/accidental-engraver.cc        Thu Jul 21 12:14:35 2005
@@ -28,7 +28,7 @@
   Music *melodic_;
   Grob *accidental_;
   Context *origin_;
-  Engraver *origin_trans_;
+  Engraver *origin_engraver_;
   Grob *head_;
   bool tied_;
 
@@ -47,10 +47,12 @@
 
 class Accidental_engraver : public Engraver
 {
-public:
   int get_bar_number ();
   void update_local_key_signature ();
-
+  void create_accidental (Accidental_entry *entry, bool, bool);
+  Grob *make_standard_accidental (Music *note, Grob *note_head, Engraver 
*trans);
+  Grob *make_suggested_accidental (Music *note, Grob *note_head, Engraver 
*trans);
+  
 protected:
   TRANSLATOR_DECLARATIONS (Accidental_engraver);
   PRECOMPUTED_VIRTUAL void process_music ();
@@ -59,14 +61,16 @@
   virtual void initialize ();
   PRECOMPUTED_VIRTUAL void process_acknowledged ();
   virtual void finalize ();
-
   virtual void derived_mark () const;
+
 public:
   SCM last_keysig_;    // ugh.
 
-  /* Urgh. Since the accidentals depend on lots of variables, we have
-     to store all information before we can really create the
-     accidentals.  */
+  /*
+    Urgh. Since the accidentals depend on lots of variables, we have
+    to store all information before we can really create the
+    accidentals.
+  */
   Link_array<Grob> left_objects_;
   Link_array<Grob> right_objects_;
 
@@ -74,6 +78,8 @@
 
   Array<Accidental_entry> accidentals_;
   Link_array<Spanner> ties_;
+
+
 };
 
 /*
@@ -311,13 +317,12 @@
       SCM cautionaries = get_property ("autoCautionaries");
       int barnum = get_bar_number ();
 
-      bool extra_natural_b = get_property ("extraNatural") == SCM_BOOL_T;
       for (int i = 0; i < accidentals_.size (); i++)
        {
          if (accidentals_[i].done_)
            continue;
          accidentals_[i].done_ = true;
-         Grob *support = accidentals_[i].head_;
+
          Music *note = accidentals_[i].melodic_;
          Context *origin = accidentals_[i].origin_;
 
@@ -351,51 +356,109 @@
             us before the notes. */
          if (num)
            {
-             /*
-               We construct the accidentals at the originating Voice
-               level, so that we get the property settings for
-               Accidental from the respective Voice.
-             */
-             Grob *a
-               = make_item_from_properties (accidentals_[i].origin_trans_,
-                                            ly_symbol2scm ("Accidental"),
-                                            note->self_scm (),
-                                            "Accidental");
-             a->set_parent (support, Y_AXIS);
-
-             if (!accidental_placement_)
-               accidental_placement_ = make_item ("AccidentalPlacement",
-                                                  a->self_scm ());
-             Accidental_placement::add_accidental (accidental_placement_, a);
-             SCM accs = scm_cons (scm_int2num (pitch->get_alteration ()),
-                                  SCM_EOL);
-             if (num == 2 && extra_natural_b)
-               accs = scm_cons (scm_int2num (0), accs);
-
-             /* TODO: add cautionary option in accidental. */
-
-             if (cautionary)
-               a->set_property ("cautionary", SCM_BOOL_T);
-
-             support->set_object ("accidental-grob", a->self_scm ());
-
-             a->set_property ("accidentals", accs);
-             accidentals_[i].accidental_ = a;
-
-             /*
-               We add the accidentals to the support of the arpeggio,
-               so it is put left of the accidentals.
-             */
-             for (int i = 0; i < left_objects_.size (); i++)
-               Side_position_interface::add_support (left_objects_[i], a);
-             for (int i = 0; i < right_objects_.size (); i++)
-               Side_position_interface::add_support (a, right_objects_[i]);
+             create_accidental (&accidentals_[i], num > 1, cautionary);
            }
        }
     }
 }
 
 void
+Accidental_engraver::create_accidental (Accidental_entry *entry,
+                                       bool restore_natural,
+                                       bool cautionary)
+{
+  Music *note = entry->melodic_;
+  Grob *support = entry->head_;
+  Pitch *pitch = unsmob_pitch (note->get_property ("pitch"));
+  
+  
+  bool as_suggestion = get_property ("suggestAccidentals");
+  Grob *a = 0;
+  if (as_suggestion)
+    a = make_suggested_accidental (note, support, entry->origin_engraver_);
+  else
+    a = make_standard_accidental (note, support, entry->origin_engraver_);
+ 
+  SCM accs = scm_cons (scm_int2num (pitch->get_alteration ()),
+                      SCM_EOL);
+  if (restore_natural)
+    {
+      if (to_boolean (get_property ("extraNatural")))
+       accs = scm_cons (scm_int2num (0), accs);
+    }
+  
+  /* TODO: add cautionary option in accidental. */
+  if (cautionary)
+    a->set_property ("cautionary", SCM_BOOL_T);
+
+
+  a->set_property ("accidentals", accs);
+  entry->accidental_ = a;
+}
+
+Grob *
+Accidental_engraver::make_standard_accidental (Music *note,
+                                              Grob *support,
+                                              Engraver *trans)
+{
+  
+  /*
+    We construct the accidentals at the originating Voice
+    level, so that we get the property settings for
+    Accidental from the respective Voice.
+  */
+  Grob *a
+    = make_grob_from_properties (trans,
+                                ly_symbol2scm ("Accidental"),
+                                note->self_scm (),
+                                "Accidental");
+
+  /*
+    We add the accidentals to the support of the arpeggio,
+    so it is put left of the accidentals.
+  */
+  for (int i = 0; i < left_objects_.size (); i++)
+    Side_position_interface::add_support (left_objects_[i], a);
+  for (int i = 0; i < right_objects_.size (); i++)
+    Side_position_interface::add_support (a, right_objects_[i]);
+
+  a->set_parent (support, Y_AXIS);
+
+  if (!accidental_placement_)
+    accidental_placement_ = make_item ("AccidentalPlacement",
+                                      a->self_scm ());
+  Accidental_placement::add_accidental (accidental_placement_, a);
+  
+  support->set_object ("accidental-grob", a->self_scm ());
+
+  return a;
+}
+
+
+Grob *
+Accidental_engraver::make_suggested_accidental (Music *note,
+                                                  Grob *note_head, Engraver 
*trans)
+{
+  
+  Grob *a
+    = make_grob_from_properties (trans,
+                                ly_symbol2scm ("AccidentalSuggestion"),
+                                note->self_scm (),
+                                "AccidentalSuggestion");
+
+  
+  Side_position_interface::add_support (a, note_head);
+  if (Grob *stem = unsmob_grob (a->get_object ("stem")))
+    {
+      Side_position_interface::add_support (a, stem);
+    }
+
+  a->set_parent (note_head, X_AXIS);
+  return a;
+}
+
+
+void
 Accidental_engraver::finalize ()
 {
   last_keysig_ = SCM_EOL;
@@ -489,14 +552,17 @@
       && note->is_mus_type ("note-event")
       && Rhythmic_head::has_interface (info.grob ()))
     {
+      /*
+       String harmonics usually don't have accidentals.
+       */
       if (to_boolean (get_property ("harmonicAccidentals"))
          || !ly_is_equal (info.grob ()->get_property ("style"),
                            ly_symbol2scm ("harmonic")))
        {
          Accidental_entry entry;
          entry.head_ = info.grob ();
-         entry.origin_trans_ = dynamic_cast<Engraver *> 
(info.origin_translator ());
-         entry.origin_ = entry.origin_trans_->context ();
+         entry.origin_engraver_ = dynamic_cast<Engraver *> 
(info.origin_translator ());
+         entry.origin_ = entry.origin_engraver_->context ();
          entry.melodic_ = note;
 
          accidentals_.push (entry);
@@ -527,12 +593,16 @@
                "This engraver usually lives at Staff level, but "
                "reads the settings for Accidental at @code{Voice} level, "
                "so you can @code{\\override} them at @code{Voice}. ",
-               "Accidental",
+               "Accidental AccidentalSuggestion",
+
                "",
+               
+               /* acks */
                "arpeggio-interface "
                "finger-interface "
                "rhythmic-head-interface "
                "tie-interface ",
+
                "autoAccidentals "
                "autoCautionaries "
                "extraNatural "
Index: lilypond/lily/engraver.cc
diff -u lilypond/lily/engraver.cc:1.71 lilypond/lily/engraver.cc:1.72
--- lilypond/lily/engraver.cc:1.71      Mon Jul 18 23:37:24 2005
+++ lilypond/lily/engraver.cc   Thu Jul 21 12:14:35 2005
@@ -59,7 +59,11 @@
 #include "translator.icc"
 
 ADD_TRANSLATOR (Engraver,
-               "", "",
+               "Base class for engravers. Does nothing, so it is not used.",
                "",
-               "", "", "");
+               "",
+               "",
+               "",
+               "");
+
 
Index: lilypond/lily/include/engraver.hh
diff -u lilypond/lily/include/engraver.hh:1.54 
lilypond/lily/include/engraver.hh:1.55
--- lilypond/lily/include/engraver.hh:1.54      Mon Jul 18 23:37:25 2005
+++ lilypond/lily/include/engraver.hh   Thu Jul 21 12:14:35 2005
@@ -48,6 +48,7 @@
 #define make_item(x, cause) make_item_from_properties (this, ly_symbol2scm 
(x), cause, x)
 #define make_spanner(x, cause) make_spanner_from_properties (this, 
ly_symbol2scm (x), cause, x)
 #define make_paper_column(x) make_paper_column_from_properties (this, 
ly_symbol2scm (x), x)
+Grob *make_grob_from_properties (Engraver *tr, SCM symbol, SCM cause, const 
char *name);
 Item *make_item_from_properties (Engraver *tg, SCM x, SCM cause, const char 
*name);
 Spanner *make_spanner_from_properties (Engraver *tg, SCM x, SCM cause, const 
char *name);
 Paper_column *make_paper_column_from_properties (Engraver *tg, SCM x, const 
char *name);
Index: lilypond/scm/define-context-properties.scm
diff -u lilypond/scm/define-context-properties.scm:1.45 
lilypond/scm/define-context-properties.scm:1.46
--- lilypond/scm/define-context-properties.scm:1.45     Tue Jul 19 00:08:00 2005
+++ lilypond/scm/define-context-properties.scm  Thu Jul 21 12:14:35 2005
@@ -354,6 +354,7 @@
 
      (subdivideBeams ,boolean? "If set, multiple beams will be subdivided
 at beat positions by only drawing one beam over the beat.")
+     (suggestAccidentals ,boolean? "If set, accidentals are typeset as 
cautionary suggestions over the note.")
 
      (systemStartDelimiter ,symbol? "Which grob to make for the start of
 the system/staff? Set to @code{SystemStartBrace},
Index: lilypond/scm/define-grob-interfaces.scm
diff -u lilypond/scm/define-grob-interfaces.scm:1.21 
lilypond/scm/define-grob-interfaces.scm:1.22
--- lilypond/scm/define-grob-interfaces.scm:1.21        Fri Jul  8 18:08:24 2005
+++ lilypond/scm/define-grob-interfaces.scm     Thu Jul 21 12:14:35 2005
@@ -17,6 +17,12 @@
     )
 
 (ly:add-interface
+ 'accidental-suggestion-interface
+   "An accidental, printed as a suggestion (typically: vertically over a note)"
+   '()
+    )
+
+(ly:add-interface
  'dynamic-interface
    "Any kind of loudness sign"
    '()
Index: lilypond/scm/define-grobs.scm
diff -u lilypond/scm/define-grobs.scm:1.214 lilypond/scm/define-grobs.scm:1.215
--- lilypond/scm/define-grobs.scm:1.214 Tue Jul 19 15:42:40 2005
+++ lilypond/scm/define-grobs.scm       Thu Jul 21 12:14:35 2005
@@ -24,10 +24,26 @@
        (cautionary-style . parentheses)
        (after-line-breaking-callback . 
,Accidental_interface::after_line_breaking)
        (meta . ((class . Item)
-                (interfaces . (accidental-interface
-                                              font-interface))))
+                (interfaces . (accidental-interface font-interface))))
+       ))
+    
+    (AccidentalSuggestion
+     . ((print-function . ,Accidental_interface::print)
+       (X-offset-callbacks . (,Self_alignment_interface::centered_on_parent
+                              ,Self_alignment_interface::aligned_on_self))
+       (self-alignment-X . ,CENTER)
+       (cautionary . #t)
+       (cautionary-style . smaller)
+       (Y-offset-callbacks . (,Side_position_interface::aligned_side))
+       (cautionary-style . parentheses)
+       (direction . ,UP)
+       (staff-padding . 0.25)
+       (script-priority . 0)
+       (meta . ((class . Item)
+                (interfaces . (side-position-interface script-interface
+                               accidental-suggestion-interface 
self-alignment-interface
+                               font-interface))))
        ))
-
     (AccidentalPlacement
      . ((X-extent-callback . ,Axis_group_interface::group_extent_callback)
        (left-padding . 0.2)
@@ -865,7 +881,8 @@
        (staff-padding . 0.2)
        (font-size . -4)
        (meta . ((class . Item)
-                (interfaces . (text-interface self-alignment-interface 
side-position-interface font-interface ))))
+                (interfaces . (text-interface self-alignment-interface
+                                              side-position-interface 
font-interface ))))
        ))
 
     (OttavaBracket


_______________________________________________
Lilypond-cvs mailing list
Lilypond-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-cvs

Reply via email to