I have entered the attached music.  So far, I have not been able to get the 
clef or time signature to print on the first measure.

I can get the clef in the middle of the first measure by adding "\set Staff.forceClef = 
##t" right after the first grace note in the "intro_part", but that doesn't work if 
I put it in front of the first grace note.

Also, I have not been able to get the time signature to print.

I'm guessing this is because of the way I'm including the "intro_part", but I'm 
not sure how else to include it.

I also had to add a rest at line 68, because otherwise, the "outro_part" starts inside 
the repeat of the "melody_part".

If anyone can suggest a better way to structure this, I'd appreciate it.

        Thanks,
        Steve
\version "2.23.8"

\header{
  title="Memphis, Tennessee"
  composer="Chuck Berry"
  enteredby="saf"
  tagline = ""  % remove the tag line
}

\include "english.ly"
\include "predefined-guitar-fretboards.ly"
\include "definitions.ily"

riff_part = {
  \transpose c c {
    \relative {
      % We don't want doubleSlurs on bends, because it gives us double arrows.
      \set doubleSlurs = ##f
      \set fingeringOrientations = #'(up)

      \set glissandoMap = #'((0 . 0))

      < e,\6 b'\5-1 >4 < e\6 b'\5-1 >4 < e\6 cs'\5-3 >4 < e\6 cs'\5-3 >4						| % measure 7 / 26
      < e\6 d'\5-4 >4 < e\6 d'\5-4 >4 < e\6 cs'\5-3 >4
      \tuplet 3/2 { \bendOn ( < e'\4-1 >8 ) ( < eqs\4-1 >8 ) ( < e\4-1 >8 ) \bendOff }					| % measure 8 / 27

      < e,\6 b'\5-1 >4 < e\6 b'\5-1 >4 < e\6 cs'\5-3 >4 < e\6 cs'\5-3 >4						| % measure 9 / 28
      < e\6 d'\5-4 >4 < e\6 d'\5-4 >4 < e\6 cs'\5-3 >4 r4								| % measure 10 / 29
    }
  }
}

intro_part = {
  \transpose c c {
    \tempo 4 = 180
    \time 2/2
    \key e \major
    \clef "treble_(8)"

    \relative {
      % We don't want doubleSlurs on bends, because it gives us double arrows.
      \set doubleSlurs = ##f
      \set fingeringOrientations = #'(up)

      \set glissandoMap = #'((0 . 0))
      \grace < d'\2-3 e\1 >16 \glissando < e\2-3 e\1 >2 < d\2-3 e\1 >2							| % measure 1
      \grace < a\3-1 b\2 >16 \glissando < b\3-1 b\2 >2 \tuplet 3/2 { < a\3-1 >4 < g\3 >4 < e\4-2 >4 }			| % measure 2

      \grace < d'\2-3 e\1 >16 \glissando < e\2-3 e\1 >2 < d\2-3 e\1 >2							| % measure 3
      \grace < a\3-1 b\2 >16 \glissando < b\3-1 b\2 >2 \tuplet 3/2 { < a\3-1 >4 < g\3 >4 < e\4-2 >4 }			| % measure 4

      \grace < d'\2-3 e\1 >16 \glissando < e\2-3 e\1 >2 < d\2-3 e\1 >2 							| % measure 5
      \grace < a\3-1 b\2 >16 \glissando < b\3-1 b\2 >2 \tuplet 3/2 { < a\3-1 >4 < g\3 >4 < e\4-2 >4 }			| % measure 6

      \riff_part
    }
  }
}

outro_part = {
  \transpose c c {
    \relative {
      % We don't want doubleSlurs on bends, because it gives us double arrows.
      \set doubleSlurs = ##f
      \set fingeringOrientations = #'(up)

      \set glissandoMap = #'((0 . 0))
      s32 % I don't know why I need this rest, but without it, the outro starts inside the repeat!
      \grace < d'\2-3 e\1 >16 \glissando < e\2-3 e\1 >2 < d\2-3 e\1 >2 							| % measure 30
      \grace < a\3-1 b\2 >16 \glissando < b\3-1 b\2 >2 \tuplet 3/2 { < a\3-1 >4 < g\3 >4 < e\4-2 >4 }			| % measure 31

      \grace < d'\2-3 e\1 >16 \glissando < e\2-3 e\1 >2 < d\2-3 e\1 >2 							| % measure 32
      \grace < a\3-1 b\2 >16 \glissando < b\3-1 b\2 >2 \tuplet 3/2 { < a\3-1 >4 < g\3 >4 < e\4-2 >4 }			| % measure 33

      \grace < d'\2-3 e\1 >16 \glissando < e\2-3 e\1 >2 < d\2-3 e\1 >2 							| % measure 34
      \grace < a\3-1 b\2 >16 \glissando < b\3-1 b\2 >2 \tuplet 3/2 { < a\3-1 >4 < g\3 >4 < e\4-2 >4 }			| % measure 35

      r1 \bar "||"													| % measure 36
    }
  }
}

chord_part = {
  \transpose c c {
    \key e \major

    \chordmode {
      s1														| % measure 1
      s1														| % measure 2
      s1														| % measure 3
      s1														| % measure 4

      s1														| % measure 5
      s1														| % measure 6
      s1														| % measure 7
      s1														| % measure 8

      s1														| % measure 9
      s1														| % measure 10

      \repeat volta 2 {
	b'1														| % measure 11
	s1														| % measure 12
	s1														| % measure 13
	s1														| % measure 14

	s1														| % measure 15
	s1														| % measure 16
	s1														| % measure 17
	s1														| % measure 18

	e1														| % measure 19
	s1														| % measure 20
	s1														| % measure 21
	s1														| % measure 22

	s1														| % measure 23
	b1:7														| % measure 24
	s1														| % measure 25

	s1														| % measure 26
	s1														| % measure 27
	s1														| % measure 28
	s1														| % measure 29
      }

      s1														| % measure 30
      s1														| % measure 31
      s1														| % measure 32
      s1														| % measure 33

      s1														| % measure 34
      s1														| % measure 35
      e1														| % measure 36
    }
  }
}

melody_part = {
  \transpose c c {
    \key e \major
    \clef treble

    \relative {
      <<
	\new StaffGroup
	<<
	  \new Staff \with {
	    \remove "Time_signature_engraver"
	    alignAboveContext = #"cn"
	    firstClef = ##f
	  }
	  \intro_part
	  \new TabStaff \with {
	    \remove "Time_signature_engraver"
	    alignAboveContext = #"cn"
	    firstClef = ##f
	  }
	  \intro_part
	>>

	{
	  s1														| % measure 1
	  s1														| % measure 2
	  s1														| % measure 3
	  s1														| % measure 4

	  s1														| % measure 5
	  s1														| % measure 6
	  s1														| % measure 7
	  s1														| % measure 8

	  s1														| % measure 9
	  r2. b'4													| % measure 10
	}
      >>
      \break

      \repeat volta 2 {
	b4 b4 b4 b4													| % measure 11
	a4 fs4 fs4 gs4													| % measure 12
	b4 b4 b4 b4													| % measure 13
	a2
	<<
	  \new Voice = "v1" \relative { \voiceOne r2 }
	  \new Voice = "v2" \relative { \voiceTwo \magnifyMusic 0.63 { fs'4 gs4 }}
	>>														| % measure 14
	\break

	b4 b4 b4 b4													| % measure 15
	a4 fs4 fs4 gs4													| % measure 16
	b4 b4 b4 b4													| % measure 17
	a2. gs4														| % measure 18
	\break

	b4 b4 b4 cs4													| % measure 19
	b4 gs4 e4 gs													| % measure 20
	b4 b4 b4 gs4													| % measure 21
	b2 r4 fs8 gs8													| % measure 22
	\break

	b4 b4 b4 gs4													| % measure 23
	a4 a4 a4 fs4													| % measure 24
	gs4 gs4 gs4 fs4													| % measure 25
	\break

	<<
	  \new StaffGroup
	  <<
	    \new Staff \with {
	      \remove "Time_signature_engraver"
	      alignBelowContext = #"vo"
	      firstClef = ##f
	    }
	    \transpose c c' {
	      \riff_part
	    }
	    \new TabStaff \with {
	      \remove "Time_signature_engraver"
	      alignBelowContext = #"vo"
	      firstClef = ##f
	    }
	    \riff_part
	  >>

	  {
	    e2. r4													| % measure 26
	    r1														| % measure 27
	    r1														| % measure 28
	    r1														| % measure 29
	  }
	>>
      }
      \break

      <<
	\new StaffGroup
	<<
	  \new Staff \with {
	    \remove "Time_signature_engraver"
	    alignBelowContext = #"vo"
	    firstClef = ##f
	  }
	  \outro_part
	  \new TabStaff \with {
	    \remove "Time_signature_engraver"
	    alignBelowContext = #"vo"
	    firstClef = ##f
	  }
	  \outro_part
	>>

	{
	  s1														| % measure 30
	  s1														| % measure 31
	  s1														| % measure 32
	  s1														| % measure 33

	  s1														| % measure 34
	  s1														| % measure 35
	  s1														| % measure 36
	}
      >>
    }
  }
}

verse_one_part = \lyricmode {
  % Note: We have to omit some bar-checks.  This occurs when we tie
  % across a bar line, or when the next measure begins with a rest.
  ""1															| % measure 1
  ""1															| % measure 2
  ""1															| % measure 3
  ""1															| % measure 4

  ""1															| % measure 5
  ""1															| % measure 6
  ""1															| % measure 7
  ""1															| % measure 8

  ""1															| % measure 9
  ""2 ""4 Long														| % measure 10

  dis- tance, in- for-													| % measure 11
  ma- tion, Give me													| % measure 12
  Mem- phis, Ten- nes-													| % measure 13
  see. "" "" ""														| % measure 14

  Help me find the													| % measure 15
  par- ty trying to													| % measure 16
  get in touch with													| % measure 17
  me.2. She4														| % measure 18

  could not leave her													| % measure 19
  num- ber, but I													| % measure 20
  know who placed the													| % measure 21
  call2 ""4 'cause8 my													| % measure 22

  un-4 cle took the													| % measure 23
  mes- sage and he													| % measure 24
  wrote it on the													| % measure 25
  wall.2. ""4														| % measure 26

  ""1															| % measure 27
  ""1															| % measure 28
  ""1															| % measure 29
  ""1															| % measure 30

  ""1															| % measure 31
  ""1															| % measure 32
  ""1															| % measure 33
  ""1															| % measure 33

  ""1															| % measure 34
  ""1															| % measure 35
  ""1															| % measure 36
}

verse_two_part = \lyricmode {
  % Note: We have to omit some bar-checks.  This occurs when we tie
  % across a bar line, or when the next measure begins with a rest.
  ""1															| % measure 1
  ""1															| % measure 2
  ""1															| % measure 3
  ""1															| % measure 4

  ""1															| % measure 5
  ""1															| % measure 6
  ""1															| % measure 7
  ""1															| % measure 8

  ""1															| % measure 9
  ""1															| % measure 10

  Help4 me, in- for-													| % measure 11
  ma- tion, get in													| % measure 12
  touch with my Ma-													| % measure 13
  rie.2  She's4 the													| % measure 14

  on- ly one who'd													| % measure 15
  call me here from													| % measure 16
  Mem- phis Ten- nes													| % measure 17
  see.2. Her4														| % measure 18

  home is on the													| % measure 19
  south2 side,														| % measure 20
  high4 up on a														| % measure 21
  ridge,2 ""														| % measure 22

  just4 a half a													| % measure 23
  mile2 from4 the													| % measure 24
  Mis- sis- sip- pi													| % measure 25
  Bridge. ""4														| % measure 26

  ""1															| % measure 27
  ""1															| % measure 28
  ""1															| % measure 29
  ""1															| % measure 30

  ""1															| % measure 31
  ""1															| % measure 32
  ""1															| % measure 33
  ""1															| % measure 33

  ""1															| % measure 34
  ""1															| % measure 35
  ""1															| % measure 36
}

verse_three_part = \lyricmode {
  % Note: We have to omit some bar-checks.  This occurs when we tie
  % across a bar line, or when the next measure begins with a rest.
  ""1															| % measure 1
  ""1															| % measure 2
  ""1															| % measure 3
  ""1															| % measure 4

  ""1															| % measure 5
  ""1															| % measure 6
  ""1															| % measure 7
  ""1															| % measure 8

  ""1															| % measure 9
  ""1															| % measure 10

  Last2 time4 I														| % measure 11
  saw Ma- rie, she's													| % measure 12
  wav- ing me good-													| % measure 13
  by.2  ""4 With													| % measure 14

  hur- ry home drops													| % measure 15
  on her cheek that													| % measure 16
  trick- l'd from her													| % measure 17
  eye.2. But4														| % measure 18

  we were pulled a-													| % measure 19
  part, be- cause her													| % measure 20
  Mom did not a-													| % measure 21
  gree,2 ""4 and8 ""8													| % measure 22

  tore4 a- part our													| % measure 23
  hap- py home in													| % measure 24
  Mem- phis Ten- nes-													| % measure 25
  see.2. ""4														| % measure 26

  ""1															| % measure 27
  ""1															| % measure 28
  ""1															| % measure 29
  ""1															| % measure 30

  ""1															| % measure 31
  ""1															| % measure 32
  ""1															| % measure 33
  ""1															| % measure 33

  ""1															| % measure 34
  ""1															| % measure 35
  ""1															| % measure 36
}

verse_four_part = \lyricmode {
  % Note: We have to omit some bar-checks.  This occurs when we tie
  % across a bar line, or when the next measure begins with a rest.
  ""1															| % measure 1
  ""1															| % measure 2
  ""1															| % measure 3
  ""1															| % measure 4

  ""1															| % measure 5
  ""1															| % measure 6
  ""1															| % measure 7
  ""1															| % measure 8

  ""1															| % measure 9
  ""1															| % measure 10

  Help4 me, in- for-													| % measure 11
  ma- tion, more than													| % measure 12
  that I can- not													| % measure 13
  add,2 ""2														| % measure 14

  On-4 ly that I													| % measure 15
  miss her2 and4													| % measure 16
  all the fun we													| % measure 17
  had.2. Ma-4														| % measure 18

  rie is on- ly														| % measure 19
  six years old,2													| % measure 20
  in-4 for- ma- tion,													| % measure 21
  please,2 ""2														| % measure 22

  try4 to put me													| % measure 23
  through to her in													| % measure 24
  Mem- phis Ten- nes-													| % measure 25
  see.2. ""4														| % measure 26

  ""1															| % measure 27
  ""1															| % measure 28
  ""1															| % measure 29
  ""1															| % measure 30

  ""1															| % measure 31
  ""1															| % measure 32
  ""1															| % measure 33
  ""1															| % measure 33

  ""1															| % measure 34
  ""1															| % measure 35
  ""1															| % measure 36
}

solo_part = {
    \tempo 4 = 180
    \time 2/2
    \key e \major
    \clef "treble_(8)"

  \relative {

    \set doubleSlurs = ##f
    \set fingeringOrientations = #'(up)
    \set glissandoMap = #'()

    \mark \markup
    {
      \left-column {
	"Solo - play between 2nd and 3rd verses."
	" "
	" "
	" "
      }
    }

    \repeat percent 4 {
      \grace < a\4-3 cs\3-2 fs\2-1 a\1-4 >8 \glissando < b\4-3 ds\3-2 gs\2-1 b\1-4 >4 < b\4-3 ds\3-2 gs\2-1 b\1-4 >4
      \grace < a\4-3 cs\3-2 fs\2-1 a\1-4 >8 \glissando < b\4-3 ds\3-2 gs\2-1 b\1-4 >4 < b\4-3 ds\3-2 gs\2-1 b\1-4 >4	| % measure 1 / 3

      \grace < b\4-3 ds\3-2 gs\2-1 b\1-4 >8 \glissando < a\4-3 cs\3-2 fs\2-1 a\1-4 >4 < a\4-3 cs\3-2 fs\2-1 a\1-4 >4
      < a\4-3 cs\3-2 fs\2-1 a\1-4 >4 < a\4-3 cs\3-2 fs\2-1 a\1-4 >8 < a\4-3 cs\3-2 fs\2-1 a\1-4 >8			| % measure 2 / 4
    }
    \break

    \repeat percent 2 {
      \grace < d\4-3 fs\3-2 b\2-1 d\1-4 >8 \glissando < e\4-3 gs\3-2 cs\2-1 e\1-4 >4 < e\4-3 gs\3-2 cs\2-1 e\1-4 >4
      \grace < d\4-3 fs\3-2 b\2-1 d\1-4 >8 \glissando < e\4-3 gs\3-2 cs\2-1 e\1-4 >4 < e\4-3 gs\3-2 cs\2-1 e\1-4 >4	| % measure 9 / 11

      \grace < e\4-3 gs\3-2 cs\2-1 e\1-4 >8 \glissando < d\4-3 fs\3-2 b\2-1 d\1-4 >4 < d\4-3 fs\3-2 b\2-1 d\1-4 >4
      < d\4-3 fs\3-2 b\2-1 d\1-4 >4 < d\4-3 fs\3-2 b\2-1 d\1-4 >8 < d\4-3 fs\3-2 b\2-1 d\1-4 >8				| % measure 10 / 12
    }

    \grace < a\4-3 cs\3-2 fs\2-1 a\1-4 >8 \glissando < b\4-3 ds\3-2 gs\2-1 b\1-4 >4 < b\4-3 ds\3-2 gs\2-1 b\1-4 >4
    \grace < a\4-3 cs\3-2 fs\2-1 a\1-4 >8 \glissando < b\4-3 ds\3-2 gs\2-1 b\1-4 >4 < b\4-3 ds\3-2 gs\2-1 b\1-4 >4	| % measure 13

    \grace < b\4-3 ds\3-2 gs\2-1 b\1-4 >8 \glissando < a\4-3 cs\3-2 fs\2-1 a\1-4 >4 < a\4-3 cs\3-2 fs\2-1 a\1-4 >4
    < a\4-3 cs\3-2 fs\2-1 a\1-4 >4 < a\4-3 cs\3-2 fs\2-1 a\1-4 >8 < a\4-3 cs\3-2 fs\2-1 a\1-4 >8			| % measure 14
    \break

    \grace < a\4-3 cs\3-2 fs\2-1 a\1-4 >8 \glissando < b\4-3 ds\3-2 gs\2-1 b\1-4 >4 < b\4-3 ds\3-2 gs\2-1 b\1-4 >4
    \grace < b\4-3 ds\3-2 gs\2-1 b\1-4 >8 \glissando < a\4-3 cs\3-2 fs\2-1 a\1-4 >4 < a\4-3 cs\3-2 fs\2-1 a\1-4 >4	| % measure 15

    < e,\6 b'\5-1 >4 < e\6 b'\5-1 >4 < e\6 cs'\5-3 >4 < e\6 cs'\5-3 >4							| % measure 16

    < e\6 d'\5-4 >4 < e\6 d'\5-4 >4
    < e\6 cs'\5-3 >4 \tuplet 3/2 { \bendOn ( < e'\4-1 >8 ) ( < eqs\4-1 >8 ) ( < e\4-1 >8 ) \bendOff }			| % measure 17

    < e,\6 b'\5-1 >4 < e\6 b'\5-1 >4 < e\6 cs'\5-3 >4 < e\6 cs'\5-3 >4							| % measure 18

    < e\6 d'\5-4 >4 < e\6 d'\5-4 >4 < e\6 cs'\5-3 >4 r4									| % measure 19
  }
}


\book {
  \paper {
    #(set-paper-size "arch a")

    system-system-spacing = #'((basic-distance . 0.1) (padding . 4))

    indent = 0
    ragged-right = ##f
    ragged-bottom = ##f
    ragged-last-bottom= ##t
  }

  \score {
    <<
      \new ChordNames = "cn"	\chord_part
      \new Voice = "vo"		\melody_part
      \new Lyrics		\verse_one_part
      \new Lyrics		\verse_two_part
      \new Lyrics		\verse_three_part
      \new Lyrics		\verse_four_part

    >>
    \layout {
      % #(layout-set-staff-size 16)
      \omit Voice.StringNumber
      \context {
	\Staff \RemoveAllEmptyStaves
      }
    }
    \midi { }
  }

  \pageBreak

  \score {
    <<
      \new Voice { \solo_part }
      \new TabStaff { \solo_part }
    >>
    \layout {
      % #(layout-set-staff-size 16)
      \omit Voice.StringNumber
      \context {
	\Staff \RemoveAllEmptyStaves
      }
    }
    \midi { }
  }

}

\version "2.23.8" % absolutely necessary!

\header {
  snippet-title = "Guitar string bending notation"
  snippet-author = "Marc Hohl"
  snippet-source = "http://code.google.com/p/lilypond/issues/detail?id=1196";
  snippet-description = \markup {
    This snippet allows to typeset bend symbols -
    typically used on guitar - on Staff and TabStaff.
    While issue 1196 aims to create a specific engraver
    for bends, this snippet leverages the slur engraver.
  }
  % add comma-separated tags to make searching more effective:
  tags = "guitar, bend, string bending"
  % is this snippet ready?  See meta/status-values.md
  status = "buggy"
}

% TODO:
% - draw dashed line for \holdBend
% - enable consecutive bend ups
% - simplify \preBend and \holdBend usage
% - ...

#(display "\nbend.ly ─ 2011-03-11 (revised: 2013-07-16)\n\n")

%%% sizes and values (to be changed/adapted):

#(define bend-line-thickness 0.1)

#(define bend-arrow-curvature-factor 0.35)

#(define y-distance-from-tabstaff-to-arrow-tip 2.75)

#(define consecutive-bends-arrow-height 2.75)

#(define bend-arrowhead-height 1.25)

#(define bend-arrowhead-width 0.8)

#(define y-distance-from-staffline-to-arrow 0.35)

%%% internal commands
#(define (quarterdiff->string quarterdiff)
   (let ((wholesteps (floor (/ quarterdiff 4))))

     (string-append (case wholesteps
                      ((0) "")
                      (else (number->string wholesteps)))
       (case (modulo quarterdiff 4)
         ((1) "¼")
         ((2) "½")
         ((3) "¾")
         (else "")))))

