]> git.donarmstrong.com Git - lilypond.git/commitdiff
Warn when \time is used in mid-measure, and reset measurePosition.
authorDevon Schudy <dschudy@gmail.com>
Wed, 26 Mar 2014 19:04:08 +0000 (15:04 -0400)
committerDavid Kastrup <dak@gnu.org>
Sat, 5 Apr 2014 09:58:22 +0000 (11:58 +0200)
This makes issues 3696 and 3888 less mysterious.

input/regression/time-signature-midmeasure.ly [new file with mode: 0644]
scm/define-music-callbacks.scm

diff --git a/input/regression/time-signature-midmeasure.ly b/input/regression/time-signature-midmeasure.ly
new file mode 100644 (file)
index 0000000..10b5891
--- /dev/null
@@ -0,0 +1,28 @@
+\version "2.19.4"
+
+\header {
+  texidoc = "Time signature changes in midmeasure generate warnings,
+except in an anacrusis or when @code{ignoreBarChecks} is true.
+@code{measurePosition} is reset to 0, so a full measure follows, regardless
+of the original position.
+
+This example should end at bar 3, with no barline before the 2/4."
+}
+
+#(ly:expect-warning (_ "\\time in mid-measure at 1/4"))
+
+\score {
+  \relative {
+    \override Score.BarNumber.break-visibility = #all-visible
+    \partial 8 \time 2/4
+    a'8 | d4
+    \time 6/8 \partial 4.
+    cis8 b a | g4. \barNumberCheck 2
+    \set Timing.ignoreBarChecks = ##t
+    \time 12/8
+    fis4. e d
+    \time 2/4
+    \set Timing.ignoreBarChecks = ##f
+    a'2 | \barNumberCheck 3
+  }
+}
index 60d7d35124687f7cd60980ce2c42490f5560f52c..e9fe53eb1b0a253e85d1af3b1d05d20ce767fae0 100644 (file)
@@ -102,7 +102,19 @@ to be used by the sequential-iterator"
                            structure))
                       (beaming-exception
                        (beam-exceptions fraction time-signature-settings))
-                      (new-measure-length (ly:make-moment num den)))
+                      (new-measure-length (ly:make-moment num den))
+                      (pos (ly:context-property context 'measurePosition)))
+                 ;;\time is OK at a negative measurePosition (after \partial),
+                 ;;but at a positive position it's probably a mistake, so warn
+                 ;;(like a barcheck) and reset it to 0 to prevent errors.
+                 (if (> (ly:moment-main pos) 0)
+                     (begin
+                       (if (not (ly:context-property context 'ignoreBarChecks #f))
+                           (ly:music-warning music
+                                             (_ "\\time in mid-measure at ~A")
+                                             (ly:moment-main pos)))
+                       (ly:context-set-property!
+                        context 'measurePosition (ly:make-moment 0))))
                  (ly:context-set-property!
                   context 'timeSignatureFraction fraction)
                  (ly:context-set-property!