X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=ly%2Fmusic-functions-init.ly;h=9e5d3c223b8c32db59a70585bd2bdf7f8478c278;hb=ab336761427b7214e133ff06b3592afa75eda1cf;hp=dbecbf2f4413cbb8b191fd617b095dea11366876;hpb=f352e0b8dd0d9b0e0ec4c75416e3eb071db7295f;p=lilypond.git diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index dbecbf2f44..9e5d3c223b 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -2,7 +2,7 @@ %%%% This file is part of LilyPond, the GNU music typesetter. %%%% -%%%% Copyright (C) 2003--2012 Han-Wen Nienhuys +%%%% Copyright (C) 2003--2014 Han-Wen Nienhuys %%%% Jan Nieuwenhuizen %%%% %%%% LilyPond is free software: you can redistribute it and/or modify @@ -221,6 +221,14 @@ barNumberCheck = "Barcheck failed got ~a expect ~a" cbn n)))))) +beamExceptions = +#(define-scheme-function (parser location music) (ly:music?) + (_i "Extract a value suitable for setting +@code{Timing.beamExceptions} from the given pattern with explicit +beams in @var{music}. A bar check @code{|} has to be used between +bars of patterns in order to reset the timing.") + (extract-beam-exceptions music)) + bendAfter = #(define-event-function (parser location delta) (real?) (_i "Create a fall or doit of pitch interval @var{delta}.") @@ -245,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 (ly:make-moment (ly:moment-main len)) breath))))) clef = #(define-music-function (parser location type) (string?) @@ -270,7 +286,7 @@ as @code{\\compoundMeter #'((3 2 8))} or shorter (timesig (cons (ly:moment-main-numerator mlen) (ly:moment-main-denominator mlen)))) #{ - \once \override Staff.TimeSignature.stencil = #(lambda (grob) + \once \override Timing.TimeSignature.stencil = #(lambda (grob) (grob-interpret-markup grob (format-compound-time args))) \set Timing.timeSignatureFraction = #timesig \set Timing.baseMoment = #beat @@ -328,25 +344,30 @@ in a CueVoice oriented by @var{dir}.") displayLilyMusic = -#(define-music-function (parser location music) (ly:music?) +#(define-music-function (parser location port music) ((output-port?) ly:music?) (_i "Display the LilyPond input representation of @var{music} -to the console.") - (newline) - (display-lily-music music parser) +to @var{port}, defaulting to the console.") + (let ((port (or port (current-output-port)))) + (newline port) + (display-lily-music music parser port)) music) displayMusic = -#(define-music-function (parser location music) (ly:music?) - (_i "Display the internal representation of @var{music} to the console.") - (newline) - (display-scheme-music music) +#(define-music-function (parser location port music) ((output-port?) ly:music?) + (_i "Display the internal representation of @var{music} to +@var{port}, default to the console.") + (let ((port (or port (current-output-port)))) + (newline port) + (display-scheme-music music port)) music) displayScheme = -#(define-scheme-function (parser location expr) (scheme?) - (_i "Display the internal representation of @var{expr} to the console.") - (newline) - (display-scheme-music expr) +#(define-scheme-function (parser location port expr) ((output-port?) scheme?) + (_i "Display the internal representation of @var{expr} to +@var{port}, default to the console.") + (let ((port (or port (current-output-port)))) + (newline port) + (display-scheme-music expr port)) expr) @@ -611,6 +632,29 @@ languageRestore = (ly:input-warning location (_ "No other language was defined previously. Ignoring.")))) +magnifyMusic = +#(define-music-function (parser location mag mus) (number? ly:music?) + (_i "Magnify the notation of @var{mus} without changing the +staff-size, using @var{mag} as a size factor. Stems, beams, and +horizontal spacing are adjusted automatically.") + #{ + \set fontSize = #(magnification->font-size mag) + % gives beam-thickness=0.48 when mag=1 (like default), + % gives beam-thickness=0.35 when mag=0.63 (like CueVoice) + \temporary \override Beam.beam-thickness = #(+ 119/925 (* mag 13/37)) + \temporary \override Beam.length-fraction = #mag + \temporary \override Stem.length-fraction = #mag + \temporary \override Stem.thickness = #(* 1.3 (max 1 mag)) + \temporary \override Score.SpacingSpanner.spacing-increment = #(* 1.2 mag) + #mus + \set fontSize = 0 + \revert Beam.beam-thickness + \revert Beam.length-fraction + \revert Stem.length-fraction + \revert Stem.thickness + \revert Score.SpacingSpanner.spacing-increment + #}) + makeClusters = #(define-music-function (parser location arg) (ly:music?) (_i "Display chords in @var{arg} as clusters.") @@ -701,16 +745,38 @@ offset = a music expression, the result is the same music expression with an appropriate tweak applied.") (if (ly:music? item) - #{ \tweak #property #(offsetter property offsets) #item #} - (if (check-grob-path item parser location - #:default 'Bottom - #:min 2 - #:max 2) - #{ - \override #item . #property = - #(offsetter property offsets) - #} - (make-music 'Music)))) + ; In case of a tweak, grob property path is Grob.property + (let ((prop-path (check-grob-path + (if (symbol? property) + (list property) + property) + parser location + #:start 1 #:default #t #:min 2 #:max 2))) + (if prop-path + ; If the head of the grob property path is a symbol--i.e., + ; a grob name, produce a directed tweak. Otherwise, create + ; an ordinary tweak. + (if (symbol? (car prop-path)) + #{ + \tweak #prop-path #(offsetter (second prop-path) offsets) #item + #} + #{ + \tweak #(second prop-path) #(offsetter (second prop-path) offsets) #item + #}) + item)) + ; In case of an override, grob property path is Context.Grob.property. + (let ((prop-path (check-grob-path + (append item + (if (symbol? property) + (list property) + property)) + parser location + #:default 'Bottom #:min 3 #:max 3))) + (if prop-path + #{ + \override #prop-path = #(offsetter (third prop-path) offsets) + #} + (make-music 'Music))))) omit = #(define-music-function (parser location item) (symbol-list-or-music?) @@ -1238,9 +1304,7 @@ shiftDurations = (_i "Change the duration of @var{arg} by adding @var{dur} to the @code{durlog} of @var{arg} and @var{dots} to the @code{dots} of @var{arg}.") - (music-map - (lambda (x) - (shift-one-duration-log x dur dots)) arg)) + (shift-duration-log arg dur dots)) single = #(define-music-function (parser location overrides music)