Jump to content

Chord name exceptions: Difference between revisions

From LilyPond wiki
Import snippet from LSR
 
Improve documentation
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The property <code>chordNameExceptions</code> can be used to store a list of special notations for specific chords.
The property <code>chordNameExceptions</code> stores a list of chord name exceptions to handle cases either not covered or handled incorrectly.


<lilypond version="2.24.0">
The default chord names used by LilyPond follow the rules as given in Klaus Ignatzek's book “Die Jazzmethode für Klavier&nbsp;1”; the algorithm to convert chords to chord names can be found in file <code>scm/chord-ignatzek-names.scm</code>. Additional rules are given as chord exceptions and stored in the variable <code>ignatzekExceptions</code>, as set up in file <code>ly/chord-modifiers-init.ly</code>.
% modify maj9 and 6(add9)
 
% Exception music is chords with markups
This snippet modifies these exceptions in three steps.
 
# Set up some music with chords and associated markup.  By convention, the root (i.e., the lowest note) of each chord should have pitch&nbsp;c.
# Call Scheme function <code>sequential-music-to-chord-exceptions</code> to create a new list of exceptions, then concatenate it with the existing ones. Since <code>ignatzekExceptions</code> is set up with this function’s second parameter set to <code>#t</code> (to ignore the root of the chords), we have to do the same.
# Register the new exception list.
 
<lilypond version="2.24">
% Step 1: Define music with chords and markup for maj9 and 6(add9).
chExceptionMusic = {
chExceptionMusic = {
   <c e g b d'>1-\markup { \super "maj9" }
   <c e g b d'>-\markup { \super "maj9" }
   <c e g a d'>1-\markup { \super "6(add9)" }
   <c e g a d'>-\markup { \super "6(add9)" }
}
}


% Convert music to list and prepend to existing exceptions.
% Step 2: Create extended exception list.
chExceptions = #(append
chExceptions =
  (sequential-music-to-chord-exceptions chExceptionMusic #t)
#(append (sequential-music-to-chord-exceptions chExceptionMusic #t)
  ignatzekExceptions)
        ignatzekExceptions)


theMusic = \chordmode {
theMusic = \chordmode {
   g1:maj9 g1:6.9
   g1:maj9 g1:6.9
  % Step 3: Register extended exception list.
   \set chordNameExceptions = #chExceptions
   \set chordNameExceptions = #chExceptions
   g1:maj9 g1:6.9
   g1:maj9 g1:6.9
Line 31: Line 39:


[[Category:Chords]]
[[Category:Chords]]
[[Category:Chords]]
[[Category:Scheme]]
[[Category:Specific notation]]
[[Category:Specific notation]]
[[Category:Included in the official documentation]]
[[Category:Included in the official documentation]]
[[Category:Snippet]]

Latest revision as of 10:54, 16 December 2025

The property chordNameExceptions stores a list of chord name exceptions to handle cases either not covered or handled incorrectly.

The default chord names used by LilyPond follow the rules as given in Klaus Ignatzek's book “Die Jazzmethode für Klavier 1”; the algorithm to convert chords to chord names can be found in file scm/chord-ignatzek-names.scm. Additional rules are given as chord exceptions and stored in the variable ignatzekExceptions, as set up in file ly/chord-modifiers-init.ly.

This snippet modifies these exceptions in three steps.

  1. Set up some music with chords and associated markup. By convention, the root (i.e., the lowest note) of each chord should have pitch c.
  2. Call Scheme function sequential-music-to-chord-exceptions to create a new list of exceptions, then concatenate it with the existing ones. Since ignatzekExceptions is set up with this function’s second parameter set to #t (to ignore the root of the chords), we have to do the same.
  3. Register the new exception list.

\version "2.24"

% Step 1: Define music with chords and markup for maj9 and 6(add9).
chExceptionMusic = {
  <c e g b d'>-\markup { \super "maj9" }
  <c e g a d'>-\markup { \super "6(add9)" }
}

% Step 2: Create extended exception list.
chExceptions =
#(append (sequential-music-to-chord-exceptions chExceptionMusic #t)
         ignatzekExceptions)

theMusic = \chordmode {
  g1:maj9 g1:6.9
  % Step 3: Register extended exception list.
  \set chordNameExceptions = #chExceptions
  g1:maj9 g1:6.9
}

\layout {
  ragged-right = ##t 
}

<<
   \new ChordNames \theMusic
   \new Voice \theMusic
>>