Dear list members,
I have to use lots of dots and dashes in a score, so I found a snippet <http://lsr.di.unimi.it/LSR/Snippet?id=82> to apply an articulation (staccato) function to a long passage. I tried to adapt it for another articulation, the one I need (portato, = dot + dash)
It works well, except the positioning: it remains outside the Staff.
I would like to get the same positioning behavior than the default articulation (inside the staff)

I found a beginning of solution, but now the dots and dashes don't avoid collisions with the staff lines. (cf attached .ly). And I kinda feel that \override is not the clean trick.

Do anyone know how I can achieve this?
Thank you!
Best,
/Pierre
\version "2.18.2"

#(define (make-script x)
   (make-music 'ArticulationEvent
     'articulation-type x))

#(define (add-script m x)
   (case (ly:music-property m 'name)
     ((NoteEvent) (set! (ly:music-property m 'articulations)
                        (append (ly:music-property m 'articulations)
                          (list (make-script x))))
       m)
     ((EventChord)(set! (ly:music-property m 'elements)
                        (append (ly:music-property m 'elements)
                          (list (make-script x))))
       m)
     (else #f)))

#(define (add-staccato m)
   (add-script m "staccato"))

addStacc = #(define-music-function (parser location music)
              (ly:music?)
              (map-some-music add-staccato music))

%%% ............................................

#(define (make-script x)
   (make-music 'ArticulationEvent
     'articulation-type x))

#(define (add-script m x)
   (case (ly:music-property m 'name)
     ((NoteEvent) (set! (ly:music-property m 'articulations)
                        (append (ly:music-property m 'articulations)
                          (list (make-script x))))
       m)
     ((EventChord)(set! (ly:music-property m 'elements)
                        (append (ly:music-property m 'elements)
                          (list (make-script x))))
       m)
     (else #f)))

#(define (add-portato m)
   (add-script m "portato"))

addPortato = #(define-music-function (parser location music)
                (ly:music?)
                (map-some-music add-portato music))


\paper {
  indent = #30
}

\score {
  <<
    \new Staff \with { instrumentName = "defaut" } \relative c'' { g8-.-- a-.-- b-.-- c-.--\downbow d-.-- c-.-- b-.-- a-.--\upbow }
    \new Staff \with { instrumentName = "+ \addStacc" } \relative c' { \addStacc { g'8 a b c\downbow d c b a\upbow } }
    \new Staff \with { instrumentName = "+ \addPortato" } \relative c' { \addPortato { g'8 a b c\downbow d c b a\upbow } }  
    \new Staff \with { instrumentName = "+ \addP + \ov." } \relative c' { \override Staff.Script.padding = #0
                                                                          \override Staff.Script.toward-stem-shift = ##t
                                                                          \override Staff.Script.quantize-position = ##t
                                                                          \addPortato { g'8 a b c\downbow d c b a\upbow }                            
    }    
  >>
}
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to