lilypond-user-fr
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: slurs entre crochets


From: Pierre Perol-Schneider
Subject: Re: slurs entre crochets
Date: Wed, 25 Mar 2015 19:06:07 +0100

Bonsoir JMarc,

J'ai ça en stock :

%\version "2.19.17" %% <= works ok.
\version "2.18.2"

%%% Credit: David Nalesnik
%% The following is a lot of code duplicated from program files (as
%% none of these functions is public).

#(define (make-bezier-sandwich-stencil coords thick xext yext)
  (let* ((command-list `(moveto
                         ,(car (list-ref coords 3))
                         ,(cdr (list-ref coords 3))
                         curveto
                         ,(car (list-ref coords 0))
                         ,(cdr (list-ref coords 0))
                         ,(car (list-ref coords 1))
                         ,(cdr (list-ref coords 1))
                         ,(car (list-ref coords 2))
                         ,(cdr (list-ref coords 2))
                         curveto
                         ,(car (list-ref coords 4))
                         ,(cdr (list-ref coords 4))
                         ,(car (list-ref coords 5))
                         ,(cdr (list-ref coords 5))
                         ,(car (list-ref coords 6))
                         ,(cdr (list-ref coords 6))
                         closepath)))
  (ly:make-stencil
    `(path ,thick `(,@' ,command-list) 'round 'round #t)
    xext
    yext)))

#(define (make-parenthesis-stencil
         y-extent half-thickness width angularity)
  "Create a parenthesis stencil.
@var{y-extent} is the Y extent of the markup inside the parenthesis.
@var{half-thickness} is the half thickness of the parenthesis.
@var{width} is the width of a parenthesis.
The higher the value of number @var{angularity},
the more angular the shape of the parenthesis."
  (let* ((line-width 0.1)
         ;; Horizontal position of baseline that end points run through.
         (base-x
          (if (< width 0)
              (- width)
              0))
         ;; X value farthest from baseline on outside  of curve
         (outer-x (+ base-x width))
         ;; X extent of bezier sandwich centerline curves
         (x-extent (ordered-cons base-x outer-x))
         (bottom-y (interval-start y-extent))
         (top-y (interval-end y-extent))

         (lower-end-point (cons base-x bottom-y))
         (upper-end-point (cons base-x top-y))

         (outer-control-x (+ base-x (* 4/3 width)))
         (inner-control-x (+ outer-control-x
                             (if (< width 0)
                                 half-thickness
                                 (- half-thickness))))

         ;; Vertical distance between a control point
         ;; and the end point it connects to.
         (offset-index (- (* 0.6 angularity) 0.8))
         (lower-control-y (interval-index y-extent offset-index))
         (upper-control-y (interval-index y-extent (- offset-index)))

         (lower-outer-control-point
          (cons outer-control-x lower-control-y))
         (upper-outer-control-point
          (cons outer-control-x upper-control-y))
         (upper-inner-control-point
          (cons inner-control-x upper-control-y))
         (lower-inner-control-point
          (cons inner-control-x lower-control-y)))

    (make-bezier-sandwich-stencil
      (list
             ;; Step 4: curve through inner control points
             ;; to lower end point.
             upper-inner-control-point
             lower-inner-control-point
             lower-end-point
             ;; Step 3: move to upper end point.
             upper-end-point
             ;; Step 2: curve through outer control points
             ;; to upper end point.
             lower-outer-control-point
             upper-outer-control-point
             upper-end-point
             ;; Step 1: move to lower end point.
             lower-end-point)
      line-width
      (interval-widen x-extent (/ line-width 2))
      (interval-widen y-extent (/ line-width 2)))))

#(define-public (parenthesize-stencil
                stencil half-thickness width angularity padding)
  "Add parentheses around @var{stencil}, returning a new stencil."
  (let* ((y-extent (ly:stencil-extent stencil Y))
         (lp (make-parenthesis-stencil
              y-extent half-thickness (- width) angularity))
         (rp (make-parenthesis-stencil
              y-extent half-thickness width angularity)))
    (set! stencil (ly:stencil-combine-at-edge lp X RIGHT stencil padding))
    (set! stencil (ly:stencil-combine-at-edge stencil X RIGHT rp padding))
    stencil))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END QUOTED CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#(define (parenthesize-slur half-thickness width angularity padding)
  (lambda (grob)
    (let* ((stil (ly:slur::print grob))
           (cps (ly:grob-property grob 'control-points))
           (extent-L (cons (- (cdr (first cps)) 0.5)
                           (+ (cdr (first cps)) 0.5)))
           (extent-R (cons (- (cdr (last cps)) 0.5)
                           (+ (cdr (last cps)) 0.5)))
           (left-par (make-parenthesis-stencil
                      extent-L half-thickness (- width) angularity))
           (right-par (make-parenthesis-stencil
                      extent-R half-thickness width angularity))
           (stil (ly:stencil-combine-at-edge left-par X RIGHT stil padding))
           (stil (ly:stencil-combine-at-edge stil X RIGHT right-par padding)))
      stil)))

parenthesizeSlur =
#(define-music-function (parser location half-thickness width angularity padding)
 (number? number? number? number?)
 #{
   \once \override Slur.stencil = #(parenthesize-slur half-thickness width angularity padding)
 #})

myParSlur = \parenthesizeSlur #0.05 #0.25 #0 #0.5

%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EXAMPLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\relative c'' {
  \myParSlur
  % I'm using \shape to move the slur up a uniform amount so that parentheses
  % don't bump into note.
  \shape #'((0 . 0.5) (0 . 0.5) (0 . 0.5) (0 . 0.5)) Slur
  c-( d e f)
  \myParSlur
  \shape #'((0 . -0.5) (0 . -0.5) (0 . -0.5) (0 . -0.5)) Slur
  c,( d e f)
}


Cordialement,
Pierre

Le 25 mars 2015 16:14, Daniel Bernair <address@hidden> a écrit :
J'avais posé la question pour tout un système. cela pourrait aider ?
%{
Je ne trouve pas comment programmer
l’impression d’un crochet de début de sélection
et celui de fin à travers un système.
%}

#(define-markup-command (flip layout props myGrob)
 (markup?)
   (interpret-markup layout props
     (markup #:concat (#:null #:scale (cons -1 1) #:line (myGrob)))))

#(define-markup-command (crochet layout props myBracketHeight) (number?)
 (interpret-markup layout props
   (markup #:line (#:with-dimensions (cons -1 0) (cons 0 2)
     (#:path 0.25
       (list (list (quote moveto) 0 1.5)
       (list (quote lineto) -2 1.5)
       (list (quote lineto) -2 (* myBracketHeight -1))
       (list (quote lineto) 0 (* myBracketHeight -1))))))))

global = {
 \key b\minor
 \time 3/4
 \mark\markup\box "M"
}

\score {
 <<
   \new Voice = "Bariton" {
     \global
     \clef F
     <>^\markup\crochet #28
     r4 r c'
     c'-\tweak X-offset #1
     ^\markup\flip\crochet #30 c' s
   }
   \new Lyrics \lyricsto "Bariton" {
     I
   }
   \new Lyrics \lyricsto "Bariton" {
     \markup\italic So
   }
   \new PianoStaff <<
     \new Staff {
       \global
       g''4.( a''8) fis''4-. fis'' fis'' s
     }
     \new Staff {
       \global
       \clef F
       << { r4 <c' d'> q c' c' s } \\ { a2. d } >>
     }
   >>
 >>
 \layout {
   \context {
     \Score
     \omit TimeSignature
   }
 }
}

Amicalement,
Daniel Bernair

-----Message d'origine----- From: ÉditionsIN NOMINE
Sent: Wednesday, March 25, 2015 9:12 AM
To: Seventies
Cc: address@hidden
Subject: Re: slurs entre crochets


Merci Jean-François pour cette réponse rapide !
J'ai trituré un peu le code, mais sans trop savoir ce que je faisais.
Résultat, j'obtiens, en remplaçant Hairpin par Slur (tu vois le niveau
du gars !), un joli objet bougeable lais non paramétrable. Il faudrait
qu'un crac trouve le moyen d'accrocher les crochets aux positions a et
b du Slur.

En attendant, je fais une manipe à la mano, bien bourrin :

bouge = #(define-music-function
   (parser location a-b)
   (pair?)
 #{
   \once \override Voice.TextScript.extra-offset = $a-b
 #})

slur = #(define-music-function
   (parser location a-b)
   (pair?)
 #{
   \once \override Slur.positions = $a-b
 #})

\score {
 \relative c''{

\bouge #'(-0.5 . -1.5) \slur #'(3 . 5.5) c16^"[" (d e f g a \bouge
#'(0.8 . -1.5)  b^"]") c d e f g a }}

Merci encore et à bientôt !
JMarc

Le Tue, 24 Mar 2015 11:40:37 -0700 (MST),
Seventies <address@hidden> a écrit :

J'ai retrouvé ceci sur les soufflets entre parenthèses, entre
crochets, ...

% Mettre un soufflet entre parenthèses (ou tout autre signe)

hairpinBetweenText =
#(define-music-function (parser location leftText rightText) (markup?
markup?)
   #{
     \once \override Hairpin #'stencil =
     #(lambda (grob)
        (let* ((orig (ly:grob-original grob))
               (siblings (if (ly:grob? orig)
                             (ly:spanner-broken-into orig)
                             '()))
               (hairpin-stencil (ly:stencil-aligned-to
                                 (ly:hairpin::print grob) Y CENTER))
               (left-addition (ly:stencil-aligned-to
                               (grob-interpret-markup grob leftText) Y
CENTER))
               (right-addition (ly:stencil-aligned-to
                                (grob-interpret-markup grob
rightText) Y CENTER)))
          (if (or (null? siblings)
                  (eq? grob (car siblings)))
              (set! hairpin-stencil
                    (ly:stencil-combine-at-edge
                     left-addition
                     X RIGHT
                     hairpin-stencil
                     0)))
          (if (or (null? siblings)
                  (eq? grob (car (reverse siblings))))
              (set! hairpin-stencil
                    (ly:stencil-combine-at-edge
                     hairpin-stencil
                     X RIGHT
                     right-addition
                     0.6)))
          hairpin-stencil))
   #})

% utilisation :
parenthesizedHairpin = \hairpinBetweenText \markup "(" \markup ")"
bracketedHairpin = \hairpinBetweenText \markup "[" \markup "]"
shortenedHairpin = \hairpinBetweenText \markup " " \markup " "

\parenthesizedHairpin
c16\< d e f g a b c d e f g a\!
% ne vaut que pour le soufflet suivant la note concernée


Je n'ai pas encore essayé en remplaçant le stencil hairpin par slur,
ça devrait fonctionner.
Si j'ai un moment ce soir, je teste, car c'est parfois bien utile.

Cordialement,

Jean-François




--
View this message in context:
http://lilypond-french-users.1298960.n2.nabble.com/slurs-entre-crochets-tp7582592p7582598.html
Sent from the LilyPond French Users mailing list archive at
Nabble.com.

_______________________________________________
liste de diffusion lilypond-user-fr
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user-fr



--
Jean-Marc LEGRAND
Éditions IN NOMINE

_______________________________________________
liste de diffusion lilypond-user-fr
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user-fr

_______________________________________________
liste de diffusion lilypond-user-fr
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user-fr


reply via email to

[Prev in Thread] Current Thread [Next in Thread]