]> git.donarmstrong.com Git - lilypond.git/blobdiff - ly/music-functions-init.ly
Merge branch 'translation'
[lilypond.git] / ly / music-functions-init.ly
index bb577e28b58c63bb651a09be26d0ac1bb0c6ab62..83c2535af58909766ac617bb0aa3733a935cc9c3 100644 (file)
@@ -253,7 +253,15 @@ bookOutputSuffix =
 breathe =
 #(define-music-function (parser location) ()
    (_i "Insert a breath mark.")
-   (make-music 'BreathingEvent))
+   (make-music 'BreathingEvent
+     'midi-length
+     (lambda (len context)
+       ;;Shorten by half, or by up to a second, but always by a power of 2
+       (let* ((desired (min (ly:moment-main (seconds->moment 1 context))
+                            (* (ly:moment-main len) 1/2)))
+              (scale (inexact->exact (ceiling (/ (log desired) (log 1/2)))))
+              (breath (ly:make-moment (expt 1/2 scale))))
+         (ly:moment-sub len breath)))))
 
 clef =
 #(define-music-function (parser location type) (string?)