Am Do., 22. Juli 2021 um 16:13 Uhr schrieb Silvain Dupertuis <
silvain-dupert...@bluewin.ch>:

> Hello,
>
> I made a chord version of the first Praeludium of the *Wohltemperierte
> Klavier*
> (in which the chords were programmaticall reconstructed from the liste of
> notes)
>
> As the chords extend on 2 and a half octaves,
> I wanted to get them on a normal piano staff
> and adjust the distance of staffs so that the would be like one staff with
> one space for an A3 note.
>
> Then the chords can be placed on the upper staff with notes automatically
> appearing at they right place on the lower staff.
>
> I found a nice way to do it, using Lilypond 20, by specifying
> *staff-staff-spacing.padding* with a negative value
>
>     \new PianoStaff \with {
>
>       % midiInstrument = "tenor sax"
>
>       \override StaffGrouper.staff-staff-spacing = #'(
>
>                             (basic-distance . 0)                              
>
>                             (padding . 0)) % s0 for first exemple ; second 
> example : (padding . -3.09)
>
>     }
>
> The result was this
>
> with padding=0
> with the negative adjustment (padding = -3.06)
>
> Unfortunately, this adjustment no longer works in LilyPond 22
> It looks like the property was broken, or no longer function this way?
> Whatever the value, the distance is not affected.
>
> You can see the complete LilyPond and PDF files in this NextCloud folder
> <https://nextcloud.silvain-dupertuis.net/index.php/s/XQqdXWLzScpbFJB>
>
> Thank you in advance if you can sort this problem out.
>
> Sincerely
>
> Silvain
>
>
> --
> Silvain Dupertuis
> Route de Lausanne 335
> 1293 Bellevue (Switzerland)
> tél. +41-(0)22-774.20.67
> portable +41-(0)79-604.87.52
> web: silvain-dupertuis.org <http://perso.silvain-dupertuis.org>
>

Hi,

for the distance, I'd fo for alignment-distances of
NonMusicalPaperColumn.line-break-system-details.
I added some *experimental* code for autosplitting chords.

#(define (make-autosplit-chord chord . ref-pitch)
  "Return a pair of lists, containing the pitches of @var{chord}, splitted
at
a reference pitch.  The reference pitch is derived from @var{ref-pitch}.
If @var{ref-pitch} is empty, @code{c'} is regarded as reference.
  "
  (define ref-pitch-steps
    (if (and (pair? ref-pitch) (car ref-pitch))
        (ly:pitch-steps (car ref-pitch))
        0))

  (call-with-values
    (lambda ()
      (partition
        (lambda (note)
          (> (ly:pitch-steps (ly:music-property note 'pitch))
             ref-pitch-steps))
        (event-chord-notes chord)))
    cons))

autoSplitChord =
#(define-music-function (stem-dir staff-names pitch chord)
  ((ly:dir? 0) (pair? '("up" . "down")) (ly:pitch?) ly:music?)
  (_i "Split @var{chord} at optional @var{pitch}.  The default of
@var{pitch} is
@code{#f}, which is interpreted by the called procedure
@code{make-autosplit-chord} as @code{c'}.

The splitted chords are distributed to named staves, relying on optional
@var{staff-names}.

The optional @var{stem-dir}, determines the direction of the stems and
whether
the chords may be connected by a cross-staff stem.
The default results in unconnected chords.
If the @code{Span_stem_engraver} is consisted, the chords may be connected
by a
cross-staff stem.")
  (if (music-is-of-type? chord 'event-chord)
      (let* ((skip (make-duration-of-length (ly:music-length chord)))
             (devided-pitches (make-autosplit-chord chord pitch))
             (upper-chord
               (if (pair? (car devided-pitches))
                   (make-event-chord (car devided-pitches))
                   (make-skip-music skip)))
             (lower-chord
               (if (pair? (cdr devided-pitches))
                   (make-event-chord (cdr devided-pitches))
                   (make-skip-music skip))))
        #{
          <<
            \context Staff = #(car staff-names)
              \context Voice {
                $(if (negative? stem-dir)
                  #{
                     \once \override Stem.cross-staff = #cross-staff-connect
                     \once \override Flag.style = #'no-flag
                     <>\noBeam
                  #})
                $(if (not (zero? stem-dir))
                  #{ \once \override Stem.direction = #stem-dir #})
                #upper-chord
              }

            \context Staff = #(cdr staff-names)
              \context Voice {
                $(if (positive? stem-dir)
                  #{
                     \once \override Stem.cross-staff = #cross-staff-connect
                     \once \override Flag.style = #'no-flag
                     <>\noBeam
                  #})
                $(if (not (zero? stem-dir))
                  #{ \once \override Stem.direction = #stem-dir #})
                #lower-chord
              }
          >>
        #})
      #{ \context Staff $chord #}))

autoSplitChordsInMusic =
#(define-music-function (mus) (ly:music?)
  (map-some-music
    (lambda (m)
      (and (music-is-of-type? m 'event-chord)
           (autoSplitChord m)))
    mus))

\score {
  \new PianoStaff
  <<
  \context Staff = "up"
   \autoSplitChordsInMusic \crossStaff {
    <g c' e' g'>4 <c bes g' e''> <f, a f' c''> <g, g d' b'>
    \break
    <c g e' c''> \autoChange { a8 c' d' e' c'4 }
   }
    \context Staff = "down" \crossStaff {
      \clef "bass"
      \once \stemUp s1 \once \stemUp s1
    }
  >>
  \layout {
    \context {
      \PianoStaff
      \consists "Span_stem_engraver"
    }
  \context {
   \Score
      \override NonMusicalPaperColumn.line-break-system-details =
        #'((alignment-distances . (6)))
    }
  }
}

Works with 2.20.0 (use \autochange) and 2.22.0 (use \autoChange)

Cheers,
  Harm

Reply via email to