[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: multiple \keys and \time problem
From: |
Thomas Morley |
Subject: |
Re: multiple \keys and \time problem |
Date: |
Wed, 30 Aug 2017 22:24:06 +0200 |
2017-08-30 12:01 GMT+02:00 Werner LEMBERG <address@hidden>:
>
> Folks,
>
>
> is it possible to make lilypond ignore multiple occurrences of \key or
> \time if they don't actually change the current key or time?
>
> Having
>
> \relative c' {
> \key d \major \time 2/2 d1 |
> d1 |
> \key d \major \time 2/2 d1 |
> d1 |
> }
>
> I get the attached output. However, I think it would be better that
> the redundant \time and \key signatures get ignored by default –
> similar to notes, where `des4 des4' doesn't produce a second flat sign
> for the second note...
>
> Note that this is not a constructed example; I get such lilypond code
> while converting Cubase XML output with musicxml2ly. Not sure whether
> this is a bug in Cubase, or an allowed feature of MusicXML and thus a
> bug in musicxml2ly...
>
>
> Werner
Hi Werner,
after David Nalesnik's suppressRedundantTimeSig-engraver, c/p unchanged,
http://www.mail-archive.com/address@hidden/msg72628.html
I coded a suppressRedundantKeySig-engraver.
David coded it for 2.14.2, thus the old syntax. Too lazy to update it
to use make-engraver ...
Needs further testing ofcourse.
\version "2.19.64"
suppressRedundantTimeSig =
#(lambda (ctx)
(let ((time-sig '()))
`((acknowledgers
(time-signature-interface
. ,(lambda (engraver grob source-engraver)
(set! time-sig (cons grob time-sig)))))
(finalize
. ,(lambda (trans)
(reduce
(lambda (elem prev)
(if (equal? (ly:grob-property elem 'fraction)
(ly:grob-property prev 'fraction))
(begin
(ly:grob-suicide! elem)
prev)
elem))
'()
(reverse time-sig))
(set! time-sig '()))))))
suppressRedundantKeySig =
#(lambda (ctx)
(let ((key-sig '()))
`((acknowledgers
(key-signature-interface
. ,(lambda (engraver grob source-engraver)
(let* ((cause (ly:grob-property grob 'cause)))
(if (ly:stream-event? cause)
(set! key-sig
(cons
(list
grob
(cons (ly:prob-property cause 'tonic)
(ly:prob-property cause 'pitch-alist)))
key-sig)))))))
(finalize
. ,(lambda (trans)
(reduce
(lambda (elem prev)
(if (equal? (cdr elem) (cdr prev))
(begin
(ly:grob-suicide! (car elem))
prev)
elem))
'()
(reverse key-sig))
(set! key-sig '()))))))
music = {
\time 3/4
R2.
\time 4/4
R1
\time 4/4
R1
\time 3/4
R2.
}
\score {
\new Staff \music
\layout {
\context {
\Score
\consists #suppressRedundantTimeSig
}
}
}
\score {
\relative c' {
\key d \major
\time 2/2 d1 |
d1 |
\key d \major \time 2/2 d1 |
d1 |
\key d \minor \time 2/2 d1 |
\key d \minor \time 3/4 d2. |
}
\layout {
\context {
\Score
\consists #suppressRedundantTimeSig
\consists #suppressRedundantKeySig
}
}
}
HTH,
Harm