From: Valentin Villenave Date: Tue, 21 Oct 2008 08:04:21 +0000 (+0200) Subject: new showFirstLength feature X-Git-Tag: release/2.11.63-1~20^2~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=39a060ddcffd3d2d52a119970158f82beba35410;p=lilypond.git new showFirstLength feature This commit implements a showFirstLength property, that does the opposite of showLastLength (both properties may be set, in this case the beginning and the end of the piece are printed, with a double barline as a separator). When only showFirstLength is set, the 'length property is overriden (except if already shorter than the specified first length) and therefore the compilation will be much faster. This new feature may be very convenient, e.g. to print the index of a book containing only the beginning of each \score. --- diff --git a/Documentation/topdocs/NEWS.tely b/Documentation/topdocs/NEWS.tely index c60fc9b5f6..e6b2866b5d 100644 --- a/Documentation/topdocs/NEWS.tely +++ b/Documentation/topdocs/NEWS.tely @@ -62,6 +62,16 @@ which scares away people. @end ignore +@item +In addition to the already existing @code{showLastLength} property, +@code{showFirstLength} can now be set as well, rendering only the first +measures of a piece. Both properties may be set at the same time: +@lilypond[] +showFirstLength = R1*2 +showLastLength = R1*3 +\relative c' { c1 d e f g a b c } +@end lilypond + @item The file extension for MIDI can be set using the command-line program default @code{midi-extension}. For Windows, the default diff --git a/Documentation/user/input.itely b/Documentation/user/input.itely index 392fbb3ea0..867370d88d 100644 --- a/Documentation/user/input.itely +++ b/Documentation/user/input.itely @@ -1284,6 +1284,7 @@ For more information on output formats, see @rprogram{Invoking lilypond}. @funindex skipTypesetting +@funindex showFirstLength @funindex showLastLength When entering or copying music, usually only the music near the end (where @@ -1301,7 +1302,9 @@ showLastLength = R1*5 in your source file. This will render only the last 5 measures (assuming 4/4 time signature) of every @code{\score} in the input file. For longer pieces, rendering only a small part is often an order -of magnitude quicker than rendering it completely +of magnitude quicker than rendering it completely. When working on the +beginning of a score you have already typeset (e.g. to add a new part), +the @code{showFirstLength} property may be useful as well. Skipping parts of a score can be controlled in a more fine-grained fashion with the property @code{Score.skipTypesetting}. When it is diff --git a/Documentation/user/working.itely b/Documentation/user/working.itely index c6007c7ee7..c912e5999c 100644 --- a/Documentation/user/working.itely +++ b/Documentation/user/working.itely @@ -129,8 +129,8 @@ piece of existing sheet music), @item Enter one manuscript (the physical copy) system at a time (but still only one bar per line of text), and check each system when you finish it. You may use the -@code{showLastLength} command to speed up processing -- see -@ruser{Skipping corrected music}. +@code{showLastLength} or @code{showFirstLength} properties to speed up +processing -- see @ruser{Skipping corrected music}. @item Define @code{mBreak = @{ \break @}} and insert @code{\mBreak} in the input file whenever the manuscript has a line break. This diff --git a/input/regression/skiptypesetting-show-first-and-last.ly b/input/regression/skiptypesetting-show-first-and-last.ly new file mode 100644 index 0000000000..4dda5fa38c --- /dev/null +++ b/input/regression/skiptypesetting-show-first-and-last.ly @@ -0,0 +1,18 @@ +\header { + + texidoc = "@code{showFirstLength} and @code{showLastLength} may be set at the + same time; both the beginning and the end of the score will be printed." + + } + +\version "2.11.63" + +showFirstLength = R1*1 +showLastLength = R1*2 +\paper { + ragged-right = ##T +} + +{ + c1 d e f g a +} diff --git a/input/regression/skiptypesetting-show-first.ly b/input/regression/skiptypesetting-show-first.ly new file mode 100644 index 0000000000..b8d2f6b3bb --- /dev/null +++ b/input/regression/skiptypesetting-show-first.ly @@ -0,0 +1,16 @@ +\header { + + texidoc = "@code{showFirstLength} will only show the first bit of a score" + + } + +\version "2.11.63" + +showFirstLength = R1*3 +\paper { + ragged-right = ##T +} + +{ + c1 d e f g a +} diff --git a/input/regression/skiptypesetting-show-last.ly b/input/regression/skiptypesetting-show-last.ly index def23fc0b0..cd280cde08 100644 --- a/input/regression/skiptypesetting-show-last.ly +++ b/input/regression/skiptypesetting-show-last.ly @@ -12,7 +12,5 @@ showLastLength = R1*3 } { - c1 c1 - c1 c1 - c1 c1 + c1 d e f g a } diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 490cafe92c..be24b74579 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -823,41 +823,94 @@ Syntax: (ly:music-length music)) music) -(define (skip-to-last music parser) - - "Replace MUSIC by +(define-public (make-duration-of-length moment) + "Make duration of the given MOMENT length." + (ly:make-duration 0 0 + (ly:moment-main-numerator moment) + (ly:moment-main-denominator moment))) + +(define (skip-this moment) + "set skipTypesetting, make SkipMusic of the given MOMENT length, + and then unset skipTypesetting." + (make-sequential-music + (list + (context-spec-music (make-property-set 'skipTypesetting #t) + 'Score) + (make-music 'SkipMusic 'duration + (make-duration-of-length moment)) + (context-spec-music (make-property-set 'skipTypesetting #f) + 'Score)))) + +(define (unskip-this moment) + "unset skipTypesetting, make SkipMusic of the given MOMENT length, + and then set skipTypesetting." + (make-sequential-music + (list + (context-spec-music (make-property-set 'skipTypesetting #f) + 'Score) + (make-music 'SkipMusic 'duration + (make-duration-of-length moment)) + (context-spec-music (make-property-set 'skipTypesetting #t) + 'Score)))) + +(define (skip-as-needed music parser) + "Replace MUSIC by + << { \\set skipTypesetting = ##f + LENGTHOF(\\showFirstLength) + \\set skipTypesetting = ##t + LENGTHOF(\\showLastLength) } + MUSIC >> + if appropriate. + + When only showFirstLength is set, + the 'length property of the music is + overridden to speed up compiling." + (let* + ((show-last (ly:parser-lookup parser 'showLastLength)) + (show-first (ly:parser-lookup parser 'showFirstLength))) + (cond + + ;; both properties may be set. + ((and (ly:music? show-first) (ly:music? show-last)) + (let* + ((orig-length (ly:music-length music)) + (skip-length (ly:moment-sub orig-length (ly:music-length show-last))) + (begin-length (ly:music-length show-first))) + (make-simultaneous-music + (list + (make-sequential-music + (list + (skip-this skip-length) + ;; let's draw a separator between the beginning and the end + (context-spec-music (make-property-set 'whichBar "||") + 'Timing))) + (unskip-this begin-length) + music)))) + + ;; we may only want to print the last length + ((ly:music? show-last) + (let* + ((orig-length (ly:music-length music)) + (skip-length (ly:moment-sub orig-length (ly:music-length show-last)))) + (make-simultaneous-music + (list + (skip-this skip-length) + music)))) + + ;; we may only want to print the beginning; in this case + ;; only the first length will be processed (much faster). + ((ly:music? show-first) + (let* + ((orig-length (ly:music-length music)) + (begin-length (ly:music-length show-first))) + ;; the first length must not exceed the original length. + (if (ly:moment> + (else music)))) -if appropriate. - " - (let* - ((show-last (ly:parser-lookup parser 'showLastLength))) - - (if (ly:music? show-last) - (let* - ((orig-length (ly:music-length music)) - (skip-length (ly:moment-sub orig-length (ly:music-length show-last)))) - - (make-simultaneous-music - (list - (make-sequential-music - (list - (context-spec-music (make-property-set 'skipTypesetting #t) - 'Score) - (make-music 'SkipMusic 'duration - (ly:make-duration - 0 0 - (ly:moment-main-numerator skip-length) - (ly:moment-main-denominator skip-length))) - (context-spec-music (make-property-set 'skipTypesetting #f) - 'Score))) - music))) - music))) - (define-public toplevel-music-functions (list @@ -872,7 +925,7 @@ if appropriate. (lambda (x parser) (music-map cue-substitute x)) (lambda (x parser) - (skip-to-last x parser) + (skip-as-needed x parser) )))