Notation d'un barré pour une seule note ou accord

Bonjour à tous,

Tout d’abord un grand merci aux développeurs pour cette nouvelle version de LilyPond !!

J’ai besoin d’un peu d’aide pour une fonction pour la notation de barrés :

Je me suis inspiré du manuel, Notation d’accords barrés pour guitare pour écrire le code suivant :

···
\version "2.24.0"

xBarre =
#(define-music-function (txt mus) 
     (string? ly:music?)
   #{ 
   \once \override TextSpanner.font-size = #-2
   \once \override TextSpanner.staff-padding = #3
   \once \override TextSpanner.style = #'line
   \once \override TextSpanner.to-barline = ##f
   \once \override TextSpanner.bound-details = 
        #`((left
            (text . ,#{ \markup { \draw-line #'( 0 . -.8) } #})
            (Y . 0)
            (padding . 0.25)
            (attach-dir . -2))
          (right
            (text . ,#{ \markup { \hspace #0.3 \bold #txt } #})
            (Y . 0)
            (padding . 0.25)
            (attach-dir . 2)))
        <>\startTextSpan $mus \stopTextSpan #})

Cela fonctionne très bien avec :

\relative c' {
  a2 \xBarre "II" { <e' a cis>4 d' }
}

Mais j’aimerais aussi pouvoir indiquer un barré pour un accord seul, comme ça :

\relative c' {
  a,2 \xBarre "II" { <e' a cis> }
}

Comment est-ce que je peux modifier mon code pour que cela fonctionne ?

Merci !

Simon

Bonjour Simon,
Peut-être avec un markup ? Par exemple :

#(define-markup-command (singleChordBarre layout props txt)
(markup?)
(interpret-markup layout props
#{
\markup \translate #'(0 . 2.5) \concat {
\draw-line #'( 0 . -.8)
\draw-line #'( 1 . 0)
\hspace #0.3 \tiny \bold \italic #txt
} #}))

\relative c' {
a2 <e' a cis>4 ^\markup\singleChordBarre II
}

Cordialement,
Pierre
PS. Pour les barrés, voir aussi : https://lsr.di.unimi.it/LSR/Item?id=952

···

Le mer. 21 déc. 2022 à 10:57, Simon Martineau <****@****> a écrit :

Bonjour à tous,

Tout d’abord un grand merci aux développeurs pour cette nouvelle version de LilyPond !!

J’ai besoin d’un peu d’aide pour une fonction pour la notation de barrés :

Je me suis inspiré du manuel, Notation d’accords barrés pour guitare pour écrire le code suivant :

\version "2.24.0"

xBarre =
#(define-music-function (txt mus) 
     (string? ly:music?)
   #{ 
   \once \override TextSpanner.font-size = #-2
   \once \override TextSpanner.staff-padding = #3
   \once \override TextSpanner.style = #'line
   \once \override TextSpanner.to-barline = ##f
   \once \override TextSpanner.bound-details = 
        #`((left
            (text . ,#{ \markup { \draw-line #'( 0 . -.8) } #})
            (Y . 0)
            (padding . 0.25)
            (attach-dir . -2))
          (right
            (text . ,#{ \markup { \hspace #0.3 \bold #txt } #})
            (Y . 0)
            (padding . 0.25)
            (attach-dir . 2)))
        <>\startTextSpan $mus \stopTextSpan #})

Cela fonctionne très bien avec :

\relative c' {
  a2 \xBarre "II" { <e' a cis>4 d' }
}

Mais j’aimerais aussi pouvoir indiquer un barré pour un accord seul, comme ça :

\relative c' {
  a,2 \xBarre "II" { <e' a cis> }
}

Comment est-ce que je peux modifier mon code pour que cela fonctionne ?

Merci !

Simon

Bonjour,

Je fais ainsi,
j'ai sous la main les caractères BI¬ ou CII¬ je copie et compose avec.

Cordialement
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.24.0"

#(define-markup-command (Txt layout props txt) (markup?)
  "Entrée de texte"
  (interpret-markup layout props
   (markup #:fontsize -2 txt )
    ))

