Hi all,

I'm been typesetting baroque music for a while, and one thing that I'm not
able to get around is some formatting niggles with the incipit. I'd like
for it to look close to those one finds in engraved Urtext editions (like
the NBA - I've attached the beginning of BWV 4/versus 3, of which I
reproduce as close as I can get to a minimal example below for
demonstrations purposes).

\version "2.24.2"

\include "incipitModern.ly" %%simply a redefinition of incipit to use a
modern staff, I've attached the file

incipitFormat = {
\override Staff.StaffSymbol.staff-space = #(magstep -2)
\override Staff.Clef.font-size = #-2
\override Staff.NoteHead.font-size = #-2
\omit Staff.TimeSignature
}

\score {
  <<
  \new Staff <<
    \new Voice = "Violin" {
      \set Staff.instrumentName = "Violino I, II"
      \clef "treble"
      \key e \minor
      r16 e'' dis'' e''
    }
  >>

  \new Staff <<
    \new Voice = "Tenor" {
      \set Staff.instrumentName = "Tenore solo"
      \incipitModern {
      \incipitFormat
      \clef "tenor"
      \key a \minor s8 }
      \clef "treble_8"
      \key e \minor
      s4
    }
  >>

  \new Staff <<
    \new Voice = "Continuo" {
      \set Staff.instrumentName = "Continuo"
      \incipitModern {
      \incipitFormat
      \clef "bass"
      \key d \minor d4 }
      \clef "bass"
      \key e \minor
      e4
    }
  >>
  >>
  \layout
  {
    indent = 4.0\cm
    incipit-width = 1.0\cm
  }
}

The problem I have is that controlling the exact width taken by the incipit
is a bit difficult - unless I set a low enough incipit-width, it's either
too far (if there's no note) or very (too) close (if there is a note) and
there's also a small gap between the end of the incipit staff and the start
of the "real" staff (or, if there is one, the corresponding brace).
Additionally, the instrument names are not vertically aligned; although
there is a trivial if non-optimal solution, to use \new Stafff \with {
\override InstrumentName.self-alignment-X = #LEFT } - I don't know if its
possible to have the instruments names centered all above one other
(without resorting to time-consuming fiddling/"cheating" by manually
including enough spaces in the instrument names), to the left of the
incipits (if any), a bit the same as if no incipit was present.

Thanks,

Aleksa Jakovljevic
organist / harpsichordist / musicologist
Montreal, Canada
\version "2.24.2"

incipitModern =
#(define-music-function (incipit-music) (ly:music?)
  (_i "Output @var{incipit-music} before the main staff as an indication of
    its appearance in the original music.")
  #{
    \once \override Staff.InstrumentName.stencil =
      #(lambda (grob)
        (let* ((instrument-name (ly:grob-property grob 'long-text))
               (align-x (ly:grob-property grob 'self-alignment-X 0))
               (align-y (ly:grob-property grob 'self-alignment-Y 0)))
        (set! (ly:grob-property grob 'long-text)
          #{ \markup {
            \score
            {
              \new Staff \with {
                \override InstrumentName.self-alignment-X = #align-x
                \override InstrumentName.self-alignment-Y = #align-y
                instrumentName = #instrument-name
              }
              {
                $incipit-music
              }
              \layout {
                $(ly:grob-layout grob)
                indent-incipit-default = 15\mm
                line-width = #(primitive-eval
                  '(or (false-if-exception indent)
                    indent-incipit-default))
                indent = #(primitive-eval
                           '(or (false-if-exception (- line-width incipit-width))
                            (* 0.5 line-width)))
                ragged-right = ##f
                ragged-last = ##f
                system-count = 1
              }
            }
            }
          #})
          (set! (ly:grob-property grob 'self-alignment-Y) #f)
          ;; Do 'self-alignment-X RIGHT only for the first InstrumentName, which
          ;; actually is the incipit. Otherwise self-alignment-X for the
          ;; shortInstrumentName is not longer settable.
          (let ((parts (ly:spanner-broken-into (ly:grob-original grob))))
            (if (and (pair? parts) (equal? grob (car parts)))
                (ly:grob-set-property! grob 'self-alignment-X RIGHT)))
          (system-start-text::print grob)))
  #}
)

Reply via email to