]> git.donarmstrong.com Git - lilypond.git/commitdiff
*** empty log message ***
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 21 Jul 2005 12:14:35 +0000 (12:14 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 21 Jul 2005 12:14:35 +0000 (12:14 +0000)
ChangeLog
Documentation/topdocs/NEWS.tely
Documentation/user/instrument-notation.itely
THANKS
input/regression/accidental-suggestions.ly [new file with mode: 0644]
lily/accidental-engraver.cc
lily/engraver.cc
lily/include/engraver.hh
scm/define-context-properties.scm
scm/define-grob-interfaces.scm
scm/define-grobs.scm

index ae9e071d09057911ea760ce3df1872f72b2ccbb0..44198d866bf3cc9e339d36b9712f680ef5699b69 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,17 @@
 
 2005-07-21  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * 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 37dce23a07b7fffb6efb3ca7d5df084305fc8c1f..213ae0ff3b0b7cd42fc1266eec72ca386a07bf6e 100644 (file)
@@ -32,6 +32,18 @@ See user manual, \NAME\
 
 
 @itemize @bullet
+
+@item
+Suggested accidentals (for notating musica ficta) may be switched on
+with @code{suggestAccidentals}
+
+@lilypond[verbatim,fragment,relative=2]
+\set suggestAccidentals = ##t
+ais bis
+@end 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 c20b3bf9d1cd5da0efc2938aaf42e1ff13ac7bd6..5c65a24b00978fb4c5aa7a145f212bc030e8ea67 100644 (file)
@@ -1940,10 +1940,12 @@ Here are all suptopics at a glance:
 * 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 @@ entering the chant, as the following excerpt demonstrates
 }
 @end lilypond
 
+@node Musica ficta accidentals
+@subsection 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.
+
+@cindex Musica ficta
+
+Support for such suggested accidentals is included, and can be
+switched on by setting @code{suggestAccidentals} to true.
+
+@cindex @code{suggestAccidentals}
+
+@lilypond[verbatim,fragment,relative=1]
+fis gis
+\set suggestAccidentals = ##t
+ais bis
+@end lilypond 
+
+@seealso
+
+Program reference: @internalsref{Accidental_engraver} engraver and the
+@internalsref{AccidentalSuggestion} object.
 
 @node Figured bass
 @subsection Figured bass
diff --git a/THANKS b/THANKS
index bed0d62e207454cdafc008c0813e2b0f50ad002d..0b3427c618571de7e4217498cc8619321e7e1c31 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -21,6 +21,7 @@ SPONSORS
 
 Jamie Bullock
 D. Josiah Boothby
+Nancho Alvarez
 Sven Axelsson
 
 
diff --git a/input/regression/accidental-suggestions.ly b/input/regression/accidental-suggestions.ly
new file mode 100644 (file)
index 0000000..d160ed0
--- /dev/null
@@ -0,0 +1,26 @@
+
+\header {
+
+ texidoc = "setting the @code{suggestAccidentals} will print
+accidentals vertically relative to the note.  This is useful for
+denoting Musica Ficta."
+}
+
+\version "2.7.2"
+\paper {
+  raggedright = ##t
+}
+
+\relative c'' {
+  \time 2/4 
+  \set suggestAccidentals = ##t 
+  cis^> gis'-|
+  \override AccidentalSuggestion #'cautionary-style = #'parentheses
+  cis,_"paren" gis'
+  \override AccidentalSuggestion #'cautionary-style = #'()
+  cis,_"no caut style"  gis'
+
+}
+  
+  
index 6898520441fa1bfcb8031f49418658212f2351ab..2b6c3741d389ed14f61429ed24a7eb296ce0fadc 100644 (file)
@@ -28,7 +28,7 @@ public:
   Music *melodic_;
   Grob *accidental_;
   Context *origin_;
-  Engraver *origin_trans_;
+  Engraver *origin_engraver_;
   Grob *head_;
   bool tied_;
 
@@ -47,10 +47,12 @@ Accidental_entry::Accidental_entry ()
 
 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 @@ protected:
   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 @@ public:
 
   Array<Accidental_entry> accidentals_;
   Link_array<Spanner> ties_;
+
+
 };
 
 /*
@@ -311,13 +317,12 @@ Accidental_engraver::process_acknowledged ()
       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,50 +356,108 @@ Accidental_engraver::process_acknowledged ()
             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);
+             create_accidental (&accidentals_[i], num > 1, cautionary);
+           }
+       }
+    }
+}
 
-             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);
+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);
 
-             /* TODO: add cautionary option in accidental. */
 
-             if (cautionary)
-               a->set_property ("cautionary", SCM_BOOL_T);
+  a->set_property ("accidentals", accs);
+  entry->accidental_ = a;
+}
 
-             support->set_object ("accidental-grob", a->self_scm ());
+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;
+}
 
-             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]);
-           }
-       }
+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 ()
 {
@@ -489,14 +552,17 @@ Accidental_engraver::acknowledge_grob (Grob_info info)
       && 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 @@ ADD_TRANSLATOR (Accidental_engraver,
                "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 b1a11fcd3a1cab2d9675588b78a33d201a8cf35c..a93b202cbca0c0ff2ea07ee18f6d969e608499de 100644 (file)
@@ -59,7 +59,11 @@ Engraver::get_score_engraver () const
 #include "translator.icc"
 
 ADD_TRANSLATOR (Engraver,
-               "", "",
+               "Base class for engravers. Does nothing, so it is not used.",
                "",
-               "", "", "");
+               "",
+               "",
+               "",
+               "");
+
 
index 54e4f287769303f64332105f98034495bbaf9133..56a2fe44eb27b04935b5e1b67c1b394436526dff 100644 (file)
@@ -48,6 +48,7 @@ public:
 #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 6cf862af69c60cd383aa1ea8955d8cfb680051fc..d01608205f5f8f594c9e4ef6b56ff5128342e857 100644 (file)
@@ -354,6 +354,7 @@ one).")
 
      (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 ffad4afbc1fa115be045bddddd6a8a5b909e21f2..65e4bb859e022e682ab87f84521bd059c44837f5 100644 (file)
    '(accidental-grob)
     )
 
+(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 b8024dddcbe3020fd551272701000d3473492b28..33e83c8d764720f755f153457c1b57d8ca879771 100644 (file)
        (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)
        (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