tx=\tweak layer -1 -\markup\center-align\Txt \etc

\relative c' {
  a2 <e' a cis>4^\tx BII¬
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Cordialement

···

--
Martial Rameaux

Merci beaucoup ! C’est exactement ce que je cherche à faire !

Par hasard, est-ce qu’il existe une possibilité en scheme de connaitre le nombre de notes contenues dans ma variable $mus ? Cela me permettrai d’intégrer ce code directement dans ma fonction dans le cas où il y a une seule note ou un seul accord…

Merci Martial, cela peut-être une bonne solution également !

Bonjour à tous,

Finalement je pense faire un petit mix des solutions proposées par Pierre (et des snippets sur LSR) et Martial. Merci à tous les deux ! J’ai encore besoin d’un peu d’aide, si quelqu’un a la solution :

singleB =
#(define-music-function (partial fretnum)
    ((string? "") number?)
  #{ 
    ^\markup {
    \center-align \fontsize #-1 \concat { 
        \bold { 
          $(format #f "~@r" fretnum) 
          #(if (not (string-null? partial))
             #{ \markup \lower #.3 \fontsize #-4.2 #partial #})
        } 
        "¬" 
      } 
    } 
    #})

\relative c'' {
  <bes d g>1 \singleB "3" 3
  % Ou
  <bes d g>1 \singleB 3
}

Je trouve la solution avec le caractère “¬” tout à fait convenable, et qui a aussi l’avantage d’être ajustée en cas d’utilisation de \magnifyStaff. J’essaye donc d’adapter un des snippets sur le LSR pour qu’il coincide.

  • Première question justement : dans les solutions proposées par Pierre (cf code ci dessous), comment faire pour que la taille soit ajustée avec \magnifyStaff ? Pour l’instant le texte est bien ajusté mais pas la ligne du textSpan :
startB = 
#(define-event-function (partial fretnum) 
   ((string? "") number? )
    #{
      \tweak bound-details.left.text
        \markup 
          \fontsize #-1 \normal-text \bold \concat { 
          #(format #f "~@r" fretnum)
          #(if (not (string-null? partial))
             #{ 
             \markup { 
             \lower #.3 \fontsize #-4.2 #partial
             \hspace #.1 }
             #}
             )
             \hspace #.1
        }
      \tweak style #'line
      \tweak thickness #1.8
      \tweak bound-details.left.stencil-align-dir-y #0
      \tweak bound-details.left.padding 0
      \tweak bound-details.left.attach-dir -1
      \tweak bound-details.left-broken.text ##f
      \tweak bound-details.left-broken.attach-dir -1
      \tweak bound-details.right.padding 0
      \tweak bound-details.right.attach-dir 1
      \tweak bound-details.right-broken.text ##f
      \tweak bound-details.right.text
        \markup
          \with-dimensions #'(0 . 0) #'(-.3 . 0) 
          \draw-line #'(0 . -0.5)
      \startTextSpan 
   #})

stopB = \stopTextSpan

\new Staff \with {
  \magnifyStaff 0.5
}
\relative c'' {
  g' \startB "3" 3 d bes \stopB
}
  • Deuxième question : toujours dans le code ci-dessus, j’aimerais que la propriété \tweak bound-details.left.stencil-align-dir-y #0 soit placée dans #(if (not (string-null? partial)) pour que la ligne soit à la bonne hauteur lorsque j’utilise l’indication de barré partiel mais aussi lorsque je ne l’utilise pas. Comment faire ? J’ai tenté d’insérer cette ligne au tout début de la fonction mais ça ne marche pas :
      (if (not (string-null? partial))
         #{ \tweak bound-details.left.stencil-align-dir-y #0 #}
         #{ \tweak bound-details.left.stencil-align-dir-y #-0.25 #}
       )

Merci beaucoup !

Bonne journée,

Simon

Bonjour Simon,

...

  • Première question justement : dans les solutions proposées par Pierre (cf code ci dessous), comment faire pour que la taille soit ajustée avec \magnifyStaff ? Pour l’instant le texte est bien ajusté mais pas la ligne du textSpan :

