treble and bass clef simultaneously

classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

treble and bass clef simultaneously

Werner LEMBERG

Folks,


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...


    Werner


======================================================================


\version "2.19.83"

fakeBassClef = {
 \once\set Staff.clefGlyph = #"clefs.F"
 \once\set Staff.clefPosition = #-8
 \once\set Staff.middleCPosition = #6
 \once\override Staff.Clef.font-size = #-3
 \once\override Staff.Clef.full-size-change = ##t
 \once\override Score.BreakAlignment #'break-align-orders =
                  #(make-vector 3 '(span-bar
                                    breathing-sign
                                    staff-bar
                                    key-cancellation
                                    key-signature
                                    time-signature
                                    clef))
}

\relative c' {
  << { c'8 g a g c \once\omit Staff.Clef g a g } \\
     { s2 \fakeBassClef c,,,4\laissezVibrer s4 } >>
}

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

fakeBassClef.png (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Urs Liska-3

Am 27.03.19 um 09:22 schrieb Werner LEMBERG:
> Folks,
>
>
> 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...


I would try to write a music function that replaces the given music with
a transposed version (c, => a (maybe optional, depending on the given
clef)) and prints the clef as a markup.

This will keep your input correct but will of course change the MIDI
output, so it might only work if you dont' care about that.

HTH
Urs


_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Aaron Hill
In reply to this post by Werner LEMBERG
On 2019-03-27 1:22 am, Werner LEMBERG wrote:
> Folks,
>
>
> 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?

%%%%
\version "2.19.82"

\new Staff = "main" {
   \clef "treble"
   c''8 g' a' g'
   << { c''8 g' }
     \new Staff \with {
       \remove "Time_signature_engraver"
       alignAboveContext = #"main"
       \override VerticalAxisGroup.default-staff-staff-spacing =
         #'((basic-distance . 0) (minimum-distance . 0)
            (padding . -10) (stretchability . 0))
       \omit StaffSymbol
       \override Clef.font-size = #-3
       \override Clef.Y-offset = #(grob-transformer 'Y-offset
         (lambda (grob orig) (- orig 7/2)))
       \override NoteHead.font-size = #-3
       \override Stem.length = #(grob-transformer 'length
         (lambda (grob orig) (* 2/3 orig)))
     }
     { \clef "bass" c,4\laissezVibrer }
   >>
   a'8 g'

   c''8 g' a' g'
   << { c''8 g' }
     \new Staff \with {
       \remove "Time_signature_engraver"
       \remove "Clef_engraver"
       alignAboveContext = #"main"
       \override VerticalAxisGroup.default-staff-staff-spacing =
         #'((basic-distance . 0) (minimum-distance . 0)
            (padding . -10) (stretchability . 0))
       \omit StaffSymbol
       \override NoteHead.font-size = #-3
       \override Stem.length = #(grob-transformer 'length
         (lambda (grob orig) (* 2/3 orig)))
       \override OttavaBracket.font-size = #-3
     }
     { \clef "treble" \ottava #-2 c,4\laissezVibrer }
   >>
   a'8 g'
}
%%%%

Because of the non-standard positioning of the bass clef, I provided a
version that uses an ottava bracket instead but keeps the note in the
treble clef.  In both cases, I shrank the note size as in keeping with
cue notes.


-- Aaron Hill
_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

once-bass-clef.cropped.png (11K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Werner LEMBERG

>> 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.


    Werner

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Aaron Hill
On 2019-03-27 3:01 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)
%%%%

-- Aaron Hill

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Andrew Bernard
In reply to this post by Werner LEMBERG
Hi Werner,

Can you not use LSR 326? That is what I use quite often.

Andrew


On Wed, 27 Mar 2019 at 19:27, Werner LEMBERG <[hidden email]> wrote:

Folks,


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...


    Werner


======================================================================


\version "2.19.83"

fakeBassClef = {
 \once\set Staff.clefGlyph = #"clefs.F"
 \once\set Staff.clefPosition = #-8
 \once\set Staff.middleCPosition = #6
 \once\override Staff.Clef.font-size = #-3
 \once\override Staff.Clef.full-size-change = ##t
 \once\override Score.BreakAlignment #'break-align-orders =
                  #(make-vector 3 '(span-bar
                                    breathing-sign
                                    staff-bar
                                    key-cancellation
                                    key-signature
                                    time-signature
                                    clef))
}

