[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Automatic setting custom bar lines
From: |
jakob lund |
Subject: |
Re: Automatic setting custom bar lines |
Date: |
Mon, 13 Feb 2012 11:36:09 +0100 |
13. feb. 2012 01.54 skrev Thomas Morley <address@hidden>:
> Hi again,
>
> perhaps you may want to use:
>
> \version "2.14.2"
> %\version "2.15.29"
>
> CustomDefaultBarLineEngraver =
> #(lambda (context)
> (let ((glyph "|"))
> `((acknowledgers
> (bar-line-interface .
> ,(lambda (engraver grob source-engraver)
> (if (equal? glyph (ly:grob-property grob 'glyph))
> (set! (ly:grob-property grob 'bar-extent) '(0 . 2))
> #f)))))))
>
>
> \new Staff \relative c'' {
> % If you don't want to put it in \layout use it like:
> c1 \bar "" c1 c c \bar ":|:" \break
> c1 c1 \bar "||" c c \bar ":|:" \break
> \repeat volta 2 {
> c1 c1 c c \bar ":|:" } \break
> c1 \bar ":|S|:" c1 \bar "S" c \bar "|."
> }
>
> \layout {
> \context {
> \Staff
> \consists #CustomDefaultBarLineEngraver
> }
> }
>
> This is my very first custom-scheme-engraver. I'd appreciate if
> someone more experienced could have a look on it.
This is very nice! A while ago I was trying to shorten every _other_
bar line shorter, but couldn't figure out how to do it automatically.
With "your" technique it's easy to extract the bar number from
"context":
CustomOtherBarLineEngraver =
#(lambda (context)
(let ((glyph "|"))
`((acknowledgers
(bar-line-interface .
,(lambda (engraver grob source-engraver)
(let ((oddbar (remainder (ly:context-property context
'currentBarNumber) 2)))
(if (and (eq? oddbar 0)
(equal? glyph (ly:grob-property grob 'glyph)))
(set! (ly:grob-property grob 'bar-extent) '(-1 . 1))
#f))))))))
I suppose the code could be parameterized in order to make it more
generally useful...
Cheers
Jakob.