X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fmusic-functions.scm;h=24661730f0b116e040f2b68ebb5bcf39825ec20b;hb=7612daa5e327fe019d441b9d458f88407dca3936;hp=ec264b700a1f0a8a0af51ea807eee685a3231a46;hpb=26a04c1f923f384d3a36c571bb3ebcdb1aabda9b;p=lilypond.git diff --git a/scm/music-functions.scm b/scm/music-functions.scm index ec264b700a..24661730f0 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -180,8 +180,7 @@ equivalent to @var{obj}, that is, for a music expression, a (ly:duration? obj) `(ly:make-duration ,(ly:duration-log obj) ,(ly:duration-dot-count obj) - ,(car (ly:duration-factor obj)) - ,(cdr (ly:duration-factor obj)))) + ,(ly:duration-scale obj))) (;; note pitch (ly:pitch? obj) `(ly:make-pitch ,(ly:pitch-octave obj) @@ -237,12 +236,11 @@ which often can be read back in order to generate an equivalent expression." The number of dots in the shifted music may not be less than zero." (let ((d (ly:music-property music 'duration))) (if (ly:duration? d) - (let* ((cp (ly:duration-factor d)) + (let* ((cp (ly:duration-scale d)) (nd (ly:make-duration (+ shift (ly:duration-log d)) (max 0 (+ dot (ly:duration-dot-count d))) - (car cp) - (cdr cp)))) + cp))) (set! (ly:music-property music 'duration) nd))) music)) @@ -867,7 +865,7 @@ NUMBER is 0-base, i.e., Voice=1 (upstems) has number 0. (defmacro-public define-syntax-function (type args signature . body) "Helper macro for `ly:make-music-function'. Syntax: - (define-syntax-function (result-type? parser location arg1 arg2 ...) (result-type? arg1-type arg2-type ...) + (define-syntax-function result-type? (parser location arg1 arg2 ...) (arg1-type arg2-type ...) ...function body...) argX-type can take one of the forms @code{predicate?} for mandatory @@ -1323,33 +1321,43 @@ immediately', that is, only look at key signature. @code{#t} is `forever'." (check-pitch-against-signature context pitch barnum laziness octaveness)) (define (key-entry-notename entry) - "Return the pitch of an entry in localKeySignature. The entry is either of the form - '(notename . alter) or '((octave . notename) . (alter barnum . measurepos))." - (if (number? (car entry)) - (car entry) - (cdar entry))) + "Return the pitch of an @var{entry} in @code{localKeySignature}. +The @samp{car} of the entry is either of the form @code{notename} or +of the form @code{(octave . notename)}. The latter form is used for special +key signatures or to indicate an explicit accidental. + +The @samp{cdr} of the entry is either a rational @code{alter} indicating +a key signature alteration, or of the form +@code{(alter . (barnum . measurepos))} indicating an alteration caused by +an accidental in music." + (if (pair? (car entry)) + (cdar entry) + (car entry))) (define (key-entry-octave entry) - "Return the octave of an entry in localKeySignature (or #f if the entry does not have - an octave)." + "Return the octave of an entry in @code{localKeySignature} +or @code{#f} if the entry does not have an octave. +See @code{key-entry-notename} for details." (and (pair? (car entry)) (caar entry))) (define (key-entry-bar-number entry) - "Return the bar number of an entry in localKeySignature (or #f if the entry does not - have a bar number)." - (and (pair? (car entry)) (caddr entry))) + "Return the bar number of an entry in @code{localKeySignature} +or @code {#f} if the entry does not have a bar number. +See @code{key-entry-notename} for details." + (and (pair? (cdr entry)) (caddr entry))) (define (key-entry-measure-position entry) - "Return the measure position of an entry in localKeySignature (or #f if the entry does - not have a measure position)." - (and (pair? (car entry)) (cdddr entry))) + "Return the measure position of an entry in @code{localKeySignature} +or @code {#f} if the entry does not have a measure position. +See @code{key-entry-notename} for details." + (and (pair? (cdr entry)) (cdddr entry))) (define (key-entry-alteration entry) "Return the alteration of an entry in localKeySignature. For convenience, returns @code{0} if entry is @code{#f}." (if entry - (if (number? (car entry)) + (if (number? (cdr entry)) (cdr entry) (cadr entry)) 0)) @@ -1594,15 +1602,14 @@ Entries that conform with the current key signature are not invalidated." (set! (ly:context-property context 'localKeySignature) (map-in-order (lambda (entry) - (let* ((localalt (key-entry-alteration entry)) - (localoct (key-entry-octave entry))) + (let* ((localalt (key-entry-alteration entry))) (if (or (accidental-invalid? localalt) - (not localoct) + (not (key-entry-bar-number entry)) (= localalt (key-entry-alteration (find-pitch-entry keysig - (ly:make-pitch localoct + (ly:make-pitch (key-entry-octave entry) (key-entry-notename entry) 0) #t #t)))) @@ -1856,3 +1863,23 @@ other stems just because of that." ((process-acknowledged trans) (make-stem-spans! ctx stems trans) (set! stems '()))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; The following is used by the alterBroken function. + +(define-public ((value-for-spanner-piece arg) grob) + "Associate a piece of broken spanner @var{grob} with an element +of list @var{arg}." + (let* ((orig (ly:grob-original grob)) + (siblings (ly:spanner-broken-into orig))) + + (define (helper sibs arg) + (if (null? arg) + arg + (if (eq? (car sibs) grob) + (car arg) + (helper (cdr sibs) (cdr arg))))) + + (if (>= (length siblings) 2) + (helper siblings arg) + (car arg))))