...

Oui, c'est assez agacent, je n'ai pas trouvé de solution simple.
Une solution un peu bâtarde serait d'ajouter un facteur 'scale' :

startB =
#(define-event-function (partial fretnum scale)
((string? "") number? number?)
#{
\tweak bound-details.left.text
\markup
\fontsize #-1 \normal-text \bold \concat {
#(format #f "~@r" fretnum)
#(if (not (string-null? partial))
#{
\markup {
\lower #.3 \fontsize #-4.2 #partial
\hspace #.1 }
#}
)
\hspace #.1
}
\tweak style #'line
\tweak thickness #1.8
\tweak bound-details.left.stencil-align-dir-y #0
\tweak bound-details.left.padding 0
\tweak bound-details.left.attach-dir -1
\tweak bound-details.left-broken.text ##f
\tweak bound-details.left-broken.attach-dir -1
\tweak bound-details.right.padding 0
\tweak bound-details.right.attach-dir 1
\tweak bound-details.right-broken.text ##f
\tweak bound-details.right.text
\markup
%\with-dimensions #'(0 . 0) #'(-.3 . 0)
%\draw-line #'(0 . -0.5)
\stencil #(make-connected-path-stencil
'((0 -.5)) 0.15 1 scale #f #f)
\startTextSpan
#})

stopB = \stopTextSpan

\new Staff \with {
\magnifyStaff 0.5
}
\relative c'' {
g' \startB "3" 3 0.5 d bes \stopB
}

...

  • Deuxième question : toujours dans le code ci-dessus, j’aimerais que la propriété \tweak bound-details.left.stencil-align-dir-y #0 soit placée dans #(if (not (string-null? partial)) pour que la ligne soit à la bonne hauteur lorsque j’utilise l’indication de barré partiel mais aussi lorsque je ne l’utilise pas. Comment faire ? J’ai tenté d’insérer cette ligne au tout début de la fonction mais ça ne marche pas :

...

Si c'est possible mais il faut réécrire tout le markup pour chaque option, pas seulement le tweak

HTH, cordialement,

Pierre

···

Le ven. 23 déc. 2022 à 10:13, Simon Martineau <****@****> a écrit :

Merci beaucoup Pierre !

Voilà donc ma fonction qui me convient très bien, je me demande juste si il n’y a pas moyen d’utiliser (let (barre-markup (...))), je trouve ça un peu dommage de réécrire les mêmes lignes avec les \tweak à l’identique. Je vais faire quelques essais !

startB = 
#(define-event-function (partial fretnum) 
   ((string? "") number? )
   (if (not (string-null? partial)) 
   #{
      \tweak bound-details.left.text
        \markup 
          \fontsize #-1 \normal-text \bold \concat { 
          #(format #f "~@r" fretnum)
             \lower #.3 \fontsize #-4.2 #partial
             \hspace #.1 }
      \tweak style #'line
      \tweak thickness #1.5
      \tweak bound-details.left.stencil-align-dir-y #0
      \tweak bound-details.left.padding 0
      \tweak bound-details.left.attach-dir -1
      \tweak bound-details.left-broken.text ##f
      \tweak bound-details.left-broken.attach-dir -1
      \tweak bound-details.right.padding 0
      \tweak bound-details.right.attach-dir 1
      \tweak bound-details.right-broken.text ##f
      \tweak bound-details.right.text
        \markup
          \with-dimensions #'(0 . 0) #'(-.3 . 0) 
          \draw-line #'(0 . -0.4)
      \startTextSpan 
   #}
    #{
      \tweak bound-details.left.text
        \markup 
          \fontsize #-1 \normal-text \bold \concat { 
          #(format #f "~@r" fretnum)
          \hspace #.1
        }
      \tweak style #'line
      \tweak thickness #1.5
      \tweak bound-details.left.stencil-align-dir-y #-0.25
      \tweak bound-details.left.padding 0
      \tweak bound-details.left.attach-dir -1
      \tweak bound-details.left-broken.text ##f
      \tweak bound-details.left-broken.attach-dir -1
      \tweak bound-details.right.padding 0
      \tweak bound-details.right.attach-dir 1
      \tweak bound-details.right-broken.text ##f
      \tweak bound-details.right.text
        \markup
          \with-dimensions #'(0 . 0) #'(-.3 . 0) 
          \draw-line #'(0 . -0.4)
      \startTextSpan 
   #})
)

