lilypond-user
[Top][All Lists]
Advanced

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

Re: hymns: chords vs. voices


From: Carl Sorensen
Subject: Re: hymns: chords vs. voices
Date: Mon, 18 Jan 2010 20:39:00 -0700

mike99 <mike.brigu <at> gmail.com> writes:

> 
> 
> Carl Sorensen-3 wrote:
> 
> This does work, though I found another limitation. Because you have to place
> the note head about one staff space down in order to avoid horizontal
> displacement of the phantom note head, the stem protrudes further down (or
> up, as the case may be) than normal.

I've now made a music function that takes care of this problem, as well as
the ledger lines.  Here it is in the form of a hymn template.

%%%%%%
#(define (add-offset-note note offset accidental)
    (let* ((chord-elements (ly:music-property note 'elements))
           (chord-note (car chord-elements))
           (new-note (ly:music-deep-copy chord-note))
           (note-pitch (ly:music-property chord-note 'pitch))
           (note-scale (ly:pitch-notename note-pitch))
           (new-scale (remainder (+ note-scale offset) 7))
           (new-pitch (ly:make-pitch -1 new-scale accidental))
           (my-tweaks (ly:music-property new-note 'tweaks)))
      (ly:music-set-property! new-note 'pitch new-pitch)
      (ly:music-set-property! new-note
                              'tweaks
                                (cons (cons 'transparent #t)
                                      my-tweaks))
      (ly:music-set-property! note
                              'elements
                              (list chord-note new-note))
      note))

% accidental is a rational number used to shift the hidden note
% used to create the second stem in order to avoid an accidental
% It is a fraction; 1/2 is a standard sharp; -1/2 is a standard
% flat.

addSecondStem =
#(define-music-function (parser location interval accidental note)
    (integer? number? ly:music?)
    (define new-note (add-offset-note note interval accidental))
#{
   \once \override NoteHead #'no-ledgers = ##t
   \once \override Stem #'length =
        #(lambda (grob) (- (ly:stem::calc-length grob) 1))
   $new-note
#})

soprano =  \relative c'' {
  a a \addSecondStem #2 #0 c \addSecondStem #2 #0 b |
  \addSecondStem #2 #0 c a' g \addSecondStem #2 #0 f |
}

alto = \relative c' {
  c \addSecondStem #-2 #1/2 a' c b |
  c \addSecondStem #-2 #1/2 a' \addSecondStem #-2 #0 g f |
}

tenor = \relative c' {
  g g g \addSecondStem #2 #0 d |
  g d d g
}

bass = \relative c {
  d d d d |
  g, g g \addSecondStem #-2 #0 g'
}

verseOne = \lyricmode {
  \set stanza = #"1."
  This is verse one
  It is more fun
}

verseTwo = \lyricmode {
  \set stanza = #"2."
  This is verse two
  It's good for you
}



\score {
  \new ChoirStaff <<
    \new Staff {
      \key d \major
      <<
        \new Voice = "hiddenSoprano" {
          \transpose c c' {
            \hideNotes
            \override Slur #'transparent = ##t
            % uncomment the next line to eliminate clashing note-column
            % warnings, but accidental and lyric spacing may be off
            %\shiftOnn
            \soprano
          }
        }
        \new Voice = "upper" {
          \partcombine \soprano \alto
        }
      >>
    }
    \new Lyrics \lyricsto "hiddenSoprano" { \verseOne }
    \new Lyrics \lyricsto "hiddenSoprano" { \verseTwo }
    \new Staff {
       \key c \major
       \clef bass {
         \partcombine \tenor \bass
       }
     }
  >>

}
%%%%%%%%%%%%%%
> 
> So far, so good; this is a viable alternative. Again, thanks for your
> help... this is fun.

You're welcome.  Actually, I've been bugged by this on my hymns, but never
decided to take the time to fix it.  I'm going to be happier now that I can
get the dual stems where I want them.

Thanks,

Carl






reply via email to

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