lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Move chord name down onto staff?


From: Jean Abou Samra
Subject: Re: Move chord name down onto staff?
Date: Tue, 13 Jul 2021 09:58:12 +0200 (CEST)

> Le 13/07/2021 03:14, David Wright <lilylis@lionunicorn.co.uk> a écrit :
> 
> 
> On Mon 12 Jul 2021 at 16:54:03 (-0700), Flaming Hakama by Elaine wrote:
> > > 
> > >
> > > ---------- Forwarded message ----------
> > > From: Jean Abou Samra <jean@abou-samra.fr>
> > > To: Werner LEMBERG <wl@gnu.org>, lilypond@hillvisions.com
> > > Cc: mark@archsys.net, lilypond-user@gnu.org
> > > Bcc:
> > > Date: Mon, 12 Jul 2021 15:01:32 +0200 (CEST)
> > > Subject: Re: Move chord name down onto staff?
> > > As a matter of style, I'd do it slightly differently:
> > > \version "2.23.4"
> > > \layout {
> > > \context {
> > > \Staff
> > > \accepts ChordNames
> > > \override ChordName.Y-offset =
> > > #self-alignment-interface::y-aligned-on-self
> > > \override ChordName.self-alignment-Y = #CENTER
> > > }
> > > }
> > > harmony = \chordmode { a1:m s1 f1:m7 s1 }
> > > tune = { s1 s1 s1 s1 }
> > >
> > > \new Staff <<
> > > \tune
> > > \new ChordNames \harmony
> > > >>
> > 
> > I'd like to understand if I can use this layout-based approach on a
> > per-score basis.
> > 
> > This example, based on the previous approach, has in-staff chords for the
> > first score, but normal, above-the-staff chords for the second score.
> > 
> > 
> > How would one go about using the layout approach to do that?
> NR § 4.2.1 The \layout block
> explains how to do this. Either attach the \layout to the \score block
> or, more flexible, assign it to a variable, and reference the variable
> in the score's \layout. The examples in this section show how to
> construct the \layout block thus, and § 4.2.2 example "2." shows how
> to attach \layout to \score.
> 
> In this manner, you can combine global layout options with
> score-specific ones.
> 
> Cheers,
> David.


You could also put it in a \with block:

\version "2.23.4"

melodyHead = \relative c'' { c1 d e f }
melodyFours = \relative c'' { g8 a r g r a r4 | b8 8 r4 r2 | g8 a r g r a r4 | 
bes8 8 r4 r2 }
headChords = \chordmode {
    c1:maj7 | b2:m7.5- e:7 | a:m7 d:7 | g:m7 c:7 |
}
foursChords = \chordmode {
    c1:maj7 | b2:m7.5- e:7 | a:m7 d:7 | g:m7 c:7 |
}

chordsOnStaff = \with {
  \accepts ChordNames
  \override ChordName.Y-offset = #self-alignment-interface::y-aligned-on-self
  \override ChordName.self-alignment-Y = #CENTER
}

\book {
    \score {
        \new StaffGroup <<
            \new Staff \melodyHead
            \new Staff \with \chordsOnStaff \new ChordNames \headChords
        >>
    }
    \score {
        <<
            \new ChordNames  { \foursChords }
            \new Staff \melodyFours
        >>
    }
}


And actually, why not define a custom context type:

\version "2.23.4"

melodyHead = \relative c'' { c1 d e f }
melodyFours = \relative c'' { g8 a r g r a r4 | b8 8 r4 r2 | g8 a r g r a r4 | 
bes8 8 r4 r2 }
headChords = \chordmode {
    c1:maj7 | b2:m7.5- e:7 | a:m7 d:7 | g:m7 c:7 |
}
foursChords = \chordmode {
    c1:maj7 | b2:m7.5- e:7 | a:m7 d:7 | g:m7 c:7 |
}

\layout {
  \context {
    \Staff
    \name StaffChordNames
    \type Engraver_group
    \alias Staff
    \alias ChordNames
    \consists Chord_name_engraver
    \denies Voice
    \override ChordName.Y-offset = #self-alignment-interface::y-aligned-on-self
    \override ChordName.self-alignment-Y = #CENTER
  }
  \inherit-acceptability StaffChordNames Staff
}

\book {
    \score {
        \new StaffGroup <<
            \new Staff \melodyHead
            \new StaffChordNames \headChords
        >>
    }
    \score {
        <<
            \new ChordNames  { \foursChords }
            \new Staff \melodyFours
        >>
    }
}


Best,
Jean



reply via email to

[Prev in Thread] Current Thread [Next in Thread]