]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3245: Make \relative { ... } interpret the first pitch as an absolute one
authorDavid Kastrup <dak@gnu.org>
Wed, 13 Mar 2013 19:50:56 +0000 (20:50 +0100)
committerDavid Kastrup <dak@gnu.org>
Sat, 6 Apr 2013 07:19:09 +0000 (09:19 +0200)
The previous default of \relative { ... } being \relative c' { ... }
made c' more special than warranted.  Having to write
\relative f { ... } for this functionality seems awkward since f
serves no musical function but just happens to be the middle of the
scale.  Iff the scale is the standard scale.  The new definition of
\relative takes care to determine the "middle of the scale" reference
point properly even in the case of non-standard scales.

ly/music-functions-init.ly

index 183bf4db21f79b5207be319967ef7d0f16e4ffd9..a25198f3e01dfaa06fd4cc76aee9e4d5a837d9e8 100644 (file)
@@ -1032,9 +1032,23 @@ usually contains spacers or multi-measure rests.")
 
 relative =
 #(define-music-function (parser location pitch music)
-   (ly:pitch? ly:music?)
-   (_i "Make @var{music} relative to @var{pitch}.")
-   (ly:make-music-relative! music pitch)
+   ((ly:pitch?) ly:music?)
+   (_i "Make @var{music} relative to @var{pitch}.  If @var{pitch} is
+omitted, the first note in @var{music} is given in absolute pitch.")
+   ;; When \relative has no clear decision (can only happen with
+   ;; scales with an even number of steps), it goes down (see
+   ;; pitch.cc).  The following formula puts out f for both the normal
+   ;; 7-step scale as well as for a "shortened" scale missing the
+   ;; final b.  In either case, a first note of c will end up as c,
+   ;; namely pitch (-1, 0, 0).
+   (ly:make-music-relative! music
+                            (or pitch
+                                (ly:make-pitch
+                                 -1
+                                 (quotient
+                                  ;; size of current scale:
+                                  (ly:pitch-steps (ly:make-pitch 1 0))
+                                  2))))
    (make-music 'RelativeOctaveMusic
               'element music))