Lilypond: Why is the second chord printed below the staff - lilypond

Small snippet (Simplified example) that should show two chords on top of a staff:
someChord = \chords {
c1
}
\score {
<<
{
\someChord
\someChord
}
{
\repeat unfold 2 { r1 }
}
>>
\layout{}
}
However, the second chord is printed below the staff. Why is that?
Tested w/:
GNU LilyPond 2.22.2 (running Guile 2.2)
GNU LilyPond 2.23.7 (running Guile 2.2)
Both give the same output:

This seems to work (thanks Ole for the hint!):
someChord = \chordmode {
c1
}
\score {
<<
\new ChordNames {
\someChord
\someChord
}
{
\repeat unfold 2 { r1 }
}
>>
\layout{}
}
Result:
I'm curious why though, because the first ChordNames context was ended before the second started....

Related

Lilypond: Produce MIDI and PDF output simultaneously

When I am evoking lilypond in order to produce midi output, I comment in an empty midi block in the score block. Then, lilypond produces a midifile instead of a PDF file. I want to create both outputs simultaneously to be able to listen to the changes and see the changes in the pdf file. Is this possible? Commenting the midi block in and out becomes a bit cumbersome after a while, and an option to produce both outputs at the same time would help me a lot!
This is an example ly file to demonstrate my workflow:
\score {
\midi {} % Commented out each time I want to produce PDF
\new PianoStaff <<
\new Staff {
\key f \minor
\mp
\relative c''' {
c
}
}
\new Staff {
\relative c {
c
}
}
>>
}
As Ole V.V suggested in his comment, it is possible to create both outputs simultaneously by adding a layout block in the score block as follows:
\score {
\midi {} % Commented out each time I want to produce PDF
\layout{} % Adding this does the trick, thanks to Ole V.V's comment
\new PianoStaff <<
\new Staff {
\key f \minor
\mp
\relative c''' {
c
}
}
\new Staff {
\relative c {
c
}
}
>>
}

How to place a rest between to notes in different voices

