On Mon, Mar 26, 2012 at 11:08:51PM +, Clément wrote:
Hello,
I've encountered many limits when trying to put numbers above measures.
Thanks very much for the bug report, Clement.
I've had a look at the problems you reported. See my comments below.
1) I found no possibility to print number 1 above multi-measure rests.
This is no crazy idea of mine, Breitkopf does it :
http://erato.uvt.nl/files/imglnks/usimg/f/ff/IMSLP11706-Mozart-
Horn_Concerto_No.1_horn_part.pdf
Looking at that horn part I only see the number 1 above single bar rests. So,
does the following code meet your needs?
Documented here:
http://lilypond.org/doc/v2.14/Documentation/notation/writing-rests#full-measure-rests
{
\set Staff.instrumentName = \markup \column { \line {With} \line {markup} }
R1*1^\markup \huge \bold 1 | R1*1^\markup \huge \bold 1 | R1*1^\markup
\huge \bold 1
}
2) Printing numbers above measures is limited to multi-measure rests and
percent
repeats.
Yes, I think you are correct.
I have 3 requests:
1) The possibility to print number 1 above multi-measure rests (of course, it
should begin by default on number 2 (just as now) in the case of multi-staff
scores) and the first measure in the case percent repeats.
I think you can just attach markup to the rest, see above.
2) Extent of count-percent-repeat to other types of repeats such as unfold
(useless if the following function is implemented).
The reply from Thomas Morley will lead you to some suitable code which is
credited to David Nalesnik.
I attach a copy that I have edited up to include something similar to your
example.
3) A function which could print numbers or series of numbers above
measures, such as:
I would like to have a function (implemented in Lilypond) which could print a
number above a measure, and why not series of numbers, for instance:
\time 4/4 \numberedMeasure 1 c2 c | \numberedMeasure 5 c2 c | etc.
or:
\time 4/4 \startNumberedMeasures c2 c | c c | etc. | c c \stopNumberedMeasures
or also:
\time 4/4 \startNumberMeasures \repeat unfold 8 { c2 c } \stopNumberedMeasures
I'll add this as a feature request. The code from David would make a good
starting point.
Cheers,
Colin.
--
Colin Hall
\version 2.14.2
% Thanks to David Nalesnik
#(set-global-staff-size 20)
#(define (sort-by-X-coord sys grob-lst)
Arranges a list of grobs in ascending order by their X-coordinates
(let* ((X-coord (lambda (x) (ly:grob-relative-coordinate x sys X)))
(comparator (lambda (p q) ( (X-coord p) (X-coord q)
(sort grob-lst comparator)))
#(define (find-bounding-grobs bar-line grob-lst)
(let* ((sys (ly:grob-system bar-line))
(X-coord (lambda (n) (ly:grob-relative-coordinate n sys X)))
(bar-line-X (X-coord bar-line)))
(define (helper lst)
(if (and ( (X-coord (car lst)) bar-line-X)
( (X-coord (cadr lst)) bar-line-X))
(cons (car lst) (cadr lst))
(if (null? (cddr lst))
(cons bar-line bar-line)
(helper (cdr lst)
(helper grob-lst)))
#(define (read-out ls1 ls2 ls3 symbol)
Filters all elements of ls1 from ls2 and appends it to ls3
(set! ls3 (append ls3 (filter (lambda (x) (eq? (car ls1) (symbol x))) ls2)))
(if (null? (cdr ls1))
ls3
(read-out (cdr ls1) ls2 ls3 symbol)))
#(define ((center-text-script x-offs) grob)
(let* ((sys (ly:grob-system grob))
(elements-lst (ly:grob-array-list (ly:grob-object sys
'all-elements)))
(grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name)))
(X-extent (lambda (q) (ly:grob-extent q sys X)))
(lst-1 (filter (lambda (x) (eq? 'BarLine (grob-name x)))
elements-lst))
(add (cdr (ly:grob-property (car lst-1) 'X-extent)))
;; Grobs to center between
(args (list 'BarLine
'TimeSignature
'KeySignature
'KeyCancellation
'Clef))
(grob-lst (read-out args elements-lst '() grob-name))
(new-grob-lst (remove (lambda (x) (interval-empty? (X-extent x)))
grob-lst))
(sorted-grob-lst (sort-by-X-coord sys new-grob-lst))
;; Bounds
(bounds (find-bounding-grobs grob sorted-grob-lst))
(left (cdr (X-extent (car bounds
(right (car (X-extent (cdr bounds
(basic-offset
(- (average left right)
(* -1 add)
(interval-center (X-extent grob))
(* -1 x-offs ;; End of Defs in let*
;; Calculation
(ly:grob-translate-axis! grob basic-offset X)))
centerTextScriptOn = {
\override TextScript #'after-line-breaking = #(center-text-script 0)
}
centerTextScriptOff = {
\revert TextScript #'after-line-breaking
}
onceCenterTextScript =