On 2019-03-27 6:46 am, Werner LEMBERG wrote:
for a solitary bass note I want to have a bass clef, not
affecting anything else in the staff. How can I fix the attached
example? I guess I need a music function that adjusts the
vertical note offset of the upper voice...
Could you use an "ossia" that overlaps the staff? [...]
A very nice idea, thanks! I admit that I would never have thought
of that. Your example is almost perfect, except that I would like
to avoid the horizontal gap caused by bass clef. What property
controls that? I tried to modify some `Clef' properties given in
`define-grobs.scm', but I didn't get the desired effect.
Has the potential for overlapping ink, but try this:
%%%%
\override Clef.X-extent = #'(1.5 . 1.5)
%%%%
Thanks, but this helps only partially.
I've now extended the example, see the attached stuff. There are
still two problems.
* The overlay fails if used within a `PianoStaff' context. This is a
showstopper.
* The small bass clef is placed before a barline.
Ideas?
When staves are part of a group (such as PianoStaff), then it is
important to use staff-staff-padding, not default-staff-staff-padding.
So I goofed there.
As penance, try out the following:
%%%%
\version "2.19.82"
fakeBassClef = #(define-music-function (align-above treble bass)
((string? #f) ly:music? ly:music?)
(define (context-id? id) (and (string? id) (not (string-null? id))))
(define prefix-with-bass-clef
(grob-transformer 'stencil (lambda (grob orig)
(grob-interpret-markup grob #{
\markup \with-dimensions-from \stencil $orig \overlay {
\stencil $orig
\translate #'(-3 . 0) \fontsize #-2 \musicglyph "clefs.F"
}
#} ))))
#{
% When alignAboveContext is unspecified, attempt to find it.
\applyContext #(lambda (context)
(if (not (context-id? align-above))
(let* ((staff (ly:context-find context 'Staff))
(id (and (ly:context? staff) (ly:context-id staff))))
(if (context-id? id) (set! align-above id)
(ly:warning "fakeBassClef: No named Staff found.")))))
<<
{ \voiceOne #treble \oneVoice }
\new Staff \with {
\remove "Time_signature_engraver"
\remove "Clef_engraver"
\omit StaffSymbol
#(ly:make-context-mod `((apply ,(lambda (c)
(if (context-id? align-above)
(set! (ly:context-property c 'alignAboveContext)
align-above))))))
% Force overlap by using a very large negative padding.
\override VerticalAxisGroup.staff-staff-spacing =
#'((basic-distance . 0) (minimum-distance . 0)
(padding . -100) (stretchability . 0))
} {
\clef "bass" \voiceTwo
\once \override NoteHead.stencil = #prefix-with-bass-clef
#bass \oneVoice
}
>>
#} )
%%%%
I have tried to separate some concerns here and document a bit. I also
grabbed some logic from David K. that attempts to automatically
determine the name of the context to align above. Its robustness is
questionable, so as a fallback I enabled an optional argument to the
music function.
-- Aaron Hill
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user