]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 467
authorJoe Neeman <joeneeman@gmail.com>
Wed, 23 Jan 2008 08:36:30 +0000 (09:36 +0100)
committerJoe Neeman <joeneeman@gmail.com>
Wed, 23 Jan 2008 08:36:30 +0000 (09:36 +0100)
Prevent clefs and octavation marks from disagreeing over middleCPosition
by introducing a separate variable (middleCClefPosition and middleCOffset)
for each purpose.

lily/clef-engraver.cc
lily/ottava-engraver.cc
lily/pitch-scheme.cc
ly/engraver-init.ly
scm/define-context-properties.scm
scm/music-functions.scm
scm/parser-clef.scm

index d9b2e27dea3d9cd544d7ccd831c757217028a9bb..74992be97612d9373bd81c89063e05bb26503525 100644 (file)
@@ -202,6 +202,5 @@ ADD_TRANSLATOR (Clef_engraver,
                "clefPosition "
                "explicitClefVisibility "
                "forceClef "
-               "middleCPosition "
                ,
                /* write */ "");
index c1afcfed3c7dee3588a244a62e469530e05da739..01bf1d85c6f4a38e1d9ef26e6925124b95ef6a6b 100644 (file)
@@ -60,9 +60,8 @@ Ottava_spanner_engraver::process_music ()
          span_ = make_spanner ("OttavaBracket", SCM_EOL);
          span_->set_property ("text", ott);
 
-         SCM c0 (get_property ("middleCPosition"));
-         SCM oc0 (get_property ("originalMiddleCPosition"));
-         if (scm_less_p (oc0, c0) == SCM_BOOL_T)
+         SCM offset (get_property ("middleCOffset"));
+         if (robust_scm2double (offset, 0) > 0)
            span_->set_property ("direction", scm_from_int (DOWN));
        }
     }
index 12ddddf10a1c9b71e729622fc0be5c64a5feda5d..2eb36a65255b7feea0c7683fc0f0c7ce3445b29c 100644 (file)
@@ -142,3 +142,21 @@ LY_DEFINE (ly_pitch_diff, "ly:pitch-diff",
 
   return pitch_interval (*r, *p).smobbed_copy ();
 }
+
+/* FIXME: probably isn't the right place for this function */
+#include "context.hh"
+LY_DEFINE (ly_set_middle_C_x, "ly:set-middle-C!",
+          1, 0, 0, (SCM context),
+          "Set the @code{middleCPosition} variable in @var{context}"
+          " based on the variables @code{middleCClefPosition} and"
+          " middleCOffset.")
+{
+  LY_ASSERT_SMOB (Context, context, 1);
+
+  Context *c = unsmob_context (context);
+  int clef_pos = robust_scm2int (c->get_property ("middleCClefPosition"), 0);
+  int offset = robust_scm2int (c->get_property ("middleCOffset"), 0);
+
+  c->set_property (ly_symbol2scm ("middleCPosition"), scm_from_int (clef_pos + offset));
+  return SCM_UNDEFINED;
+}
index d8ffe8990f129ca7ab01e262a07f22b5aa7b2f67..2b7d5a8281b11e7fedd46017bd9303090ea3f0b9 100644 (file)
@@ -505,6 +505,7 @@ automatically when an output definition (a @code{\score} or
   tieWaitForNote = ##f
   clefGlyph = #"clefs.G"
   clefPosition = #-2
+  middleCClefPosition = #-6
   middleCPosition = #-6
   firstClef = ##t
   
@@ -571,7 +572,8 @@ automatically when an output definition (a @code{\score} or
 
   bassStaffProperties = #'((assign clefGlyph "clefs.F")
   (assign clefPosition 2)
-  (assign middleCPosition 6))
+  (assign middleCPosition 6)
+  (assign middleCClefPosition 6))
 %% tablature:
   stringOneTopmost = ##t
   highStringOne = ##t
@@ -782,6 +784,7 @@ of Editio Vaticana."
   %% Choose vaticana do clef on 3rd line as default.
   clefGlyph = #"clefs.vaticana.do"
   middleCPosition = #1
+  middleCClefPosition = #1
   clefPosition = #1
   clefOctavation = #0
 
@@ -882,6 +885,7 @@ accommodated for typesetting a piece in mensural style."
 
   %% Choose petrucci g clef on 2nd line as default.
   clefGlyph = #"clefs.petrucci.g"
+  middleCClefPosition = #-6
   middleCPosition = #-6
   clefPosition = #-2
   clefOctavation = #0