\relative c' {
  << { c'8 g a g c \once\omit Staff.Clef g a g } \\
     { s2 \fakeBassClef c,,,4\laissezVibrer s4 } >>
}
_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Werner LEMBERG

> Can you not use LSR 326? That is what I use quite often.

I started with that, however, it doesn't work with my particular, more
complicated music.


    Werner

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Werner LEMBERG
In reply to this post by Aaron Hill

>>>> 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?


    Werner

\version "2.19.83"

% XXX hard-coded context `left'
fakeBassClef = #(define-music-function (treble bass)
                  (ly:music? ly:music?)
  #{
     << { \voiceOne #treble \oneVoice }
        \new Staff \with {
          \remove "Time_signature_engraver"
          alignAboveContext = #"left"
          \override VerticalAxisGroup.default-staff-staff-spacing =
            #'((basic-distance . 0)
               (minimum-distance . 0)
               (padding . -10)
               (stretchability . 0))
          \omit StaffSymbol
          \override Clef.font-size = #-2
          \override Clef.X-extent = #'(1.5 . 1.5)
          \override Clef.Y-offset =
            #(grob-transformer 'Y-offset (lambda (grob orig) (- orig 5)))
        } {
          \clef "bass" \voiceTwo #bass \oneVoice
        }
    >>
  #})


%%%%%

\new Staff = "left" \relative c'' {
  c8 g a g \fakeBassClef { <fis ais cis> g } { c,,,4 } a'''8 g |
  \fakeBassClef { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |

  \break

  \fakeBassClef { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |
  c8 g a g \fakeBassClef { <fis ais cis> g } { c,,,4 } a'''8 g |
}

%%%%%

\new PianoStaff {
  <<
    \new Staff = "right" \relative c'' {
      c1 | c1 | c1 | c1 |
    }
    \new Staff = "left" \relative c'' {
      c8 g a g \fakeBassClef { <fis ais cis> g } { c,,,4 } a'''8 g |
      \fakeBassClef { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |

      \break

      \fakeBassClef { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |
      c8 g a g \fakeBassClef { <fis ais cis> g } { c,,,4 } a'''8 g |
    }
  >>
}

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

fakeBassClef.png (28K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Werner LEMBERG
In reply to this post by Urs Liska-3
>> for a solitary bass note I want to have a bass clef, not affecting
>> anything else in the staff.  [...]
>
> I would try to write a music function that replaces the given music
> with a transposed version (c, => a (maybe optional, depending on the
> given clef)) and prints the clef as a markup.

Thanks for the idea.  In case the other approach with an overlay can't
be fixed, I will try this route.


    Werner

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Aaron Hill
In reply to this post by Werner LEMBERG
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
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Thomas Morley-2
In reply to this post by Werner LEMBERG
Am Mi., 27. März 2019 um 09:27 Uhr schrieb Werner LEMBERG <[hidden email]>:

>
>
> Folks,
>
>
> 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...
>
>
>     Werner
>
>
> ======================================================================
>
>
> \version "2.19.83"
>
> fakeBassClef = {
>  \once\set Staff.clefGlyph = #"clefs.F"
>  \once\set Staff.clefPosition = #-8
>  \once\set Staff.middleCPosition = #6
>  \once\override Staff.Clef.font-size = #-3
>  \once\override Staff.Clef.full-size-change = ##t
>  \once\override Score.BreakAlignment #'break-align-orders =
>                   #(make-vector 3 '(span-bar
>                                     breathing-sign
>                                     staff-bar
>                                     key-cancellation
>                                     key-signature
>                                     time-signature
>                                     clef))
> }
>
> \relative c' {
>   << { c'8 g a g c \once\omit Staff.Clef g a g } \\
>      { s2 \fakeBassClef c,,,4\laissezVibrer s4 } >>
> }

Hi Werner,

here my factious approach:

\version "2.19.82"

\layout {
  \context {
    \Voice
    \name "ClefVoice"
    \alias "Voice"
    \consists "Clef_engraver"
    clefGlyph = #"clefs.F"
    middleCPosition = #6
    clefPosition = #-8
    explicitClefVisibility = ##(#f #t #t)
    \override Clef.full-size-change = ##t
    \override Clef.font-size = #-4
    \override Clef.space-alist.next-note = #'(fixed-space . 2)
    \override Clef.after-line-breaking =
      #(lambda (grob)
        (let ((col (ly:item-get-column grob)))
          (if (eqv? (ly:item-break-dir grob) 1)
              (ly:grob-translate-axis!
                grob
                (cdr (ly:grob-extent col col X))
                X))))
  }
  %% probably let ClefVoice be accepted by other contexts too
  \context {
      \Staff
      \accepts "ClefVoice"
  }
}


clefTst =
#(define-music-function (m1 m2)(ly:music? ly:music?)
#{
  <<
      $m1
    \context ClefVoice = "ClefVoice" {
      \voiceTwo
      %% Mmmh, this is a Score-override, may cause problems ...
      \temporary \override Score.BreakAlignment.before-line-breaking =
        #(lambda (grob)
          (if (eqv? (ly:item-break-dir grob) 0)
              (ly:grob-set-property! grob 'break-align-orders
                  (make-vector 3 '(span-bar
                                    breathing-sign
                                    staff-bar
                                    key-cancellation
                                    key-signature
                                    time-signature
                                    clef)))))
      \set forceClef = ##t
      $m2
      \revert Score.BreakAlignment.before-line-breaking
    }
  >>
#})


\new Staff = "left"
  \relative c'' {
      %\key ces \major
    \clef treble
    c8 g a g
    \clefTst { <fis ais cis> g } c,,,4
    a'''8 g |
    \clefTst { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |

    \break

    \clefTst { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |
    c8 g a g \clefTst { <fis ais cis> g } { c,,,4 } a'''8 g |
  }


\new PianoStaff {
  <<
    \new Staff = "right" \relative c'' {
      c1 | c1 | c1 | c1 |
    }
    \new Staff = "left" \relative c'' {
      c8 g a g \clefTst { <fis ais cis> g } { c,,,4 } a'''8 g |
      \clefTst { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |

      \break

      \clefTst { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |
      c8 g a g \clefTst { <fis ais cis> g } { c,,,4 } a'''8 g |
    }
  >>
}

It's not tested beyond the given example, though.


Cheers,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Werner LEMBERG
In reply to this post by Aaron Hill
> 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: [...]

Very nice, thanks!  Attached is my slightly modified version.

* It uses `alignBelowContext', since otherwise it can happen that
  grobs sticking out vertically of the left-hand staff collide with
  grobs from the right-hand staff.  It has the drawback that
  `staff-staff-spacing' must be set in the main staff also, but I can
  live with that.  As the attached image shows, there still can be
  collisions, but in my music the system distances are sufficiently
  large to avoid that.

* It also replaces `\once\override' with `\override ... \revert' so
  that the second argument of \fakeBassClef can contain skips.

