]> git.donarmstrong.com Git - lilypond.git/blobdiff - ly/music-functions-init.ly
Issue 4411: Omit unnecessary second argument to ly:make-unpure-pure-container, docume...
[lilypond.git] / ly / music-functions-init.ly
index e173083989b37ade4fb367dee3dbc2589411158e..74b054dc8c9d183b6453b5a10266f6459c247693 100644 (file)
@@ -36,7 +36,7 @@ absolute =
    (ly:music?)
    (_i "Make @var{music} absolute.  This does not actually change the
 music itself but rather hides it from surrounding @code{\\relative}
-commands.")
+and @code{\\fixed} commands.")
    (make-music 'RelativeOctaveMusic 'element music))
 
 acciaccatura =
@@ -287,6 +287,17 @@ as @code{\\compoundMeter #'((3 2 8))} or shorter
     \set Timing.measureLength = #mlen
   #} ))
 
+compressMMRests =
+#(define-music-function (parser location music) (ly:music?)
+  (_i "Remove the empty bars created by multi-measure rests,
+leaving just the first bar containing the MM rest itself.")
+   (music-map
+    (lambda (m)
+      (if (eq? 'MultiMeasureRestMusic (ly:music-property m 'name))
+          #{ \once \set Score.skipBars = ##t #m #}
+          #{ #m #} ))
+    music))
+
 crossStaff =
 #(define-music-function (parser location notes) (ly:music?)
   (_i "Create cross-staff stems")
@@ -418,6 +429,20 @@ finger =
             (if (number? finger) 'digit 'text)
             finger))
 
+fixed =
+#(define-music-function (parser location pitch music)
+   (ly:pitch? ly:music?)
+   (_i "Use the octave of @var{pitch} as the default octave for @var{music}.")
+   (let ((octave-marks (1+ (ly:pitch-octave pitch))))
+     (cond ((not (= 0 octave-marks))
+            (ly:music-transpose music (ly:make-pitch octave-marks 0 0))
+            ;;In order to leave unchanged the notes in any enclosed
+            ;; \absolute or \fixed or \relative, make a cancelling shift
+            (map (lambda (m)
+                   (ly:music-transpose m (ly:make-pitch (- octave-marks) 0 0)))
+                 (extract-named-music music 'RelativeOctaveMusic)))))
+   (make-music 'RelativeOctaveMusic 'element music))
+
 footnote =
 #(define-music-function (parser location mark offset footnote item)
    ((markup?) number-pair? markup? symbol-list-or-music?)
@@ -486,9 +511,7 @@ given through @var{ratio}.")
   #{
     \set harmonicDots = ##t
     \temporary \override TabNoteHead.stencil = #(tab-note-head::print-custom-fret-label (ratio->fret ratio))
-    \temporary \override NoteHead.Y-extent = #(ly:make-unpure-pure-container ly:grob::stencil-height
-                                       (lambda (grob start end)
-                                               (ly:grob::stencil-height grob)))
+    \temporary \override NoteHead.Y-extent = #(ly:make-unpure-pure-container ly:grob::stencil-height)
     \temporary \override NoteHead.stencil = #(lambda (grob) (ly:grob-set-property! grob 'style 'harmonic-mixed)
                                             (ly:note-head::print grob))
     #(make-harmonic
@@ -1123,6 +1146,24 @@ parenthesize =
        (set! (ly:music-property arg 'parenthesize) #t))
    arg)
 
+#(define (make-directed-part-combine-music
+          parser direction chord-range part1 part2
+          one-context-settings
+          two-context-settings
+          shared-context-settings)
+
+   (let ((pc-music (make-part-combine-music
+                     parser (list part1 part2) direction chord-range)))
+     #{ \context Staff <<
+          \context Voice = "one" \with #one-context-settings {}
+          \context Voice = "two" \with #two-context-settings {}
+          \context Voice = "shared" \with #shared-context-settings {}
+          #pc-music
+          #(make-part-combine-marks
+            default-part-combine-mark-state-machine
+            (ly:music-property pc-music 'split-list))
+        >> #} ))
+
 partcombine =
 #(define-music-function (parser location chord-range part1 part2)
    ((number-pair? '(0 . 8)) ly:music? ly:music?)
@@ -1131,27 +1172,33 @@ a music expression containing simultaneous voices, where @var{part1}
 and @var{part2} are combined into one voice where appropriate.
 Optional @var{chord-range} sets the distance in steps between notes
 that may be combined into a chord or unison.")
-   (make-part-combine-music parser
-                            (list part1 part2) #f chord-range))
+   (make-directed-part-combine-music parser #f chord-range part1 part2
+    #{ \with { \voiceOne \override DynamicLineSpanner.direction = #UP } #}
+    #{ \with { \voiceTwo \override DynamicLineSpanner.direction = #DOWN } #}
+    #{ #} ))
 
 partcombineUp =
 #(define-music-function (parser location chord-range part1 part2)
    ((number-pair? '(0 . 8)) ly:music? ly:music?)
    (_i "Take the music in @var{part1} and @var{part2} and typeset so
 that they share a staff with stems directed upward.")
-   (make-part-combine-music parser
-                            (list part1 part2) UP chord-range))
+   (make-directed-part-combine-music parser UP chord-range part1 part2
+    #{ \with { \voiceOne \override DynamicLineSpanner.direction = #UP } #}
+    #{ \with { \voiceThree \override DynamicLineSpanner.direction = #UP } #}
+    #{ \with { \voiceOne \override DynamicLineSpanner.direction = #UP } #} ))
 
 partcombineDown =
 #(define-music-function (parser location chord-range part1 part2)
    ((number-pair? '(0 . 8)) ly:music? ly:music?)
    (_i "Take the music in @var{part1} and @var{part2} and typeset so
 that they share a staff with stems directed downward.")
-   (make-part-combine-music parser
-                            (list part1 part2) DOWN chord-range))
+   (make-directed-part-combine-music parser DOWN chord-range part1 part2
+    #{ \with { \voiceFour \override DynamicLineSpanner.direction = #DOWN } #}
+    #{ \with { \voiceTwo \override DynamicLineSpanner.direction = #DOWN } #}
+    #{ \with { \voiceTwo \override DynamicLineSpanner.direction = #DOWN } #} ))
 
 partcombineForce =
-#(define-music-function (location parser type once) (symbol-or-boolean? boolean?)
+#(define-music-function (location parser type once) (boolean-or-symbol? boolean?)
    (_i "Override the part-combiner.")
    (make-music 'EventChord
                'elements (list (make-music 'PartCombineForceEvent