Pour le facteur scale et \magnifyStaff, je garde l’idée sous le coude !

Merci beaucoup !

Simon

Oui, bien sûr :

\version "2.24.0"

startB =
#(define-event-function (partial fretnum)
((string? "") number? )
(let ((barre-event
#{
\tweak style #'line
\tweak thickness #1.5
\tweak bound-details.left.stencil-align-dir-y #0
\tweak bound-details.left.padding 0
\tweak bound-details.left.attach-dir -1
\tweak bound-details.left-broken.text ##f
\tweak bound-details.left-broken.attach-dir -1
\tweak bound-details.right.padding 0
\tweak bound-details.right.attach-dir 1
\tweak bound-details.right-broken.text ##f
\tweak bound-details.right.text
\markup
\with-dimensions #'(0 . 0) #'(-.3 . 0)
\draw-line #'(0 . -0.4)
\startTextSpan
#}))
(if (string-null? partial)
#{
\tweak bound-details.left.text
\markup
\fontsize #-1 \normal-text \bold \concat {
#(format #f "~@r" fretnum)
\hspace #.1
}
#barre-event
#}
#{
\tweak bound-details.left.text
\markup
\fontsize #-1 \normal-text \bold \concat {
#(format #f "~@r" fretnum)
\lower #.3 \fontsize #-4.2 #partial
\hspace #.1 }
#barre-event
#})))

Attention, il y a bien deux paires de parenthèses autour de
« barre-event ... » dans « (let ((barre-event ...)) ...) »,
comme expliqué dans

https://tutoriel-scheme.readthedocs.io/fr/latest/variables-locales.html#parentheser-un-let

Cordialement,
Jean

···

Le 24/12/2022 à 09:56, Simon Martineau a écrit :

Merci beaucoup Pierre !

Voilà donc ma fonction qui me convient très bien, je me demande juste si il n’y a pas moyen d’utiliser (let (barre-markup (...))), je trouve ça un peu dommage de réécrire les mêmes lignes avec les \tweak à l’identique. Je vais faire quelques essais !

Merci beaucoup Jean !

Voilà donc la fonction au final :

startB = 
#(define-event-function (partial fretnum) 
   ((string? "") number? )
   (let ((barre-event
         #{
            \tweak style #'line
            \tweak thickness #1.2
            \tweak bound-details.left.padding 0
            \tweak bound-details.left.attach-dir -1
            \tweak bound-details.left-broken.text ##f
            \tweak bound-details.left-broken.attach-dir -1
            \tweak bound-details.right.padding 0
            \tweak bound-details.right.attach-dir 1
            \tweak bound-details.right-broken.text ##f
            \tweak bound-details.right.text
              \markup
                \with-dimensions #'(0 . 0) #'(-.3 . 0) 
                \draw-line #'(0 . -0.4)
            \startTextSpan 
          #})) 
     (if (string-null? partial)
          #{
            \tweak bound-details.left.text
              \markup 
                \fontsize #-1 \normal-text \bold \concat { 
                #(format #f "~@r" fretnum)
                \hspace #.1
              }
            \tweak bound-details.left.stencil-align-dir-y #-0.25
            #barre-event
          #}
          #{
            \tweak bound-details.left.text
              \markup 
                \fontsize #-1 \normal-text \bold \concat { 
                #(format #f "~@r" fretnum)
                \lower #.3 \fontsize #-4.2 #partial
                \hspace #.1 }
            \tweak bound-details.left.stencil-align-dir-y #0
            #barre-event
          #})))

stopB = \stopTextSpan

Merci à tous pour votre aide !

Simon