# Why is lilypond treating this measure with 3⅓ beats?

## The problem

I'm currently working on a joke piece to learn the lilypond software and came across this unusual bug.

I currently have this in the code:

``````\clef "percussion"
c'1^\markup "scream"
\clef "treble"
\time 4/4
r1 r2 r r4 r r r r8 r r r r r r r r16 r r r r r r r r r r r r r r r r32 r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
``````

yet for some reason lilypond is not putting 4 beats per measure?

It seems to round 3 plus a single triplet note? I'm not sure why this is happening.

## Clues

A few time signatures before this I have a measure using a 4/3 time signature which uses 5 beats plus a single quarter note triplet (5⅓ beats).

The two other time signatures that appear between them I do not finish between switching to a different time signature and putting a bar line to show the difference.

I'm still not entirely sure why this happens and how to fix it. Does anybody know how? Thanks in advance.

### Edit

The problem was an overflow, and it is solved now. Thank you!

• You probably don’t need a percussion clef just to indicate the scream is unpitched. The x note head is enough. You can notate it all with the treble clef. May 4 at 22:10
• Why the Threatening Music Notation would you be producing this score in the first place? May 5 at 11:10
• @AJFaraday because most of us love music-score jokes. May 5 at 13:26

Note that 5 beats and one single quarter triplet are not 5⅓, but 5⅔.

Thus the measure does not in fact fit 4/3, but it would need 17/12. This results in missalignment in the following measures. So if you use a single eigth note triplet or a 17/12 measure this will work, as demonstrated here:

``````{
\clef "percussion"
\time 4/3
c' c' c' c' c' \tuplet 3/2 { c' }
\time 4/4
c'1^\markup "scream"
\clef "treble"
\time 4/4
r1 r2 r r4 r r r r8 r r r r r r r r16 r r r r r r r r r r r r r r r r32 r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
}

{
\clef "percussion"
\time 4/3
c'4 c' c' c' c' \tuplet 3/2 { c'8 }
\time 4/4
c'1^\markup "scream"
\clef "treble"
\time 4/4
r1 r2 r r4 r r r r8 r r r r r r r r16 r r r r r r r r r r r r r r r r32 r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
}

{
\clef "percussion"
\time 17/12
c'4 c' c' c' c' \tuplet 3/2 { c' }
\time 4/4
c'1^\markup "scream"
\clef "treble"
\time 4/4
r1 r2 r r4 r r r r8 r r r r r r r r16 r r r r r r r r r r r r r r r r32 r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
}
``````

By the way: When posting code to illustrate a problem, please make sure to post enough code to actually illustrate it. This makes helping you easier.

If you compile your code separately, you will see that it's OK (for instance, see a lilybin).

So the problem must be elsewhere. Most likely, there are mistakes in the preceding music, and they "overflow" here. The easiest way out is to use bar checks: in your source, you should put `|` at each place where a barline should occur. Lilypond then checks whether the position of `|`'s match with the actual barlines, and if not, you get a warning. For instance, if I write `\time 3/4 a2 a2 a2 a4`, I get one bar with two half-notes, and one with a single half-note (the middle one will start in the first bar and "overflow" into the other), then a new bar with a quarter note. If I, for instance wrote `\time 3/4 a2 a2 | a2 a4 |`, I get an error on the first bar, because that clarifies that I meant `a2 a2` to be a complete 3/4 bar, which it obviously is not.

For more info, have a look at the documentation. By the way, bar checks are ubiquitous in Lilypond: everybody uses them pretty much everywhere. You should too (if you want to avoid mistakes like this).

Btw., to maintain some readability in your code, you should put one bar per line. At least that's what I found to be most useful.