%%% markup commands

#(define-markup-command (pointedSlur layout props thickness bx by mx my ex ey)
   (number? number? number? number? number? number? number?)
   (interpret-markup layout props
     (markup #:postscript
       (ly:format "~f setlinewidth
                        ~f ~f moveto
                        ~f ~f lineto
                        ~f ~f lineto stroke" thickness bx by mx my ex ey))))

#(define-markup-command (drawBendArrow layout props
                          thickness begin-x middle-x end-x begin-y end-y 
arrow-lx arrow-rx arrow-y outstring)
   (number? number? number? number? number? number? number? number? number? 
string?)
   (interpret-markup layout props
     (markup #:postscript
       (ly:format "~f setlinewidth
                        ~f ~f moveto
                        ~f ~f lineto
                        ~f ~f ~f ~f ~f ~f curveto
                        stroke
                        ~f ~f moveto
                        ~f ~f lineto
                        ~f ~f lineto
                        closepath fill"
thickness
begin-x begin-y
middle-x begin-y
middle-x begin-y end-x begin-y end-x arrow-y
arrow-lx arrow-y
end-x end-y
arrow-rx arrow-y)
       #:hspace 0
       #:translate (cons (- end-x 1.2) (+ end-y 0.5))
       #:fontsize -2
       #:bold
       ;; changed:
       ;#:center-column (outstring)
       outstring
       )))
#(define-markup-command (drawHoldBendWithArrow layout props
                          thickness begin-x begin-y end-x end-y arrow-lx 
arrow-rx arrow-y outstring)
   (number? number? number? number? number? number? number? number? string?)
   (interpret-markup layout props
     (markup #:postscript
       (ly:format "~f setlinewidth
                        ~f ~f moveto
                        ~f ~f lineto
                        stroke
                        ~f ~f moveto
                        ~f ~f lineto
                        ~f ~f lineto
                        closepath fill
                        ~f ~f moveto
                        ~f ~f lineto
                        stroke"
thickness
begin-x begin-y
begin-x arrow-y
arrow-lx arrow-y
begin-x end-y
arrow-rx arrow-y
begin-x end-y
end-x end-y)
       #:hspace 0
       #:translate (cons (- begin-x 1.2) (+ end-y 0.5))
       #:fontsize -2
       ;; Why does it work here??
       #:bold #:center-column (outstring))))

#(define-markup-command (drawHoldBendArrowOnly layout props
                          thickness begin-x begin-y end-x end-y arrow-lx 
arrow-rx arrow-y outstring)
   (number? number? number? number? number? number? number? number? string?)
   (interpret-markup layout props
     (markup #:postscript
       (ly:format "~f setlinewidth
                        ~f ~f moveto
                        ~f ~f lineto
                        stroke
                        ~f ~f moveto
                        ~f ~f lineto
                        ~f ~f lineto
                        closepath fill"
thickness
begin-x begin-y
begin-x arrow-y
arrow-lx arrow-y
begin-x end-y
arrow-rx arrow-y)
       #:hspace 0
       #:translate (cons (- begin-x 1.2) (+ end-y 0.5))
       #:fontsize -2
       ;; Why does it work here??
       #:bold #:center-column (outstring))))

%% The markup-command 'draw-dashed-line' was implemented with version 2.17.x
%% TODO: use 'draw-dashed-line' instead. See also 'tie::draw-hold-bend' below.
#(define-markup-command (drawDashedLine layout props
                          thickness begin-x end-x line-y)
   (number? number? number? number?)
   ;; TODO: draws a full line instead of a dashed line
   (interpret-markup layout props
     (markup #:postscript
       (ly:format "~f setlinewidth
                        ~f ~f moveto
                        ~f ~f lineto
                        stroke"
thickness begin-x line-y end-x line-y))))

%%% callbacks

#(define (slur::draw-pointed-slur grob)
   (let* ((control-points (ly:grob-property grob 'control-points))
          (direction (ly:grob-property grob 'direction))
          (first-point (car control-points))
          (second-point (cadr control-points))
          (third-point (caddr control-points))
          (forth-point (cadddr control-points))
          (first-x (+ (car first-point) 0.125)) ;; due to David's proposals
          (first-y (cdr first-point))
          (second-x (car second-point))
          (second-y (cdr second-point))
          (third-x (car third-point))
          (third-y (cdr third-point))
          (forth-x (- (car forth-point) 0.125))
          (forth-y (cdr forth-point))

          (middle-x (/ (+ third-x second-x) 2))
          (middle-y (/ (+ third-y second-y) 2)))

     (grob-interpret-markup grob
       (make-pointedSlur-markup bend-line-thickness
         first-x first-y middle-x middle-y forth-x forth-y))))

#(define (slur::draw-bend-arrow grob)
   (let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
          (line-count (ly:grob-property staff-symbol 'line-count))
          (staff-space (ly:grob-property staff-symbol 'staff-space))
          (left-bound (ly:spanner-bound grob LEFT))
          (right-bound (ly:spanner-bound grob RIGHT))
          (left-tab-note-head (ly:grob-property left-bound 'cause))
          (right-tab-note-head (ly:grob-property right-bound 'cause))
          (control-points (ly:grob-property grob 'control-points))
          (left-point (car control-points))
          ;;changed: cadddr changed to last
          (right-point (last control-points))
          (left-pitch  (ly:event-property (event-cause left-bound) 'pitch))
          (right-pitch (ly:event-property (event-cause right-bound) 'pitch))
          (quarterdiff (- (ly:pitch-quartertones right-pitch)
                         (ly:pitch-quartertones left-pitch)))
          (begin-x (car left-point))
          (begin-y (+ (* (/ (ly:grob-property left-tab-note-head 
'staff-position) 2)
                        staff-space)
                     y-distance-from-staffline-to-arrow))
          ;; cdr left-point doesn't work, because invisible stems are included
          (end-x (car right-point))
          (end-y (+ (* (/ (- line-count 1) 2) staff-space) 
y-distance-from-tabstaff-to-arrow-tip))
          (arrow-lx (- end-x (/ bend-arrowhead-width 2)))
          (arrow-rx (+ end-x (/ bend-arrowhead-width 2)))
          (arrow-y (- end-y bend-arrowhead-height))
          (middle-x (+ begin-x (* bend-arrow-curvature-factor (- end-x 
begin-x))))
          (bend-amount (quarterdiff->string quarterdiff)))

     (if (< quarterdiff 0)
         ;; bend down
         (let* ((y-offset (cdr (ly:grob-extent left-tab-note-head 
left-tab-note-head Y)))
                (temp begin-y))
           (set! begin-y end-y) ;; swap begin-y/end-y
           (set! end-y (+ temp y-offset))
           (set! arrow-y (+ end-y bend-arrowhead-height))
           (set! bend-amount "")
           (ly:grob-set-property! right-tab-note-head 'display-cautionary #t)
           (ly:grob-set-property! right-tab-note-head 'stencil 
tab-note-head::print))
         ;; bend up
         (let* ((x-offset (/ (cdr (ly:grob-extent left-tab-note-head 
left-tab-note-head X))
                            2)))

           (set! begin-x (+ begin-x x-offset))
           (ly:grob-set-property! right-tab-note-head 'transparent #t)))

     ;; draw resulting bend arrow
     (grob-interpret-markup grob
       (make-drawBendArrow-markup
        bend-line-thickness
        begin-x middle-x end-x begin-y end-y
        arrow-lx arrow-rx arrow-y
        bend-amount))))


#(define (slur::draw-shifted-bend-arrow grob)
   (let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
          (line-count (ly:grob-property staff-symbol 'line-count))
          (staff-space (ly:grob-property staff-symbol 'staff-space))
          (left-bound (ly:spanner-bound grob LEFT))
          (right-bound (ly:spanner-bound grob RIGHT))
          (left-tab-note-head (ly:grob-property left-bound 'cause))
          (right-tab-note-head (ly:grob-property right-bound 'cause))
          (control-points (ly:grob-property grob 'control-points))
          (left-point (car control-points))
          (right-point (cadddr control-points))
          (left-pitch  (ly:event-property (event-cause left-bound) 'pitch))
          (right-pitch (ly:event-property (event-cause right-bound) 'pitch))
          (quarterdiff (- (ly:pitch-quartertones right-pitch)
                         (ly:pitch-quartertones left-pitch)))
          (begin-x (car left-point))
          (begin-y (+ (* (/ (ly:grob-property left-tab-note-head 
'staff-position) 2)
                        staff-space)
                     y-distance-from-tabstaff-to-arrow-tip))
          ;; cdr left-point doesn't work, because invisible stems are included
          (end-x (car right-point))
          (end-y (+ (* (/ (- line-count 1) 2) staff-space) 
y-distance-from-tabstaff-to-arrow-tip consecutive-bends-arrow-height))
          (arrow-lx (- end-x (/ bend-arrowhead-width 2)))
          (arrow-rx (+ end-x (/ bend-arrowhead-width 2)))
          (arrow-y (- end-y bend-arrowhead-height))
          (middle-x (+ begin-x (* bend-arrow-curvature-factor (- end-x 
begin-x))))
          (bend-amount (quarterdiff->string quarterdiff)))
     (if (< quarterdiff 0)
         ;; bend down
         (let* ((y-offset (cdr (ly:grob-extent left-tab-note-head 
left-tab-note-head Y)))
                (temp begin-y))

           (set! begin-y end-y) ;; swap begin-y/end-y
           (set! end-y (+ temp y-offset))
           (set! arrow-y (+ end-y bend-arrowhead-height))
           (set! bend-amount "")
           (ly:grob-set-property! right-tab-note-head 'stencil
             (lambda (grob) (parenthesize-tab-note-head grob))))
         ;; bend up
         (ly:grob-set-property! right-tab-note-head 'transparent #t))
     ;; draw resulting bend arrow
     (grob-interpret-markup grob
       (make-drawBendArrow-markup
        bend-line-thickness
        begin-x middle-x end-x begin-y end-y
        arrow-lx arrow-rx arrow-y
        bend-amount))))

#(define (slur::draw-pre-bend-hold grob)
   (let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
          (line-count (ly:grob-property staff-symbol 'line-count))
          (staff-space (ly:grob-property staff-symbol 'staff-space))
          (left-bound (ly:spanner-bound grob LEFT))
          (right-bound (ly:spanner-bound grob RIGHT))
          (left-tab-note-head (ly:grob-property left-bound 'cause))
          (right-tab-note-head (ly:grob-property right-bound 'cause))
          (control-points (ly:grob-property grob 'control-points))
          (left-point (car control-points))
          (right-point (cadddr control-points))
          (left-pitch  (ly:event-property (event-cause left-bound) 'pitch))
          (right-pitch (ly:event-property (event-cause right-bound) 'pitch))
          (quarterdiff (- (ly:pitch-quartertones right-pitch)
                         (ly:pitch-quartertones left-pitch)))
          (begin-x (car left-point))
          (y-offset (cdr (ly:grob-extent left-tab-note-head left-tab-note-head 
Y)))
          (begin-y (+ (* (/ (ly:grob-property left-tab-note-head 
'staff-position)
                           2)
                        staff-space)
                     y-offset))
          ;; cdr left-point doesn't work, because invisible stems are included
          (end-x (car right-point))
          (end-y (+ (* (/ (- line-count 1) 2) staff-space) 
y-distance-from-tabstaff-to-arrow-tip))
          (arrow-lx (- begin-x (/ bend-arrowhead-width 2)))
          (arrow-rx (+ begin-x (/ bend-arrowhead-width 2)))
          (arrow-y (- end-y bend-arrowhead-height))
          (bend-amount (quarterdiff->string quarterdiff)))

     (ly:grob-set-property! right-tab-note-head 'transparent #t)
     ;; draw resulting bend arrow
     (grob-interpret-markup grob
       (make-drawHoldBendWithArrow-markup
        bend-line-thickness
        begin-x begin-y
        end-x end-y
        arrow-lx arrow-rx arrow-y
        bend-amount))))

#(define (slur::draw-pre-bend-only grob)
   (let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
          (line-count (ly:grob-property staff-symbol 'line-count))
          (staff-space (ly:grob-property staff-symbol 'staff-space))
          (left-bound (ly:spanner-bound grob LEFT))
          (right-bound (ly:spanner-bound grob RIGHT))
          (left-tab-note-head (ly:grob-property left-bound 'cause))
          (right-tab-note-head (ly:grob-property right-bound 'cause))
          (control-points (ly:grob-property grob 'control-points))
          (left-point (car control-points))
          (right-point (cadddr control-points))
          (left-pitch  (ly:event-property (event-cause left-bound) 'pitch))
          (right-pitch (ly:event-property (event-cause right-bound) 'pitch))
          (quarterdiff (- (ly:pitch-quartertones right-pitch)
                         (ly:pitch-quartertones left-pitch)))
          (begin-x (car left-point))
          (y-offset (cdr (ly:grob-extent left-tab-note-head left-tab-note-head 
Y)))
          (begin-y (+ (* (/ (ly:grob-property left-tab-note-head 
'staff-position)
                           2)
                        staff-space)
                     y-offset))
          ;; cdr left-point doesn't work, because invisible stems are included
          (end-x (car right-point))
          (end-y (+ (* (/ (- line-count 1) 2) staff-space) 
y-distance-from-tabstaff-to-arrow-tip))
          (arrow-lx (- begin-x (/ bend-arrowhead-width 2)))
          (arrow-rx (+ begin-x (/ bend-arrowhead-width 2)))
          (arrow-y (- end-y bend-arrowhead-height))
          (bend-amount (quarterdiff->string quarterdiff)))

     (ly:grob-set-property! right-tab-note-head 'transparent #t)
     ;; draw resulting bend arrow
     (grob-interpret-markup grob
       (make-drawHoldBendArrowOnly-markup
        bend-line-thickness
        begin-x begin-y
        end-x end-y
        arrow-lx arrow-rx arrow-y
        bend-amount))))

#(define (tie::draw-hold-bend grob)
   (let* ((staff-symbol (ly:grob-object grob 'staff-symbol))
          (line-count (ly:grob-property staff-symbol 'line-count))
          (staff-space (ly:grob-property staff-symbol 'staff-space))
          (left-tab-note-head (ly:spanner-bound grob LEFT))
          (right-tab-note-head (ly:spanner-bound grob RIGHT))
          (control-points (ly:grob-property grob 'control-points))
          (left-point (car control-points))
          (right-point (cadddr control-points))
          (begin-x (car left-point))
          (end-x (car right-point))
          (line-y (+ (* (/ (- line-count 1) 2) staff-space) 
y-distance-from-tabstaff-to-arrow-tip)))

     (ly:grob-set-property! right-tab-note-head 'transparent #t)
     (grob-interpret-markup grob
       (make-drawDashedLine-markup
        bend-line-thickness
        begin-x end-x line-y)
       ;; with 2.17.21 one could use:
       ;(make-translate-markup (cons 0 line-y)
       ;  (make-override-markup '(on . 0.3)
       ;    (make-draw-dashed-line-markup
       ;      (cons end-x 0))))
       )))

%%% music functions

bendOn =
#(define-music-function (note) (ly:music?)
#{
  \override Voice.Slur.stencil = #slur::draw-pointed-slur
  \override TabVoice.Slur.stencil = #slur::draw-bend-arrow
  $note \noBreak
#})

bendOff = {
  \revert Voice.Slur.stencil
  % \override TabVoice.Slur.stencil = #slur::draw-tab-slur
}

bendGrace =
#(define-music-function (note) (ly:music?)
   #{
     \once \override Voice.Stem.stencil = #point-stencil
     \once \override Voice.Flag.stencil = ##f
     \once \override Voice.Stem.direction = #DOWN
     \once \override Voice.Slur.direction = #UP
     \grace #note
   #})

preBendHold =
#(define-music-function (note) (ly:music?)
   #{
     \once \override TabVoice.Slur.stencil = #slur::draw-pre-bend-only
     \once \override TabStaff.Parentheses.transparent = ##t
     <>\noBeam \parenthesize #note
   #})

preBendRelease =
#(define-music-function (note) (ly:music?)
   #{
     \once \override TabVoice.Slur.stencil = #slur::draw-pre-bend-hold
     \once \override TabStaff.Parentheses.transparent = ##t
     \once \override Voice.Slur.direction = #DOWN
     <>\noBeam \parenthesize #note
   #})

holdBend =
#(define-music-function () ()
   #{
     \once \override TabVoice.Tie.stencil = #tie::draw-hold-bend
   #})

shiftBend = {
  \once \override TabVoice.Slur.stencil = #slur::draw-shifted-bend-arrow
}

Reply via email to