\version "2.24.3"

#(set-default-paper-size '(cons (* 210 mm) (* 5000 mm)))

#(define-public (bracket-stencils grob)
  (let ((lp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "[")))
        (rp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "]"))))
    (list lp rp)))

bracketify = #(define-music-function (arg) (ly:music?)
  (_i "Tag @var{arg} to be parenthesized.")
#{
  \tweak Parentheses.stencils #bracket-stencils
    \parenthesize $arg
#})

\header {
  tagline = #f
}

gtrOne = \relative {
  \time 4/4
  \key fis \minor
  \tempo 4 = 147
  \set Score.currentBarNumber = #0
  s2\mf s4 s8 a8 \bar ".|:"
  a8 cis8 cis8 cis'8
  cis8 fis,8 fis8 a,8 |
  a8 cis8 cis8 cis'8
  cis8 fis,8 fis8 a,8 |
  a8 cis8 cis8 b'8
  b8 fis8 fis8 a,8 |
  a8 cis8 cis8 b'8
  b8 fis8 fis8 cis8 |
  cis8 d8 d8 gis8
  gis8 d8 d8 cis8 |
  cis8 d8 d8 gis8
  gis8 d8 d8 cis8 |
  d8 e8 e8 a8
  a8 e8 e8 \bracketify d8 |
  \bracketify d8 e8 e8 a8 a8 e8 e8 a,8 | \bar ":|."
}

gtrTwoVoiceOne = \relative {
  \time 4/4
  \key fis \minor
  \tempo 4 = 147
  s1\mf \bar ".|:"
  s8 fis8 fis8 e'8 e8
  fis,8 fis8 s8 |
  s8 fis8 fis8 e'8
  e8 fis,8 fis8 s8 |
  s8 fis8 fis8 d'8 d8
  fis,8 fis8 s8 |
  s8 fis8 fis8 d'8 d8
  fis,8 fis8 s8 |
  s8 fis8 fis8 e'8 e8
  fis,8 fis8 s8 |
  s8 fis8 fis8 e'8
  e8 fis,8 fis8 s8 |
  s8 fis8 fis8 d'8 d8
  fis,8 fis8 s8 |
  s8 fis8 fis8 d'8 d8
  fis,8 fis8 s8 | \bar ":|."
}

gtrTwoVoiceTwo = \relative {
  \time 4/4
  \key fis \minor
  \tempo 4 = 147
  s2 s4 s8 fis8 \bar ".|:"
  fis8 s8 s4 s4 s8 \bracketify fis8 |
  \repeat unfold 2 { \bracketify fis8 s8 s4 s4 s8 \bracketify fis8 | }
  \bracketify fis8 s8 s4 s4 s8 fis8 |
  fis8 s8 s4 s4 s8 \bracketify fis8 |
  \bracketify fis8 s8 s4 s4 s8 \bracketify fis8 |
  \bracketify fis8 s8 s4 s4 s8 \bracketify fis8 |
  \bracketify fis8 s8 s4 s4 s8 fis8 | \bar ":|."
}

bass = \relative {
  \time 4/4
  \key fis \minor
  \tempo 4 = 147
  s2\mf s4 s8 e,,8 |
  e8 fis4.~ fis4 e8 fis8 |
  fis2 e8 fis8 a8 b8 |
  b8 d,8~ d8 a'8 d,4 cis8 d8 |
  d8 b'4.~ b8 ais4 cis,8 |
  e8 fis4.~ fis4 e8 fis8 |
  fis2 e8 fis8 a8 b8 |
  b8 d,4.~ d4 cis8 d8 |
  e2 cis2 |
}

kitOne = \drummode {
  s2\mf \grace { sn16( sn } sn) sn8 sn16 sn4 |
  \repeat percent 3 {
    hho8 hho \parenthesize hh \parenthesize hh
    <sn hh> <\parenthesize sn \parenthesize hh>16 sn hh8 \parenthesize hh |
  }
  hho4 hho hho <sn hho>8. sn16 |
  \repeat percent 3 {
    hho8 hho \parenthesize hh \parenthesize hh
    <sn hh> <\parenthesize sn \parenthesize hh>16 sn hh8 \parenthesize hh |
  }
  hho4 hho hho <sn hho>8. sn16 |
}

kitTwo = \drummode {
  s2 s4 s8 bd |
  \repeat percent 3 { bd8 bd4 \bracketify bd8 r4. bd8 | }
  bd8\< bd \bracketify bd bd \after 2 \! bd2 |
  \repeat percent 3 { bd8 bd4 \bracketify bd8 r4. bd8 | }
  bd8\< bd \bracketify bd bd \after 2 \! bd2 |
}

fullScore = <<
  \new Staff \with {
    midiInstrument = "electric guitar (clean)"
    midiPanPosition = #-1.0
  } {
    \clef "treble_8"
    \gtrOne
  }

  \new Staff \with {
    midiInstrument = "electric guitar (jazz)"
    midiPanPosition = #1.0
  } <<
    \clef "treble_8"
    \new Voice = "g2v1" { \voiceOne \gtrTwoVoiceOne }
    \new Voice = "g2v2" { \voiceTwo \gtrTwoVoiceTwo }
  >>

  \new Staff \with {
    midiInstrument = "electric bass (pick)"
    midiPanPosition = #0.0
  } {
    \clef "bass_8"
    \bass
  }

  \tag #'folded {
    \new DrumStaff \with { drumStyleTable = #weinberg-drums-style } <<
      \new DrumVoice { \voiceOne \kitOne }
      \new DrumVoice { \voiceTwo \kitTwo }
    >>
  }
  \tag #'unfolded {
    \new DrumStaff \with { drumStyleTable = #weinberg-drums-style } <<
      \new DrumVoice { \unfoldRepeats { \voiceOne \kitOne } }
      \new DrumVoice { \unfoldRepeats { \voiceTwo \kitTwo } }
    >>
  }
>>

\score {
  \removeWithTag #'unfolded
  \fullScore

  \layout {
    indent = 0
  }
}

\score {
  \removeWithTag #'folded
  \fullScore

  \midi { }
}
