]> git.donarmstrong.com Git - lilypond.git/commitdiff
new showFirstLength feature
authorValentin Villenave <valentin@villenave.net>
Tue, 21 Oct 2008 08:04:21 +0000 (10:04 +0200)
committerValentin Villenave <valentin@villenave.net>
Tue, 21 Oct 2008 08:04:21 +0000 (10:04 +0200)
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.

Documentation/topdocs/NEWS.tely
Documentation/user/input.itely
Documentation/user/working.itely
input/regression/skiptypesetting-show-first-and-last.ly [new file with mode: 0644]
input/regression/skiptypesetting-show-first.ly [new file with mode: 0644]
input/regression/skiptypesetting-show-last.ly
scm/music-functions.scm

index c60fc9b5f6d667e8744647e9468997af3fc64c34..e6b2866b5d12500893c406c50242425dfa1a4c08 100644 (file)
@@ -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
index 392fbb3ea00f7094959440fdf70b8cefaefbffdb..867370d88d9d56965b9e9a1d1068a2e0236e8b01 100644 (file)
@@ -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
index c6007c7ee77e5a59e9232dd9d12280367f204828..c912e5999c85bcff1972978254ad6ce797814986 100644 (file)
@@ -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 (file)
index 0000000..4dda5fa
--- /dev/null
@@ -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 (file)
index 0000000..b8d2f6b
--- /dev/null
@@ -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
+}
index def23fc0b071cc98f8b0a285c9fabc48b3a40dcf..cd280cde0868a903964f87c1e58aeadde847e9df 100644 (file)
@@ -12,7 +12,5 @@ showLastLength = R1*3
 }
 
 {
-  c1 c1
-  c1 c1
-  c1 c1
+  c1 d e f g a
 }
index 490cafe92c40c9cc3f3de7ed20b29541353061ea..be24b74579aed713f720e6ff13ab4e63d9d24dd2 100644 (file)
@@ -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<? begin-length orig-length)
+      (set! (ly:music-property music 'length)
+       (ly:music-length show-first)))
+     music))
 
-<< { \\set skipTypesetting = ##t
-     LENGTHOF(\\showLastLength)
-     \\set skipTypesetting = ##t  }
-    MUSIC >>
+   (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)
    )))