[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
#442 workaround (keeping piano staves alive together)
From: |
Valentin Villenave |
Subject: |
#442 workaround (keeping piano staves alive together) |
Date: |
Tue, 1 Sep 2009 14:35:12 +0200 |
2008/12/17 Valentin Villenave <address@hidden>:
Hi everyone,
Several months ago I posted a (hackish) workaround for #442:
http://lists.gnu.org/archive/html/lilypond-user/2008-12/msg00456.html
%%%
\layout {
\context { \RemoveEmptyStaffContext }
\context {
\name PseudoVoice
\alias Voice
\type Engraver_group
\consists Note_heads_engraver
\consists Pitch_squash_engraver
squashedPosition = #0
\override NoteHead #'stencil = #empty-stencil
}
\context {
\Staff
\accepts PseudoVoice
\remove Time_signature_engraver
}
}
#(define (remove music) ; throw everything into the Big Void...
(context-spec-music music 'Devnull))
#(define (unpitch music)
; in addition to the PitchSquash thing, we need to make
; accidentals disappear (since these are engraved at a
; Staff level, and since we don't want to affect the
; real Voice).
(let* ((es (ly:music-property music 'elements))
(e (ly:music-property music 'element))
(p (ly:music-property music 'pitch)))
(if (pair? es)
(ly:music-set-property!
music 'elements
(map (lambda (x) (unpitch x)) es)))
(if (ly:music? e)
(ly:music-set-property!
music 'element
(unpitch e)))
(if (ly:pitch? p)
(ly:music-set-property! music 'pitch 0)))
music)
#(define (event-filter event)
(let ((n (ly:music-property event 'name)))
(if (or
(eq? n 'ContextSpeccedMusic) ; to avoid clefs and ottavas
(eq? n 'ContextChange) ; cross-staff voices are supported
(eq? n 'ArpeggioEvent)) ; arpeggios need to go too
(music-map remove event))
(if (eq? n 'SimultaneousMusic) ; we don't want a new Voice to be created
(ly:music-set-property! event 'name 'NoteEvent))))
makeGhost =
#(define-music-function (parser location music) (ly:music?)
(context-spec-music (music-filter event-filter (unpitch music)) 'PseudoVoice))
PianoFunction=
#(define-music-function (parser location right left) (ly:music? ly:music?)
#{
\new PianoStaff <<
\new Staff = "md"
<<
\new Voice { \clef treble $right }
\new Voice { \makeGhost $left }
>>
\new Staff = "mg"
<<
\new Voice { \clef bass $left }
\new Voice { \makeGhost $right }
>>
>>
#})
\PianoFunction
\relative { c1 \break c \break R \break R \break c }
\relative { c1 R R c c }
%%%%%%%%%%
It works generally well (even supports cross-staff voices, slurs etc)
but I haven't added it to the LSR because it generates a lot of
warnings (for every note, that is):
Warning: rhythmic head is not part of a rhythmic column
I wonder if it is possible to get rid of these warnings and make it
look less ugly... or is Joe's recent work likely to make a cleaner
implementation possible?
Regards,
Valentin
- #442 workaround (keeping piano staves alive together),
Valentin Villenave <=