index 528bce09017e0cd974665c570ea3114ad9ebc061..a80deb681c6ea1244ebaa4a5c39eec4a508e0230 100644 (file)
@@ -306,9 +306,15 @@ markup.  Called with two arguments, event and context.")
 @code{midiMinimumVolume}.")
      (midiMinimumVolume ,number? "Set the minimum loudness for MIDI.
 Ranges from 0 to@tie{}1.")
+     (middleCClefPosition ,number? "The position of the middle C,
+as determined only by the clef.  This can be calculated by looking at
+@code{clefPosition} and @code{clefGlyph}.")
+     (middleCOffset ,number? "The offset of
+middle C from the position given by @code{middleCClefPosition} This
+is used for ottava brackets.")
      (middleCPosition ,number? "The place of the middle C, measured in
 half staff-spaces.  Usually determined by looking at
-@code{clefPosition} and @code{clefGlyph}.")
+@code{middleCClefPosition} and @code{middleCOffset}.")
      (minimumFret ,number? "The tablature auto string-selecting
 mechanism selects the highest string with a fret at least
 @code{minimumFret}.")
index 5585eebdb734c9ff59690f5edde7491d8d2b3e26..1e7c524241141b0c4ab6e8dff817a59b077b0544 100644 (file)
@@ -439,27 +439,20 @@ i.e.  this is not an override"
       "Either reset middleCPosition to the stored original, or remember
 old middleCPosition, add OCTAVATION to middleCPosition, and set
 OTTAVATION to `8va', or whatever appropriate."     
-      (if (number? (ly:context-property         context 'middleCPosition))
-         (begin
-           (if (number? (ly:context-property context 'originalMiddleCPosition))
-               (let ((where (ly:context-property-where-defined context 'middleCPosition)))
-                 
-                 (ly:context-set-property! context 'middleCPosition
-                                           (ly:context-property context 'originalMiddleCPosition))
-                 (ly:context-unset-property where 'originalMiddleCPosition)
-                 (ly:context-unset-property where 'ottavation)))
-ot         
-           (let* ((where (ly:context-property-where-defined context 'middleCPosition))
-                  (c0 (ly:context-property context 'middleCPosition))
-                  (new-c0 (+ c0 (* -7 octavation)))
-                  (string (cdr (assoc octavation '((2 . "15ma")
-                                                   (1 . "8va")
-                                                   (0 . #f)
-                                                   (-1 . "8vb")
-                                                   (-2 . "15mb"))))))
-             (ly:context-set-property! context 'middleCPosition new-c0)
-             (ly:context-set-property! context 'originalMiddleCPosition c0)
-             (ly:context-set-property! context 'ottavation string)))))
+      (if (number? (ly:context-property         context 'middleCOffset))
+         (let ((where (ly:context-property-where-defined context 'middleCOffset)))
+           (ly:context-unset-property where 'middleCOffset)
+           (ly:context-unset-property where 'ottavation)))
+
+      (let* ((offset (* -7 octavation))
+            (string (cdr (assoc octavation '((2 . "15ma")
+                                             (1 . "8va")
+                                             (0 . #f)
+                                             (-1 . "8vb")
+                                             (-2 . "15mb"))))))
+       (ly:context-set-property! context 'middleCOffset offset)
+       (ly:context-set-property! context 'ottavation string)
+       (ly:set-middle-C! context)))
     (set! (ly:music-property m 'procedure) ottava-modify)
     (context-spec-music m 'Staff)))
 
index 4724090ff92a0962a176d7671345072bf4f8e521..ede242b4aa9cb29056bb61198b960745563ee75b 100644 (file)
     (if (pair? e)
        (let* ((musics (map make-prop-set
                            `(((symbol . clefGlyph) (value . ,(cadr e)))
-                             ((symbol . middleCPosition)
+                             ((symbol . middleCClefPosition)
                               (value . ,(+ oct
                                            (caddr e)
                                            (cdr (assoc (cadr e) c0-pitch-alist)))))
                              ((symbol . clefPosition) (value . ,(caddr e)))
                              ((symbol . clefOctavation) (value . ,(- oct))))))
+              (recalc-mid-C (make-music 'ApplyContext))
               (seq (make-music 'SequentialMusic
-                               'elements musics))
+                               'elements (append musics (list recalc-mid-C))))
               (csp (make-music 'ContextSpeccedMusic)))
+         (set! (ly:music-property recalc-mid-C 'procedure) ly:set-middle-C!)
          (context-spec-music seq 'Staff))
        (begin
          (ly:warning (_ "unknown clef type `~a'") clef-name)