Hi Alasdair,

Am 07.08.23 um 07:05 schrieb Alasdair McAndrew:
In fact you can just look at the snippet at https://lsr.di.unimi.it/LSR/Item?id=848 I've set mine up slightly differently, with letters between the lines, but the principle is the same.  But as you see from this snippet, you have to enter the notes and values for the tablature stave, and the note durations again (with appropriate "silent" notes) for the rhythm stave.  And both these staves have to be created independently and put together at the end.

I want to know if you can do this without having to enter the rhythm durations and stave separately - the information in "myNotes" in the snippet contains all the information needed. I'm hoping for a solution where all you need to enter is "myNotes", and then both the tablature staff and the rhythm staff would be created in one go.

Thank you again.

That's basically a matter of programmatically turning the given music into bare (pitch-less) durations while skipping repeated durations.

Question: What should be done for actual rests in the input?

One possible approach might be:

\version "2.24.0"

%% http://lsr.di.unimi.it/LSR/Item?id=848
%LSR modified by P.P.Schneider on Feb.2014 for v2.18
% modified by L.-F. Moser in Aug. 2023
% (added \extractRhythm and \tabStaves)

%{ Tablature layout for viol music

The snippet defines a specialized group of rhythmic and
tablature staves able to handle old english viol tablature
scores.

The string tunings defaults to the most common viol in d
but other usual tunings are also available.

The rhythm part is used to provide only the pace changes,
and therefore must be provided as a supplementary voice.
%}

viol-in-d-tuning = \stringTuning <d, g, c e a' d'>

viol-in-d-scord-tuning = \stringTuning <c, g, c e a' d'>

viol-in-g-tuning = \stringTuning <g, c f a' d' g''>

ViolTabLayout = \layout {
  \context {
    \RhythmicStaff
    \type "Engraver_group"
    \name "ViolTabRhythmicStaff"
    \alias "RhythmicStaff"

    \description "Handles rhythm part of viol tablature."

    \remove "Time_signature_engraver"
    \remove "Staff_symbol_engraver"
    \remove "Bar_engraver"

    fontSize = #-3
    \override StaffSymbol.staff-space = #(magstep -3)
    \override Stem.length = #5
    \override VerticalAxisGroup.staff-staff-spacing =
    #'((basic-distance . 1)
       (minimum-distance . 1)
       (padding . 1))

    % useful to merge chords noteheads
    \override NoteHead.X-offset = #0
  }

  \context {
    \TabStaff
    \type "Engraver_group"
    \name "ViolTabFingeringStaff"
    \alias "Staff"

    \description "Handles fingering part of viol tablature."

    tablatureFormat = #fret-letter-tablature-format
    stringTunings = #viol-in-d-tuning

    % useful for tablature only scores
    \revert TimeSignature.stencil
    \override TimeSignature.style = #'single-digit
  }

  \context {
    \type "Engraver_group"
    \name "ViolTabStaff"
    \consists "Vertical_align_engraver"
    topLevelAlignment = ##f

    \description "Handles viol tablature."

    \defaultchild "ViolTabFingeringStaff"
    \accepts "ViolTabRhythmicStaff"
    \accepts "ViolTabFingeringStaff"
  }

  \context {
    \Score
    \accepts "ViolTabStaff"
  }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#(define rest-or-skip?
   (music-type-predicate '(skip-event general-rest-event)))

extractRhythm =
#(define-music-function (mus) (ly:music?)
   (make-music
    'SequentialMusic
    'elements
    (let loop
      ((remaining-notes
        (extract-typed-music (event-chord-reduce mus)
                             'rhythmic-event))
       (current-duration #f))

      (if
       (null? remaining-notes)
       '()
       (let*
        ((note (car remaining-notes))
         (duration (ly:music-property note 'duration)))
        (cons
         (make-music
          (if (or (rest-or-skip? note)
                  (equal? duration current-duration))
              'SkipEvent
              'NoteEvent)
          'duration duration)
         (loop (cdr remaining-notes)
               (if (rest-or-skip? note) current-duration duration))))))))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

tabStaves =
#(define-music-function (mus) (ly:music?)
   #{
     <<
       \new Staff \with { \clef bass } {
         #mus
       }
       \new ViolTabStaff {
         <<
           \new ViolTabRhythmicStaff {
             \extractRhythm $mus
           }
           \new ViolTabFingeringStaff { #mus }
         >>
       }
     >>
   #})

myNotes = \relative c {
  <d, g d'>4 e f8 g a4
  <d b g>2. c4
  d4. e8 f4 g
  r8 g g f e4 a
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\score {
  \tabStaves \myNotes
  \layout {
    \ViolTabLayout
  }
}

Lukas


Reply via email to