The last missing bit is the hard-coded offset of the fake bass clef
offset, which doesn't take any accidentals (and similar things left of
the note head) into account.


    Werner

\version "2.19.83"


fakeBassClef = #(define-music-function (align-below 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 #`(-4 . 0)
               \fontsize #-2 \musicglyph "clefs.F"
           }
         }
      #} ))))

  #{
    % When alignBelowContext is unspecified, attempt to find it.
    \applyContext #(lambda (context)
      (if (not (context-id? align-below))
        (let* ((staff (ly:context-find context 'Staff))
               (id (and (ly:context? staff)
                        (ly:context-id staff))))
          (if (context-id? id)
            (set! align-below id)
            (ly:warning "fakeBassClef: No named Staff found.")))))
    <<
      { #treble }
      \new Staff \with {
        \remove "Time_signature_engraver"
        \remove "Clef_engraver"
        \omit StaffSymbol

        #(ly:make-context-mod `((apply ,(lambda (c)
          (if (context-id? align-below)
            (set! (ly:context-property c 'alignBelowContext) align-below))))))

        % 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
        \override NoteHead.stencil = #prefix-with-bass-clef
        #bass
        \revert NoteHead.stencil
        \oneVoice
      }
    >>
  #} )


%%%%%

\new PianoStaff <<
  \new Staff = "right" {
    \repeat unfold 8 { c'8_[ b''' b''' c'] } |
  }
  \new Staff = "left" \with {
    % necessary for \fakeBassClef
    \override VerticalAxisGroup.staff-staff-spacing =
      #'((basic-distance . 0)
         (minimum-distance . 0)
         (padding . -100)
         (stretchability . 0))
  } \relative c'' {
    c8 g'' a g,, \fakeBassClef { <fis ais cis> g } { c,,,4 } a'''8 g |
    \fakeBassClef { <fis ais cis>8 g } { s cis,,,8 } a'''8 g c g a g |

    \break

    \fakeBassClef { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |
    c8 g'' a g,, \fakeBassClef { <fis ais cis> g } { s ces,,,8 } a'''8 g |
  }
>>

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

fakeBassClef.png (24K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Werner LEMBERG
In reply to this post by Thomas Morley-2

> here my factious approach: [...]

Thanks a lot!  Attached is the same sample code as with Aaron's
solution.  Do you see a possibility to make leading skips work in the
second argument of \clefTst?


    Werner

\version "2.19.82"

\layout {
  \context {
    \Voice
    \name "ClefVoice"
    \alias "Voice"
    \consists "Clef_engraver"
    clefGlyph = #"clefs.F"
    middleCPosition = #6
    clefPosition = #-8
    explicitClefVisibility = ##(#f #t #t)
    \override Clef.full-size-change = ##t
    \override Clef.font-size = #-4
    \override Clef.space-alist.next-note = #'(fixed-space . 2)
    \override Clef.after-line-breaking =
      #(lambda (grob)
        (let ((col (ly:item-get-column grob)))
          (if (eqv? (ly:item-break-dir grob) 1)
              (ly:grob-translate-axis!
                grob
                (cdr (ly:grob-extent col col X))
                X))))
  }
  %% probably let ClefVoice be accepted by other contexts too
  \context {
      \Staff
      \accepts "ClefVoice"
  }
}


clefTst =
#(define-music-function (m1 m2) (ly:music? ly:music?)
#{
  <<
      $m1
    \context ClefVoice = "ClefVoice" {
      \voiceTwo
      %% Mmmh, this is a Score-override, may cause problems ...
      \temporary \override Score.BreakAlignment.before-line-breaking =
        #(lambda (grob)
          (if (eqv? (ly:item-break-dir grob) 0)
              (ly:grob-set-property! grob 'break-align-orders
                  (make-vector 3 '(span-bar
                                    breathing-sign
                                    staff-bar
                                    key-cancellation
                                    key-signature
                                    time-signature
                                    clef)))))
      \set forceClef = ##t
      $m2
      \revert Score.BreakAlignment.before-line-breaking
    }
  >>
#})


\new PianoStaff <<
  \new Staff = "right" {
    \repeat unfold 8 { c'8_[ b''' b''' c'] } |
  }
  \new Staff = "left" \relative c'' {
    c8 g'' a g,, \clefTst { <fis ais cis> g } { c,,,4 } a'''8 g |
    \clefTst { <fis ais cis>8 g } { s cis,,,8 } a'''8 g c g a g |

    \break

    \clefTst { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |
    c8 g'' a g,, \clefTst { <fis ais cis> g } { s ces,,,8 } a'''8 g |
  }
>>

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

fakeBassClef2.png (21K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Thomas Morley-2
Am Do., 28. März 2019 um 08:02 Uhr schrieb Werner LEMBERG <[hidden email]>:

>
>
> > here my factious approach: [...]
>
> Thanks a lot!  Attached is the same sample code as with Aaron's
> solution.  Do you see a possibility to make leading skips work in the
> second argument of \clefTst?
>
>
>     Werner

Probably like below.
Again: not tested beyond the given example!

\version "2.19.82"

\layout {
  \context {
    \Voice
    \name "ClefVoice"
    \alias "Voice"
    \consists "Clef_engraver"
    clefGlyph = #"clefs.F"
    middleCPosition = #6
    clefPosition = #-8
    explicitClefVisibility = ##(#f #t #t)
    \override Clef.full-size-change = ##t
    \override Clef.font-size = #-4
    \override Clef.space-alist.next-note = #'(fixed-space . 2)
    \override Clef.after-line-breaking =
      #(lambda (grob)
        (let ((col (ly:item-get-column grob)))
          (if (eqv? (ly:item-break-dir grob) 1)
              (ly:grob-translate-axis!
                grob
                (cdr (ly:grob-extent col col X))
                X))))
  }
  %% probably let ClefVoice be accepted by other contexts too
  \context {
      \Staff
      \accepts "ClefVoice"
  }
}


clefTst =
#(define-music-function (m1 m2) (ly:music? ly:music?)


(ly:music-set-property! m2 'elements
 (call-with-values
   (lambda ()
     (partition
       (lambda (m) (music-is-of-type? m 'skip-event))
       (ly:music-property m2 'elements)))
   (lambda (a b)
     (append
       a
       (list
         #{
           \context ClefVoice = "ClefVoice" {
             %% Mmmh, this is a Score-override, may cause problems ...
             \temporary \override Score.BreakAlignment.before-line-breaking =
               #(lambda (grob)
                 (if (eqv? (ly:item-break-dir grob) 0)
                     (ly:grob-set-property! grob 'break-align-orders
                         (make-vector 3 '(span-bar
                                           breathing-sign
                                           staff-bar
                                           key-cancellation
                                           key-signature
                                           time-signature
                                           clef)))))
                \voiceTwo
                %\set forceClef = ##t
                #(make-sequential-music b)
                \revert Score.BreakAlignment.before-line-breaking
           }
         #})))))

#{ << $m1 $m2 >> #})


\new PianoStaff <<
  \new Staff = "right" {
    \repeat unfold 8 { c'8_[ b''' b''' c'] } |
  }
  \new Staff = "left" \relative c'' {
    c8 g'' a g,, \clefTst { <fis ais cis> g } { c,,,4 } a'''8 g |
    \clefTst { <fis ais cis>8 g } { s cis,,,8 } a'''8 g c g a g |

    \break

    \clefTst { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |
    c8 g'' a g,, \clefTst { <fis ais cis> g } { s ces,,,8 } a'''8 g |
  }
>>

Cheers,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Thomas Morley-2
Am Do., 28. März 2019 um 23:52 Uhr schrieb Thomas Morley
<[hidden email]>:

>
> Am Do., 28. März 2019 um 08:02 Uhr schrieb Werner LEMBERG <[hidden email]>:
> >
> >
> > > here my factious approach: [...]
> >
> > Thanks a lot!  Attached is the same sample code as with Aaron's
> > solution.  Do you see a possibility to make leading skips work in the
> > second argument of \clefTst?
> >
> >
> >     Werner
>
> Probably like below.
> Again: not tested beyond the given example!
>
> \version "2.19.82"
>
> \layout {
>   \context {
>     \Voice
>     \name "ClefVoice"
>     \alias "Voice"
>     \consists "Clef_engraver"
>     clefGlyph = #"clefs.F"
>     middleCPosition = #6
>     clefPosition = #-8
>     explicitClefVisibility = ##(#f #t #t)
>     \override Clef.full-size-change = ##t
>     \override Clef.font-size = #-4
>     \override Clef.space-alist.next-note = #'(fixed-space . 2)
>     \override Clef.after-line-breaking =
>       #(lambda (grob)
>         (let ((col (ly:item-get-column grob)))
>           (if (eqv? (ly:item-break-dir grob) 1)
>               (ly:grob-translate-axis!
>                 grob
>                 (cdr (ly:grob-extent col col X))
>                 X))))
>   }
>   %% probably let ClefVoice be accepted by other contexts too
>   \context {
>       \Staff
>       \accepts "ClefVoice"
>   }
> }
>
>
> clefTst =
> #(define-music-function (m1 m2) (ly:music? ly:music?)
>
>
> (ly:music-set-property! m2 'elements
>  (call-with-values
>    (lambda ()
>      (partition
>        (lambda (m) (music-is-of-type? m 'skip-event))
>        (ly:music-property m2 'elements)))
>    (lambda (a b)
>      (append
>        a
>        (list
>          #{
>            \context ClefVoice = "ClefVoice" {
>              %% Mmmh, this is a Score-override, may cause problems ...
>              \temporary \override Score.BreakAlignment.before-line-breaking =
>                #(lambda (grob)
>                  (if (eqv? (ly:item-break-dir grob) 0)
>                      (ly:grob-set-property! grob 'break-align-orders
>                          (make-vector 3 '(span-bar
>                                            breathing-sign
>                                            staff-bar
>                                            key-cancellation
>                                            key-signature
>                                            time-signature
>                                            clef)))))
>                 \voiceTwo
>                 %\set forceClef = ##t
>                 #(make-sequential-music b)
>                 \revert Score.BreakAlignment.before-line-breaking
>            }
>          #})))))
>
> #{ << $m1 $m2 >> #})
>
>
> \new PianoStaff <<
>   \new Staff = "right" {
>     \repeat unfold 8 { c'8_[ b''' b''' c'] } |
>   }
>   \new Staff = "left" \relative c'' {
>     c8 g'' a g,, \clefTst { <fis ais cis> g } { c,,,4 } a'''8 g |
>     \clefTst { <fis ais cis>8 g } { s cis,,,8 } a'''8 g c g a g |
>
>     \break
>
>     \clefTst { <fis ais cis>8 g } { c,,,4 } a'''8 g c g a g |
>     c8 g'' a g,, \clefTst { <fis ais cis> g } { s ces,,,8 } a'''8 g |
>   }
> >>
>
> Cheers,
>   Harm

More robust:
clefTst =
#(define-music-function (m1 m2) (ly:music? ly:music?)
  (ly:music-set-property! m2 'elements
    (let* ((m2-elts (ly:music-property m2 'elements))
           (idx
             (list-index
               (lambda (m) (or (music-is-of-type? m 'note-event)
                               (music-is-of-type? m 'event-chord)))
               m2-elts)))
     (call-with-values
       (lambda () (split-at m2-elts idx))
       (lambda (a b)
         (append
           a
           (list
             #{
               \context ClefVoice = "ClefVoice" {
                 %% Mmmh, this is a Score-override, may cause problems ...
                 \temporary
                   \override Score.BreakAlignment.before-line-breaking =
                      #(lambda (grob)
                        (if (eqv? (ly:item-break-dir grob) 0)
                            (ly:grob-set-property! grob 'break-align-orders
                                (make-vector 3 '(span-bar
                                                  breathing-sign
                                                  staff-bar
                                                  key-cancellation
                                                  key-signature
                                                  time-signature
                                                  clef)))))
                    \voiceTwo
                    %\set forceClef = ##t
                    #(make-sequential-music b)
                    \revert Score.BreakAlignment.before-line-breaking
               }
             #}))))))

  #{ << $m1 $m2 >> #})

Cheers,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Werner LEMBERG

>> > Thanks a lot!  Attached is the same sample code as with Aaron's
>> > solution.  Do you see a possibility to make leading skips work in
>> > the second argument of \clefTst?
>
> More robust: [...]

An excellent solution, thanks!  It's again and again amazing to see
what is possible with Scheme code – or rather, what you, Aaron, and
others are able to accomplish.  I think both your and Aaron's
solutions should be used as two alternative solutions to improve
lilypond snippet #326.

Being a perfectionist I see a last spacing issue: If there are
accidentals in the main chord, the fake bass clef gets aligned with
the leftmost accidental (in the image, I've slightly moved the clef
down for testing purposes to assure that there is no collision with
the accidentals).  I wonder why this is so – I'm not aware of the
necessity to do such an alignment at all –, and whether this can be
circumvented.


    Werner

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user

fakeBassClef2-spacing.png (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Thomas Morley-2
Am Sa., 30. März 2019 um 09:04 Uhr schrieb Werner LEMBERG <[hidden email]>:

> > More robust: [...]

> Being a perfectionist I see a last spacing issue: If there are
> accidentals in the main chord, the fake bass clef gets aligned with
> the leftmost accidental (in the image, I've slightly moved the clef
> down for testing purposes to assure that there is no collision with
> the accidentals).  I wonder why this is so – I'm not aware of the
> necessity to do such an alignment at all –, and whether this can be
> circumvented.

The distance from bass-clef to the following note is set by
\override Clef.space-alist.next-note = #'(fixed-space . 2)
So the current alignment is more by accident.

Above does not hold if the ClefVoice starts at line-begin.
Per default main and additional bass-clef are vertical aligned then.

I tried to get the bass-clef closer to the note in question with
\override Clef.after-line-breaking = ...
Though, this override does not work sufficiently. Try chords with and
without accidentals in the main Voice to what I mean.
Up to now I've not found a good method to do it better ...

Cheers,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Thomas Morley-2
Am Sa., 30. März 2019 um 13:06 Uhr schrieb Thomas Morley
<[hidden email]>:

>
> Am Sa., 30. März 2019 um 09:04 Uhr schrieb Werner LEMBERG <[hidden email]>:
>
> > > More robust: [...]
>
> > Being a perfectionist I see a last spacing issue: If there are
> > accidentals in the main chord, the fake bass clef gets aligned with
> > the leftmost accidental (in the image, I've slightly moved the clef
> > down for testing purposes to assure that there is no collision with
> > the accidentals).  I wonder why this is so – I'm not aware of the
> > necessity to do such an alignment at all –, and whether this can be
> > circumvented.
>
> The distance from bass-clef to the following note is set by
> \override Clef.space-alist.next-note = #'(fixed-space . 2)
> So the current alignment is more by accident.
>
> Above does not hold if the ClefVoice starts at line-begin.
> Per default main and additional bass-clef are vertical aligned then.
>
> I tried to get the bass-clef closer to the note in question with
> \override Clef.after-line-breaking = ...
> Though, this override does not work sufficiently. Try chords with and
> without accidentals in the main Voice to what I mean.
> Up to now I've not found a good method to do it better ...
>
> Cheers,
>   Harm

Below my current approach for adjusting the additional clef at line-begin.

\version "2.19.82"

#(define shift-clef-at-line-begin
  (lambda (grob)
    ;; If at line-start, this Clef is usually aligned with the main Clef.
    ;; Only for this case we try to move this clef towards the first
    ;; NoteColumn
    (if (eqv? (ly:item-break-dir grob) 1)
        (let* ((col (ly:item-get-column grob))
               (min-dist (ly:grob-object col 'minimum-distances))
               ;; We try to find the next PaperColumn, hopefully with the
               ;; first event initiating a NoteColumn
               (pap-col-dists
                 (filter
                   (lambda (x)
                     (and (pair? x)
                          (ly:grob? (car x))
                          (eq? (grob::name (car x)) 'PaperColumn)))
                   min-dist)))
          ;; Only proceed if a PaperColumn is found
          (if (pair? pap-col-dists)
              (let*(;; TODO sorting may be superfluous.
                    (sorted-pap-col-dists
                      (sort
                        pap-col-dists
                        (lambda (p q) (< (cdr p) (cdr q)))))
                    ;; The relevant PaperColumn with distance.
                    (rel-pap-col-dist
                      (car sorted-pap-col-dists))
                    ;; The relevant PaperColumn.
                    (pap-col
                      (car rel-pap-col-dist))
                    ;; Clef's X-extent
                    (x-ext (ly:grob-property grob 'X-extent))
                    (space-alist
                      (ly:grob-property grob 'space-alist))
                    (sys (ly:grob-system grob))
                    ;; Clef's X-extent relative to System.
                    (clef-grob-x-ext
                      (ly:grob-extent grob sys X))
                    ;; A hackish method to get the relevant NoteColumn.
                    ;; 'id is set in `clefTst´-function.
                    ;; And here used for selection.
                    ;; Lateron we want to move the clef relying only
                    ;; on the (possible) Accidentals of _this_ NoteColumn,
                    ;; not on Staff's AccidentalPlacement
                    (rel-nc
                      (filter
                        (lambda (g)
                          (and
                            (grob::has-interface g 'note-column-interface)
                            (equal? (ly:grob-property g 'id) "this")))
                        ;; TODO do we need to check for ly:grob-array?
                        (ly:grob-array->list
                          (ly:grob-object pap-col 'elements))))
                    ;; TODO if there are several entries in rel-nc,
                    ;;      simple car is likely insufficient
                    (rel-nc-grob-x-ext
                      (ly:grob-extent (car rel-nc) sys X))
                    ;; Get the relevant NoteHeads
                    (nhs-array (ly:grob-object (car rel-nc) 'note-heads))
                    (nhs-list
                      (if (ly:grob-array? nhs-array)
                          (ly:grob-array->list nhs-array)
                          '()))
                    ;; And their Accidentals
                    (raw-accs
                      (map
                        (lambda (nh)
                          (ly:grob-object nh 'accidental-grob))
                        nhs-list))
                    (accs
                      (remove null? raw-accs))
                    ;; Get the left coordinate of most left Accidental
                    (most-left-acc-left-coord
                      (apply
                        min
                        ;; If no Accidentals, use NoteCoulmn extent instead
                        (car rel-nc-grob-x-ext)
                        (map
                          (lambda (acc)
                            (car (ly:grob-extent acc sys X)))
                          accs)))
                    (amount
                      (-
                         ;; As 1. step we move the clef towards the
                         ;; NoteColumn and half clef's x-ext back.
                         ;; The clef's left edge is now algned with left
                         ;; edge of the NoteColumn ot the most left
                         ;; Accidental
                         most-left-acc-left-coord
                         (interval-center x-ext)
                         ;; Next we move the Clef to the left relying
                         ;; on the relevant NoteColumns X-dimension
                         (interval-length rel-nc-grob-x-ext)
                         ;; The default Clef doesn't sit on zero-X
                         ;; thus we move it back this amount
                         (car clef-grob-x-ext)
                         ;; Finally we apply the amount we get from
                         ;; Clef.space-alist.next-note
                         (cdr (assoc-get 'next-note space-alist)))))
                ;; Very little moving is rather disturbing,
                ;; thus we provide a threshold
                (if (> amount 1.5)
                    (ly:grob-translate-axis! grob amount X))))))))

\layout {
  \context {
    \Voice
    \name "ClefVoice"
    \alias "Voice"
    \consists "Clef_engraver"
    clefGlyph = #"clefs.F"
    middleCPosition = #6
    clefPosition = #-8
    explicitClefVisibility = ##(#f #t #t)
    \override Clef.full-size-change = ##t
    \override Clef.font-size = #-4
    \override Clef.space-alist.next-note = #'(fixed-space . 1)
    %% If adjusting clef at line-begin is not desired, comment the line below
    %% and the NoteColumn.id-override in `clefTst´
    \override Clef.after-line-breaking = #shift-clef-at-line-begin
  }
  %% probably let ClefVoice be accepted by other contexts too
  \context {
    \Staff
    \accepts "ClefVoice"
  }
}


clefTst =
#(define-music-function (m1 m2) (ly:music? ly:music?)
  (ly:music-set-property! m2 'elements
    (let* ((m2-elts (ly:music-property m2 'elements))
           (idx
             (list-index
               (lambda (m) (or (music-is-of-type? m 'note-event)
                               (music-is-of-type? m 'event-chord)))
               m2-elts)))
     (call-with-values
       (lambda () (split-at m2-elts idx))
       (lambda (a b)
         (append
           a
           (list
             #{
               \context ClefVoice = "ClefVoice" {
                    %% Sometimes needed
                    \override Staff.TimeSignature.space-alist.clef =
                      #'(fixed-space . 1)
                 %% Mmmh, this is a Score-override, may cause problems ...
                 \temporary
                   \override Score.BreakAlignment.before-line-breaking =
                      #(lambda (grob)
                        (if (eqv? (ly:item-break-dir grob) 0)
                            (ly:grob-set-property! grob 'break-align-orders
                                (make-vector 3 '(span-bar
                                                  breathing-sign
                                                  staff-bar
                                                  key-cancellation
                                                  key-signature
                                                  time-signature
                                                  clef)))))
                    \voiceTwo
                    %% Hackish ...
                    \once \override NoteColumn.id = "this"
                    #(make-sequential-music b)
                    \revert Score.BreakAlignment.before-line-breaking
               }
             #}))))))

  #{ << $m1 $m2 >> #})


\new PianoStaff <<
  \new Staff = "right" {
    \repeat unfold 8 { c'8_[ b''' b''' c'] } |
  }
  \new Staff = "left" \relative c'' {
      \key ces \major
    c8 g'' a g,, \clefTst { <fis ais cis> g } { c,,,4 } a'''8 g |
    \clefTst { <fis ais cis>8 g } { s8 cis,,,16 s } a'''8 g c g a g |

    \break

    \clefTst { <fis ais cis>8 g } { <ces,,, ees>4 } a'''8 g c g a g |
    c8 g'' a g,, \clefTst { <fis ais cis> g } { s ces,,,8 } a'''8 g |
  }
>>

HTH,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Werner LEMBERG

> Below my current approach for adjusting the additional clef at
> line-begin.

Amazing, thanks!  Alas, the effort to get the desired effect is
tremendously large.  I would have never been able to achieve that...


    Werner

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: treble and bass clef simultaneously

Thomas Morley-2
Am Mo., 1. Apr. 2019 um 23:14 Uhr schrieb Werner LEMBERG <[hidden email]>:
>
>
> > Below my current approach for adjusting the additional clef at
> > line-begin.
>
> Amazing, thanks!  Alas, the effort to get the desired effect is
> tremendously large.

Yep.
There's no direct relationship between a Clef of a _Voice_ and a
specific NoteColumn of the same Voice.
So it's difficult to find a way from one to the other, not sure if the
method I finally used is the best ...

Cheers,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
12