]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/music-functions.scm
Merge branch 'master' into lilypond/translation
[lilypond.git] / scm / music-functions.scm
index 25b223bbe9826016cf692c5e3c4f14624aa72176..8cdd53955f61790bd5e4b3378c7bcc6c74ac9f9b 100644 (file)
@@ -278,7 +278,7 @@ through MUSIC."
        ;; This works for single-note and multi-note tremolos!
        (let* ((children (if (music-is-of-type? main 'sequential-music)
                             ;; \repeat tremolo n { ... }
-                            (length (ly:music-property main 'elements))
+                            (length (extract-named-music main 'EventChord))
                             ;; \repeat tremolo n c4
                             1))
               ;; # of dots is equal to the 1 in bitwise representation (minus 1)!
@@ -304,7 +304,7 @@ through MUSIC."
 (define (calc-repeat-slash-count music)
   "Given the child-list @var{music} in @code{PercentRepeatMusic},
 calculate the number of slashes based on the durations.  Returns @code{0}
-if durations in in @var{music} vary, allowing slash beats and double-percent
+if durations in @var{music} vary, allowing slash beats and double-percent
 beats to be distinguished."
   (let* ((durs (map (lambda (elt)
                      (duration-of-note elt))
@@ -411,7 +411,8 @@ in @var{grob}."
     Slur
     Stem
     TextScript
-    Tie))
+    Tie
+    TupletBracket))
 
 (define-safe-public (make-voice-props-set n)
   (make-sequential-music
@@ -649,21 +650,6 @@ NUMBER is 0-base, i.e., Voice=1 (upstems) has number 0.
        (set! (ly:grob-property grob symbol) val))))
 
 
-;;
-(define-public (smart-bar-check n)
-  "Make a bar check that checks for a specific bar number."
-  (let ((m (make-music 'ApplyContext)))
-    (define (checker tr)
-      (let* ((bn (ly:context-property tr 'currentBarNumber)))
-       (or (= bn n)
-           (ly:error
-            ;; FIXME: uncomprehensable message
-            (_ "Bar check failed.  Expect to be at ~a, instead at ~a")
-            n bn))))
-    (set! (ly:music-property m 'procedure) checker)
-    m))
-
-
 (define-public (skip->rest mus)
   "Replace @var{mus} by @code{RestEvent} of the same duration if it is a
 @code{SkipEvent}.  Useful for extracting parts from crowded scores."
@@ -691,12 +677,17 @@ NUMBER is 0-base, i.e., Voice=1 (upstems) has number 0.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; warn for bare chords at start.
 
-
 (define-public (ly:music-message music msg)
   (let ((ip (ly:music-property music 'origin)))
     (if (ly:input-location? ip)
-       (ly:input-message ip msg)
-       (ly:warning msg))))
+        (ly:input-message ip msg)
+        (ly:message msg))))
+
+(define-public (ly:music-warning music msg)
+  (let ((ip (ly:music-property music 'origin)))
+    (if (ly:input-location? ip)
+        (ly:input-warning ip msg)
+        (ly:warning msg))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
@@ -841,7 +832,7 @@ Syntax:
              (set! (ly:music-property music 'quoted-events) quoted-vector)
              (set! (ly:music-property music 'iterator-ctor)
                    ly:quote-iterator::constructor))
-           (ly:warning (_ "cannot find quoted music: `~S'") quoted-name)))
+           (ly:music-warning music (ly:format (_ "cannot find quoted music: `~S'") quoted-name))))
     music))
 
 
@@ -1004,14 +995,14 @@ then revert skipTypesetting."
       (equal? laziness #t)
       (<= bar-number (+ (cadr alteration-def) laziness))))
 
-(define (accidental-voided? alteration-def)
-  "Checks an alteration entry for being voided.
+(define (accidental-invalid? alteration-def)
+  "Checks an alteration entry for being invalid.
 
-Non-key alterations are voided when tying into the next bar or when
-there is a clef change, since neither repetition nor cancellation can
-be omitted when the same note occurs again.
+Non-key alterations are invalidated when tying into the next bar or
+when there is a clef change, since neither repetition nor cancellation
+can be omitted when the same note occurs again.
 
-Returns @code{#f} or the reason for the voiding, a symbol."
+Returns @code{#f} or the reason for the invalidation, a symbol."
   (let* ((def (if (pair? alteration-def)
                  (car alteration-def)
                  alteration-def)))
@@ -1083,7 +1074,7 @@ specifies whether accidentals should be canceled in different octaves."
      (from-key-sig
       (set! previous-alteration from-key-sig)))
 
-    (if (accidental-voided? previous-alteration)
+    (if (accidental-invalid? previous-alteration)
        (set! need-accidental #t)
 
        (let* ((prev-alt (extract-alteration previous-alteration))
@@ -1093,8 +1084,8 @@ specifies whether accidentals should be canceled in different octaves."
              (begin
                (set! need-accidental #t)
                (if (and (not (= this-alt 0))
-                        (or (< (abs this-alt) (abs prev-alt))
-                            (< (* prev-alt this-alt) 0)))
+                        (and (< (abs this-alt) (abs prev-alt))
+                            (> (* prev-alt this-alt) 0)))
                    (set! need-restore #t))))))
 
     (cons need-restore need-accidental)))
@@ -1113,7 +1104,7 @@ active pitch in any octave.
 @var{laziness} states over how many bars an accidental should be remembered.
 @code{0}@tie{}is the default -- accidental lasts over 0@tie{}bar lines, that
 is, to the end of current measure.  A positive integer means that the
-accidental lasts over that many bar lines.  @code{-1} is `forget
+accidental lasts over that many bar lines.  @w{@code{-1}} is `forget
 immediately', that is, only look at key signature.  @code{#t} is `forever'."
 
   (check-pitch-against-signature context pitch barnum laziness octaveness))
@@ -1393,7 +1384,7 @@ Entries that conform with the current key signature are not invalidated."
           (lambda (entry)
             (let* ((localalt (key-entry-alteration entry))
                    (localoct (key-entry-octave entry)))
-              (if (or (accidental-voided? localalt)
+              (if (or (accidental-invalid? localalt)
                       (not localoct)
                       (= localalt
                          (key-entry-alteration