Hello Jean!

That is a nice solution, but it has some issues. For one thing this will case 
problem if we have a Script on a skip that is used for something like spacing 
a markup (resulting in a compile error if a skip has both a script and for 
example a markup). I rather suggest to perform the check at stencil level.

Also this will affect each script in the score. I rather suggest to have a 
function tag each Script to be handled to make sure only these are handled.

Cheers,
Valentin

Am Montag, 20. Dezember 2021, 23:36:39 CET schrieb Jean Abou Samra:

> 
> I'd do this:
> 
> \version "2.22.1"
> 
> \layout {
>    \override Voice.Script.before-line-breaking =
>      #(lambda (grob)
>         (let ((parent (ly:grob-parent grob X)))
>           (if (or (not (grob::has-interface parent 'note-column-interface))
>                   (not (null? (ly:grob-object parent 'rest))))
>             (ly:grob-suicide! grob))))
> }
> 
> articulations = { s16_> s16_> s16 s16_. s16_- s8_> s16_! s8__ s8__
> s16_.  s8_- s16_. }
> 
> \new RhythmicStaff \with { \override Script.Y-offset = #-1.7 }
> \new Voice << \articulations { f'16 16 16 16 16 8 16 8 8 16 8 16 } >>
> 
> \new RhythmicStaff \new Voice << \articulations { c'8. 16 8. 16 8 r8 8.
> 16 } >>
> 
> \new RhythmicStaff \new Voice << \articulations { c'16 16 16 16 r8. 16
> r8 16 16 r16 8. } >>
> 
> 
> Best,
> Jean
#(define (moment->number mom)
   (let ((frac (moment->fraction mom)))
     (/ (car frac) (cdr frac))))

#(define (make-time-table music)
   (define (make-pairs list-of-music current-time)
     (if (null? list-of-music)
         '()
         (let* ((next (car list-of-music))
                (mom (ly:music-length next))
                (duration (moment->number mom))
                (articulations (ly:music-property next 'articulations)))
           (cons (cons current-time articulations)
                 (make-pairs (cdr list-of-music) (+ current-time duration))))))
   (make-pairs
    (ly:music-property music 'elements)
    0))

applyTable =
#(define-music-function (timetable music) (list? ly:music?)
   (define (apply-table list-of-music current-time current-timetable)
     (if (and (not (null? list-of-music)) (not (null? current-timetable)))
         (let* ((next-table-pair (car current-timetable))
                (table-time (car next-table-pair))
                (table-articulations (cdr next-table-pair))
                (current-music (car list-of-music))
                (current-articulations (ly:music-property current-music 'articulations))
                (current-elements (ly:music-property current-music 'elements))
                (current-mom (ly:music-length current-music))
                (current-mom-num (moment->number current-mom))
                (next-time (+ current-time current-mom-num))
                (next-table current-timetable))
           (while (and (not (null? next-table)) (< (caar next-table) next-time))
                  (set! next-table (cdr next-table)))
           (if (and (= current-time table-time)
                    (music-is-of-type? current-music 'note-event))
               (ly:music-set-property! current-music
                                       'articulations
                                       (append current-articulations table-articulations)))
           (if (and (= current-time table-time)
                    (music-is-of-type? current-music 'event-chord))
               (ly:music-set-property! current-music
                                       'elements
                                       (append current-elements table-articulations)))
           (apply-table (cdr list-of-music) next-time next-table))))
   (apply-table
    (ly:music-property music 'elements)
    0
    timetable)
   music)


%% DOES NOT NEED TO BE SKIPS!
articulations = { s16_> s16_> s16 s16_. s16_- s8_> s16_! s8__ s8__ s16_.  s8_- s16_. }
#(define myTable (make-time-table articulations))
%#(display myTable)

<<
 \new RhythmicStaff \with { \override Script.Y-offset = #-1.7 } 
<< { s16_> s16_> s16 s16_. s16_- s8_> s16_! s8__ s8__ s16_.  s8_- s16_. }
  { f'16 16 16 16 16 8 16 8 8 16 8 16 } >>

% but also apply the first sequential expressions, with the articulations, to for instance

\new RhythmicStaff { c'8. 16 8. 16 8 r8 8. 16 }

% so that the result would be 

\new RhythmicStaff \with { instrumentName = "this method" }
\applyTable #myTable { c'8. 16 8. 16 8 r8 8. 16 }

\new RhythmicStaff { c'8._> 16-. 8._- 16_! 8__  r8 8.-. 16-. }

% or to 

\new RhythmicStaff {c'16 16 16 16 r8. 16 r8 16 16 r16 8. }

\new RhythmicStaff \with { instrumentName = "this method" }
\applyTable #myTable {c'16 16 16 16 r8. 16 r8 16 16 r16 8. }

% getting

\new RhythmicStaff {c'16_> 16_> 16 16_. r8. 16_! r8 16__ 16 r16 8._- }
>>

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to