Product SiteDocumentation Site

12.5.8.2. The Bar-Check Symbol

The bar-check symbol tests whether a measure line is printed at that point in the music. LilyPond prints a warning if the bar-check symbol does not line up with a measure line in the score. LilyPond continues to process the music, and does not automatically change any durations.
The bar-check symbol is the pipe character, |. We recommend that you put a bar-check symbol at the end of every measure, and that you input only one measure on every line. If you follow this recommendation, you will make fewer mistakes.
This example is correct, so LilyPond will not print a warning:
\time 4/4
c4 c c c |
c4 c c c |
There are four quarter notes between each bar-check symbol, which is the right number of beats in the indicated metre.
This example is incorrect, so LilyPond will print a warning.
\time 4/4
c4 c2 c4 |
c4 c2 c |
c4 c2 c4 |
This example shows three measures of the same pattern: c4 c2 c4. The second measure is missing the last quarter-note symbol (a 4), so LilyPond outputs one quarter note followed by two half notes. The second measure is five beats, so the bar-check symbol does not coincide with the measure line after the fourth beat. LilyPond prints a warning when it reaches the bar-check symbol at the end of the second measure.
Consider this example.
\time 4/4
c2 c c c |
c4 c c c |
The first bar has four half-notes, which is twice as many beats as are allowed in one measure. A bar-check symbol only triggers a warning if it is placed where there is no bar line. Therefore, LilyPond will not print a warning for this example, even though only two of the three bar lines has a bar-line check symbol.
One mistake in a file will sometimes cause LilyPond to print multiple warnings. A bar-check symbol does not force LilyPond to insert a bar line. LilyPond continues to insert notes with the duration shown in the file. Look at the following example, and the LilyPond output.
\time 4/4
c4 c2 c4 |
c4 c2 c |
c4 c2 c4 |
Interpreting music...
example.ly:3:10: warning: barcheck failed at: 1/4
  c4 c2 c
	  |
The mistake in the second measure causes a warning at the bar-check symbol. LilyPond does not modify note durations, so the half note at the end of the second measure occupies the fourth beat of the second measure and the first beat of the third measure. The third measure is correct, with four beats, but the bar-check symbol causes a warning to be printed because LilyPond expects a bar line before the last quarter note, not after it.
You can avoid confusion if you fix the first warning, then reprocess the file before you fix other warnings. One mistake may cause many warnings.