Adding text to slurs

Begonnen von pablocordal, Samstag, 3. November 2018, 23:22

« vorheriges - nächstes »

pablocordal

Hi to everyone from Spain  ;D

I'd like to add some text in phrasing slurs in lilypond. I've been reading the online manual and I don't find this option anywhere.
Does anybody know how to do that?

This is the music where I'd like to add text to the slurs:

\version "2.18.2"
#(ly:set-option 'midi-extension "midi")

\header {
}

\score {
    <<
    \new Staff = "melody" {
        \clef "treble"
        \set Staff.midiInstrument = #"acoustic grand"
        \new Voice {
            \override Score.BarNumber.break-visibility = #'#(#f #t #t)
            \override Score.BarNumber.font-size = #-4
            \slurDown
            \time 4/4
           
           

            \set Score.currentBarNumber = #0
            r2.\( e'4( 
            \bar "|."  g'4)  r2  e'4(  g'4)  r2  e'4(  g'4  f'4)  r4 c''4(  g'4  f'4)  r4  c'4(  f'4  e'4   b'2  a'2)  r2   c'2(  g'2)  r2.\(  e'4(
            \bar "||" \break   
            g'4)  r2  e'4(  g'4)  r2  e'4(  g'4  f'4)  r4  c''4(  g'4  f'4)  r4  c'4(  f'4  e'4   b'2  a'2)  r2  c'2(  c'2)  r1  \bar "|."  \break
            \set Score.currentBarNumber = #0
            r2  c'2^\markup { "B(8)" }  \bar "|."  d''2   c'2  r2  d''2   g'1    e'2    b'2  a'1  e'2  c'2  d'1  dis'1  \bar "|."  \break
        }
    }
    >>
\layout { indent = #0  }   
}

\markup {
  \column {
\line { \hspace #1.0 }

  }
}


Best regards for all.
Pablo



Manuela

Hi Pablo,

hi to Spain from Austria/Germany  ;)

please use the code-Tag, helpers can copy the code much better  when you do so. Your example has an error (unlimited phrasing slur), and it is not minimal.

Do you understand German? Because this is the German Lilypond forum, and all help texts and explanations are written in German, here for instance Helfern helfen.

Where is the advantage adding text to slurs instead of notes?

Greetings to Spain
Danke für eure Hilfe
viele Grüße
-- Manuela

pablocordal

Hi,
You were right about the error. I re-attach the text here without mistakes (between code labels   ;)  ):


\version "2.18.2"
#(ly:set-option 'midi-extension "midi")

\header {}

\score {
    <<
    \new Staff = "melody" {
        \clef "treble"
        \set Staff.midiInstrument = #"acoustic grand"
        \new Voice {
            \override Score.BarNumber.break-visibility = #'#(#f #t #t)
            \override Score.BarNumber.font-size = #-4
            \slurDown
            \time 4/4

            \set Score.currentBarNumber = #0
            r2. e'4(
            \bar "|."  g'4)  r2  e'4(  g'4)  r2  e'4(  g'4  f'4)  r4 c''4(  g'4  f'4)  r4  c'4(  f'4  e'4   b'2  a'2)  r2   c'2(  g'2)  r2.  e'4(
            \bar "||" \break   
            g'4)  r2  e'4(  g'4)  r2  e'4(  g'4  f'4)  r4  c''4(  g'4  f'4)  r4  c'4(  f'4  e'4   b'2  a'2)  r2  c'2(  c'2)  r1  \bar "|."  \break
            \set Score.currentBarNumber = #0
            r2  c'2(^\markup { "B(8)" }  \bar "|."  d''2   c''2)  r2  d''2(   a'2  g'2  a'2  b'2)  a'1(  e'2  c'2  d'1)  dis'1  \bar "|." \break
        }
    }
    >>
\layout { indent = #0  }   
}

\markup {
  \column {
\line { \hspace #1.0 }

  }
}




I'm sorry, I don't understand german.. I'm using google translator to understand this forum...  :o

I need to add text to the slurs (inside or outside the slurs), I don't want to replace the notes. Why?  education purposo, I'm a music teacher, so I want to add information to each musical phrase.

Best regards

Manuela

#3
Pablo, your are absolute Lilypond beginner? :)

Lilypond is a really amazing tool, but you have to learn a lot.  ;)

I am trying to demonstrate some of the capabilites of Lilypond with the following code, for better understanding I have colored the text and the notes:
\version "2.18.2"

mus = \relative c'' { c4 c c c }
myslurs = { s4( s s s) }
myphrase = { s4\( s s s\) }

mytext = {
  \override TextScript.self-alignment-X = #1
  \textLengthOn
  \once \override NoteHead.color = #green
  \once \override TextScript.color = #green
  s4-\markup \fontsize #-1 \italic "Start of Slur" s s
  \textLengthOff

  \override TextScript.self-alignment-X = #-1
  \once \override NoteHead.color = #blue
  \once \override TextScript.color = #blue
  s-\markup \fontsize #-1.5 "End of Slur"

  \override TextScript.self-alignment-X = #0
  \override TextScript.direction = #UP
  \once \override NoteHead.color = #magenta
  \once \override TextScript.color = #magenta
  s-\markup \fontsize #-1 \fontsize #-2 \italic "Start of Phrasing Slur" s s

  \once \override NoteHead.color = #grey
  \once \override TextScript.color = #grey
  s_\markup \fontsize #-3 "End of Phrasing Slur"
}

\score {
  \new Staff = "melody"
  {
    <<
      \clef treble
      \new Voice { \mus \mus }
      \context Voice { \myslurs \myphrase }
      \context Voice \mytext
    >>
  }

}


You can color Stems and Slurs too by adding following code:

\override PhrasingSlur.color = #yellow
\override Stem.color = #red

and so on.
Danke für eure Hilfe
viele Grüße
-- Manuela

harm6

Hi Pablo,

Zitat von: PabloI'm sorry, I don't understand german.. I'm using google translator to understand this forum...
Without knowledge of german, it may be pretty tedious to follow the threads in this forum.
I'd recommend to subscribe to the international (english spoken) mailinglist.
There's a spanish mailinglist as well, I don't know how active they are, though.
See:
http://lilypond.org/doc/v2.16/Documentation/web/contact

Zitat von: PabloI need to add text to the slurs (inside or outside the slurs), I don't want to replace the notes. Why?  education purposo, I'm a music teacher, so I want to add information to each musical phrase.
Two recent threads on the international list may be of interest for you:
http://lilypond.1069038.n5.nabble.com/Modified-slur-stencil-with-added-markup-td216588.html
For annotating Slurs and:
http://lilypond.1069038.n5.nabble.com/Helper-macros-for-music-analysis-td217073.html#none
Which is supposed to provide even more tools for analysis.
Though, the latter is work on progress, I doubt it's already ready for use.

Cheers,
  Harm

harm6

Hi again,

I've seen you wrote to the international list
http://lists.gnu.org/archive/html/lilypond-user/2018-11/msg00089.html

I hope you'll get many nice replies.

Cheers,
  Harm

pablocordal

Thank you for the info.

Yes, I'm trying in the international forum too. No luck there yet. I was trying to test the first code you told me Harm. I mean this one:

annotatedSlur =
#(define-music-function (padding text) ((number? 1) markup?)
   #{
     \once \override Slur.after-line-breaking =
     #(lambda (grob)
        (let*
         ((stencil (ly:slur::print grob))
          (dir (ly:grob-property grob 'direction))
          (markup-stencil (grob-interpret-markup grob text))
          (shift (- (interval-center (ly:stencil-extent stencil X))
                   (interval-center (ly:stencil-extent markup-stencil X))))
          (new-stencil
           (ly:stencil-combine-at-edge
            stencil
            Y dir
            (ly:stencil-translate-axis markup-stencil shift X)
            padding)))
         (ly:grob-set-property! grob 'stencil new-stencil)))
   #})

{
  \annotatedSlur
  %\markup \score { c''' }
  \markup  "hin." 
  c''4( g' g' c'' )
}


But when I paste it into Frescobaldi (the editor I use) and I try to compile it I receive this error:
error: syntax error, unexpected LYRIC_ELEMENT
  \markup  "hin."
                   
I don't know anything about programming in Lilypond. Can you please help me to make it work?  it is just what I need, or so it seems.

Thank you very much. Best regards

pablocordal

Manuela,

Yes, I though I was not, but now I realize YES, I'm absolute Lilypond beginner. The code you sent me adds a text in the beginning and the end of the slurs. It is not exactly what I need, I'd like the text to be centered in the slur. Can you figure out a way to do it that way?

Thank you very much ANYWAY. Best regards

harm6

It's a 2.19.82-coding, but you use 2.18.2

I've posted a 2.18-coding on the international list.

Cheers,
  Harm

P.S.
I suggest not to continue here to avoid doubling.
Most of us are subscribed overthere as well. Others may follow the already provided links.

Manuela

Ok Harm, this will be the last post from me in this thread  :)

Pablo, Harm's code works fine with Lilypond 2.19.xx, but not with 2.18. I suggest to upgrade, don't be afraid of the "unstable" version, nothing bad happens when you use it  ;)

Update: sry Harm, den ersten Teil deines Postings habe ich irgendwie überlesen  :-[
Danke für eure Hilfe
viele Grüße
-- Manuela