Hello,

I thought this might be useful to put 'out there' on the user list*

A few months ago someone asked on this list how to create a page of (what were 
essentially) single-measure, two staff-line (with Clef) 'mini scores'. Used, I 
seemed to recall, for making tables of 'chords'.

I did a bit of experimenting after someone pointed out in a separate thread 
that you can put pretty much anything within a \markup construct (even another 
\score w/ \layout {} ), and that got me thinking.

So I came up with this .ly file (and pdf output attached). It's fully commented 
so that I didn't have to also write an email explaining how I had done it to 
the person who was still learning LP. It seemed to satisfy whoever it was I 
gave it to in the end and came across it today, forgetting that I was meant to 
share this if it worked.

Anyway, have fun

James

* It could be useful as an LSR snippet - but if anyone can come up with a 
simpler way of doing this let me know.

Attachment: grid_of_mini_scores.pdf
Description: grid_of_mini_scores.pdf

\version "2.15.1"

\pointAndClickOff

#(set-global-staff-size 24)

% This creates a simple grid of single measure/two staff scores (mini scores). The 'mini scores' are used within a
% \markup construct. Then by creating an 'invisible system' as a 'frame' and attaching these 'mini scores' as
% \markups to notes within the 'invisible system' it is possible to create the grid effect.
% The single 'mini score' on its own in the first line is just to show one on its own.
% By adjusting the global-staff-size and the X offset of the mini-score contruction (below) it is possible to create more or less mini-scores per line.

\paper {
  % Indent of 0\mm required to make first markup align with the measure below as without it
  % the first measure of the invisible score is indented and throws off the alignment of the first
  % mini score
  indent = 0\mm
  % This just spaces out the 'grid' evenly, top-to-bottom
  ragged-last-bottom = ##f
  % uncomment this line to remove the default LilyPond tag at the bottom of the page
  % tagline = #ff
}

  % 'musicall' is the name of the 'invisible score + \markups of the 'mini scores'' used in the final \score
  % construct at the end of the file
musicall = {

  % \textlengthOn is required to keep the horizontal spacing consistent else the 'mini scores' will collide
  % or touch each other.
  \textLengthOn

  % Each measure in the invisible score that the \markup is attached to is a semi-breve
  % the tweak moves the mini score, to the left - adjust as necessary. #-10 seems about right
  % for this page and staffsize.
  c1-\tweak #'X-offset #-10 ^\markup {

  % This is the construct of the 'mini score'. In this specific case the time-signature was not needed
  % so the \override in the mini score removes the timesignature.
    \score {
    <<
      \new Staff \relative c' {  \override Staff.TimeSignature #'stencil = ##f \clef "treble" c4 d e f }
      \new Staff \relative c' {  \override Staff.TimeSignature #'stencil = ##f \clef "bass" c4 d e f }
    >>

  % The \layout { } is required. Do not remove it.
    \layout { }
  }
}

% The manual \break just forces the number of mini scores that are horizontally spaced
% This can be placed as required and with a combination of the \tweak above, the staffsize you can create
% different sized grids of mini scores.
  \break

% The following are just a repeat of the above but with a \repeat unfold 4 + break to just show how to quickly
% create a number of mini scores...

\repeat unfold 4 { 
  c1-\tweak #'X-offset #-10 ^\markup {
    \score {
      <<
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "treble" c4 d e f }
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "bass" c4 d e f }
      >>
    \layout { }
    }
  }
} \break

\repeat unfold 4 { 
  c1-\tweak #'X-offset #-10 ^\markup {
    \score {
      <<
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "treble" c4 d e f }
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "bass" c4 d e f }
      >>
    \layout { }
    }
  }
} \break

\repeat unfold 4 { 
  c1-\tweak #'X-offset #-10 ^\markup {
    \score {
      <<
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "treble" c4 d e f }
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "bass" c4 d e f }
      >>
    \layout { }
    }
  }
} \break

\repeat unfold 4 { 
  c1-\tweak #'X-offset #-10 ^\markup {
    \score {
      <<
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "treble" c4 d e f }
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "bass" c4 d e f }
      >>
    \layout { }
    }
  }
} \break


\repeat unfold 4 { 
  c1-\tweak #'X-offset #-10 ^\markup {
    \score {
      <<
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "treble" c4 d e f }
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "bass" c4 d e f }
      >>
    \layout { }
    }
  }
} \break

\repeat unfold 4 { 
  c1-\tweak #'X-offset #-10 ^\markup {
    \score {
      <<
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "treble" c4 d e f }
        \new Staff \relative c' { \override Staff.TimeSignature #'stencil = ##f \clef "bass" c4 d e f }
      >>
    \layout { }
    }
  }
} \break

}

% This is where the grid is printed

\score {
  % include everything in the variable 'musicall' above
  \musicall

  % we now need to start to remove the components to create the 'invisible score'
  \layout {
   \context {
     \Staff

     % If you remove the clef completely then the alignment of the first mini-score is off and this puts the
     % whole grid off. So we are just going to make the clef's transparent
     \override Clef #'transparent = ##t

     % Remove the Time signature from the invisible score
     \remove "Time_signature_engraver"

     % Remove the staff lines and bar lines from the invisible score
     \remove "Staff_symbol_engraver"
    }
    \context {
      \Voice

     % Remove the semi-breve notes from the invisible score (the notes the mini scores are attached to)
      \remove "Note_heads_engraver" 
    }

    \context {
      \Score
     % Remove the bar numbers from the invisible score
      \remove "Bar_number_engraver"
    }
  }
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to