I have this basic three-voices snippet.
\score {
<<
\new Staff {
\key a \major \time 3/8
\clef "G_8"
{
<<
{ e'4 r16 cis'' }
\\
{ a,4. }
\\
{ r8 <a cis'> <a cis'> }
>>
}
}
>>
}
The problem that i encounter is that the rest of the third voice (at the 13th line), is rendered on top of all the other notes, which makes unclear what voice it should be part of.
screenshot of the result with the rest on top
What I want to achieve is to get the rest to render between the two notes at the beginning (the A and the E), and I couldn't manage to do it with any of the \stemUp, \stemDown and \stemNeutral commands.
An approach you can take is to use the command \rest, which allows you to specify a 'note position' for the rest. E.g., if you type a'4\rest, you will create a quarter-note rest at the staff position of an A4. In your case, I think a g8\rest works well. I believe this solution is a bit more solid than using offset tweaks, since those are relative to where your rest is and changing the music can change the rest position, while the command \rest creates an absolute position.
\score {
<<
\new Staff {
\key a \major \time 3/8
\clef "G_8"
{
<<
{ e'4 r16 cis'' }
\\
{ a,4. }
\\
{ g8\rest <a cis'> <a cis'> }
>>
}
}
>>
}
Well, I don't have a global answer, but for one rest you could use \tweak:
\version "2.22.2"
\score {
<<
\new Staff {
\key a \major \time 3/8
\clef "G_8"
{
<<
{ e'4 r16 cis'' }
\\
{ a,4. }
\\
{ \tweak Y-offset -1 r8 <a cis'> <a cis'> }
>>
}
}
>>
}

Lilypond: Adjacent analysis brackets

I need several analysis bracket combinations which are rather unusual (at least I didn't find a lot help in the net). First of all I wanted overlapping analysis brackets, which I managed to achieve already. Now, what I also need is "adjacent brackets", meaning that one bracket ends on a note while on the same note another one starts. So in theory I would need this: "g4\stopGroup\startGroup". However, this results in simply one big bracket. Here is my example code, which currently has the problem that the g4 is in both voices and therefore visible twice, while it should only be there once, but both brackets should include it.
\version "2.19.61"
adjtwo = \relative c'' {
s2 g4\startGroup a b c\stopGroup d e
}
adjone = \relative c' {
\once \override HorizontalBracket #'direction = #UP
e\startGroup f g\stopGroup
}
\score {
\new Staff {
<<
\voiceOne \adjone
\voiceThree \adjtwo
>>
}
}
\layout {
\context {
\Voice
\consists "Horizontal_bracket_engraver"
}
}
Thanks for any help
Best regards
Is this what you're looking for?
\version "2.19.61"
\score {
\relative {
\override HorizontalBracket #'direction = #UP
e'\startGroup f g\stopGroup <>\startGroup a
b c\stopGroup d e
}
}
\layout {
\context {
\Voice
\consists "Horizontal_bracket_engraver"
}
}
A work around to make this, is the following:
put \starGroup and \stopGroup where you need. The unique condition is that you can not put a \stopGroup following a \startGroup. You have to put at least 1 note among their. You can put the \stopGroup after the following note, don't worry
fix the position and length of the bracket that are wrong drawn with \once \override HorizontalBracket.shorten-pair = #'(-3.0 . 1.5).
For your example, you can do the following:
adjone = \relative c' {
\once \override HorizontalBracket #'direction = #UP
e \startGroup f g \stopGroup
\once \override HorizontalBracket.shorten-pair = #'(-3.0 . 1.5)
a \startGroup b c \stopGroup d e
}
\score {
\new Staff {
<<
\voiceOne \adjone
>>
}
}
\layout {
\context {
\Voice
\consists "Horizontal_bracket_engraver"
}
}
And you get this score:
(I can not put images embed yet) Here is the link of the image: https://imgur.com/a/H1gN0wE

LilyPond: Can a double barline follow a multi-measure rest?

I have a multi-measure rest at the end of a piece, and I cannot get a final "|." barline to print. The regular single barline is used instead.
Minimal example:
\score {
\new Staff <<
\compressFullBarRests
R1*62
\bar "|."
>>
}
I'm using version 2.16; the problem exists with 2.17 as well.
This doesn't have anything to do with multi-measure rests. It doesn't work because you had used << >> (which indicate simultaneous music) instead of { } (which indicate sequential music). With << >>, all three commands (\compressFullBarRests, R1*62 and \bar "|.") are processed simultaneously, which means that \bar "|." takes place at moment 0 (at the very beginning of music), not after rests. This will work:
\score {
\new Staff {
\compressFullBarRests
R1*62
\bar "|."
}
}
This does not seem to have anything to do with the multi-measure rest - the |. bar is not printed even if you use a note instead of the multi-measure rest.
Not sure why, but this seems to do the job:
melody =
{
R1*62
\bar "|."
}
\score {
<<
\compressFullBarRests
\new Voice = "one" { \autoBeamOff \melody }
>>
}

In these Lilypond diads and triads, why do the final chords contain the wrong notes in the bass?

Why does the last chord in both of the following \score blocks not display the correct note in the bass? In the dyad, the last chord should have D in the bass. In the triad, the last chord should have F in the bass. Instead, both chords are displaying the same as the first chord in their respective \score blocks.
\version "2.14.2"
\book {
\header {
title = \markup \center-column {"Dyad, Triad Permutations"}
arranger = \markup \center-column { "Sean O'Donnell" }
}
\score {
\relative {
<bes d>1
<d bes>
}
}
\score {
\relative {
<bes d f>1
<bes f d>
<d bes f>
<d f bes>
<f bes d>
<f d bes>
}
}
}
You have to specify the octave relative to current notes. You can do so by using the comma (,) (to go lower) and an apostrophe (') (to go higher). So, in the first example, relative to the chord before you need to drop the D down an octave (and then bring the Bb back up). Likewise in the other chord, drop the F and bring the D back up. See the follow code to achieve what you want...
\version "2.14.2"
\book {
\header {
title = \markup \center-column {"Dyad, Triad Permutations"}
arranger = \markup \center-column { "Sean O'Donnell" }
}
\score {
\relative {
<bes d>1
<d, bes'>
}
}
\score {
\relative {
<bes d f>1
<bes f d>
<d bes f>
<d f bes>
<f bes d>
<f, d' bes>
}
}
}
To fully understand how note positioning works in \relative mode, please see the Pitches section of the manual here:
http://lilypond.org/doc/v2.12/Documentation/user/lilypond-learning/Simple-notation#Simple-notation
which states:
The easiest way to enter notes is by using \relative mode. In this
mode, the octave is chosen automatically by assuming the following
note is always to be placed closest to the previous note, i.e., it is
to be placed in the octave which is within three staff spaces of the
previous note.
[...]
By adding (or removing) quotes ' or commas , from the \relative c' {
command, we can change the starting octave
[...]
Relative mode can be confusing initially, but is the easiest way to
enter most melodies.
The manual page also shows code examples of working in \relative mode.