]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/define-music-callbacks.scm
Issue 4099: Partcombine warning about simultaneous breathing
[lilypond.git] / scm / define-music-callbacks.scm
index 24281a883846ac64d0e7aa6293b2657ce3ff1499..667a7c631505aa85556721845a122b6dd2aa37a1 100644 (file)
@@ -116,3 +116,14 @@ to be used by the sequential-iterator"
             'Timing)
            'Score)
           (make-music 'TimeSignatureEvent music))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Some MIDI callbacks -- is this a good place for them?
+
+(define-public (breathe::midi-length 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 (ly:make-moment (ly:moment-main len)) breath)))