]> git.donarmstrong.com Git - lilypond.git/blobdiff - ly/music-functions-init.ly
Doc: Add @funindex for \newSpacingSection (3185)
[lilypond.git] / ly / music-functions-init.ly
index ad9f7bdda27dfa7f9e7d5df1b5ca50742eaa6289..a25198f3e01dfaa06fd4cc76aee9e4d5a837d9e8 100644 (file)
 
 %% TODO: using define-music-function in a .scm causes crash.
 
+absolute =
+#(define-music-function (parser location music)
+   (ly:music?)
+   (_i "Make @var{music} absolute.  This does not actually change the
+music itself but rather hides it from surrounding @code{\\relative}
+commands.")
+   (make-music 'RelativeOctaveMusic 'element music))
+
 acciaccatura =
 #(def-grace-function startAcciaccaturaMusic stopAcciaccaturaMusic
    (_i "Create an acciaccatura from the following music expression"))
@@ -1024,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))