Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
LilyPond wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Repeat with brackets
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
This snippet adds brackets with the number of repetitions above a bar or a group of bar. Very useful when dealing with minimal music, for instance. To summon it, simply use <code>\repeatBracket </code><code>N</code><code> </code><code>music</code>, where <code>N</code> is the number of repetitions. Example: <code>\repeatBracket 7 { c'2 e' }</code> <lilypond version="2.24.0" full> % repeatBracket snippet % will add .----Nx----. above a bar, where N is the number of repetitions % based on the wonderful spanner by David Nalesnik (see: http://lists.gnu.org/archive/html/lilypond-user/2014-10/msg00446.html ) #(define (test-stencil grob text) (let* ((orig (ly:grob-original grob)) (siblings (ly:spanner-broken-into orig)) ; have we been split? (refp (ly:grob-system grob)) (left-bound (ly:spanner-bound grob LEFT)) (right-bound (ly:spanner-bound grob RIGHT)) (elts-L (ly:grob-array->list (ly:grob-object left-bound 'elements))) (elts-R (ly:grob-array->list (ly:grob-object right-bound 'elements))) (break-alignment-L (filter (lambda (elt) (grob::has-interface elt 'break-alignment-interface)) elts-L)) (break-alignment-R (filter (lambda (elt) (grob::has-interface elt 'break-alignment-interface)) elts-R)) (break-alignment-L-ext (ly:grob-extent (car break-alignment-L) refp X)) (break-alignment-R-ext (ly:grob-extent (car break-alignment-R) refp X)) (num (markup text)) (num (if (or (null? siblings) (eq? grob (car siblings))) num (make-parenthesize-markup num))) (num (grob-interpret-markup grob num)) (num-stil-ext-X (ly:stencil-extent num X)) (num-stil-ext-Y (ly:stencil-extent num Y)) (num (ly:stencil-aligned-to num X CENTER)) (num (ly:stencil-translate-axis num (+ (interval-length break-alignment-L-ext) (* 0.5 (- (car break-alignment-R-ext) (cdr break-alignment-L-ext)))) X)) (bracket-L (markup #:path 0.1 ; line-thickness `((moveto 0.5 ,(* 0.5 (interval-length num-stil-ext-Y))) (lineto ,(* 0.5 (- (car break-alignment-R-ext) (cdr break-alignment-L-ext) (interval-length num-stil-ext-X))) ,(* 0.5 (interval-length num-stil-ext-Y))) (closepath) (rlineto 0.0 ,(if (or (null? siblings) (eq? grob (car siblings))) -1.0 0.0))))) (bracket-R (markup #:path 0.1 `((moveto ,(* 0.5 (- (car break-alignment-R-ext) (cdr break-alignment-L-ext) (interval-length num-stil-ext-X))) ,(* 0.5 (interval-length num-stil-ext-Y))) (lineto 0.5 ,(* 0.5 (interval-length num-stil-ext-Y))) (closepath) (rlineto 0.0 ,(if (or (null? siblings) (eq? grob (last siblings))) -1.0 0.0))))) (bracket-L (grob-interpret-markup grob bracket-L)) (bracket-R (grob-interpret-markup grob bracket-R)) (num (ly:stencil-combine-at-edge num X LEFT bracket-L 0.4)) (num (ly:stencil-combine-at-edge num X RIGHT bracket-R 0.4))) num)) #(define-public (Measure_attached_spanner_engraver context) (let ((span '()) (finished '()) (event-start '()) (event-stop '())) (make-engraver (listeners ((measure-counter-event engraver event) (if (= START (ly:event-property event 'span-direction)) (set! event-start event) (set! event-stop event)))) ((process-music trans) (if (ly:stream-event? event-stop) (if (null? span) (ly:warning "You're trying to end a measure-attached spanner but you haven't started one.") (begin (set! finished span) (ly:engraver-announce-end-grob trans finished event-start) (set! span '()) (set! event-stop '())))) (if (ly:stream-event? event-start) (begin (set! span (ly:engraver-make-grob trans 'MeasureCounter event-start)) (set! event-start '())))) ((stop-translation-timestep trans) (if (and (ly:spanner? span) (null? (ly:spanner-bound span LEFT)) (moment<=? (ly:context-property context 'measurePosition) ZERO-MOMENT)) (ly:spanner-set-bound! span LEFT (ly:context-property context 'currentCommandColumn))) (if (and (ly:spanner? finished) (moment<=? (ly:context-property context 'measurePosition) ZERO-MOMENT)) (begin (if (null? (ly:spanner-bound finished RIGHT)) (ly:spanner-set-bound! finished RIGHT (ly:context-property context 'currentCommandColumn))) (set! finished '()) (set! event-start '()) (set! event-stop '())))) ((finalize trans) (if (ly:spanner? finished) (begin (if (null? (ly:spanner-bound finished RIGHT)) (set! (ly:spanner-bound finished RIGHT) (ly:context-property context 'currentCommandColumn))) (set! finished '()))) (if (ly:spanner? span) (begin (ly:warning "I think there's a dangling measure-attached spanner :-(") (ly:grob-suicide! span) (set! span '()))))))) % necessary layout options % note that you can have more than one single layout block (some of them may even be outside and some inside \score) \layout { \context { \Staff \consists #Measure_attached_spanner_engraver \override MeasureCounter.font-encoding = #'latin1 \override MeasureCounter.font-size = 0 \override MeasureCounter.outside-staff-padding = 2 \override MeasureCounter.outside-staff-horizontal-padding = #0 } } % function itself repeatBracket = #(define-music-function (N note) (number? ly:music?) #{ \override Staff.MeasureCounter.stencil = #(lambda (grob) (test-stencil grob #{ #(string-append(number->string N) "Γ") #} )) \startMeasureCount \repeat volta #N { $note } \stopMeasureCount #} ) %%%%%%%%%%%%%%%%%%%%%% EXAMPLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% { \repeatBracket 7 {c'1} \repeatBracket 32 {d' g} \repeatBracket 14 {e' f g} \repeatBracket 29 {f' a bes \break cis' e''} \repeatBracket 1048 {g'1} } \paper { tagline = ##f } </lilypond> [[Category:Repeats]] [[Category:Automatic notation]] [[Category:Contemporary notation]] [[Category:Specific notation]] [[Category:Contexts and engravers]]
Summary:
Please note that all contributions to LilyPond wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Meta:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Repeat with brackets
Add topic