lilypond-user
[Top][All Lists]
Advanced

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

SacredHarpHeads: possible solution to major/minor problem


From: Neil Puttock
Subject: SacredHarpHeads: possible solution to major/minor problem
Date: Tue, 22 Apr 2008 17:36:32 +0100

On 14/04/2008, Adrian Mariano <address@hidden> wrote:
> Neil Puttock wrote:
>
> > On 14/04/2008, Adrian Mariano <address@hidden> wrote:
> >
> >
> >
> > >  Sounds like there's no real alternative.  Using two commands is clean
> and
> > > simple.  I see that the other person who reported this issue proposed
> that
> > > same solution.
> > >
> > >
> >
> > There's two options I can see for this:
> >
> > 1. Add a command such as \sacredHarpHeadsMinor;
> >
> > 2. Split the command into two, i.e., \sacredHarpHeadsMajor &
> > \sacredHarpHeadsMinor.
> >
> > The first option is simplest, since there's no requirement for a
> > convert-ly rule.
> >
> >
>  I would say that the minor mode is as common as the major in Sacred Harp
> music, maybe even more common, so option #1 seems inferior to option 2,
> because it presupposes that in some sense major is an appropriate default.

As a third option, here's my attempt at a universal command which will
automatically select the correct shapeNoteStyles for \sacredHarpHeads.
Since I've only just started getting the hang of coding in scheme,
there's probably room for improvement; I welcome any comments.

sacredHarps = \applyContext #(lambda (c)
  (let* ((alts (ly:context-property c 'keySignature))
         (tonic (ly:context-property c 'tonic)))
    (if (ly:pitch? tonic)
      (begin
      (display tonic)
        (let* ((third (modulo (+ 2 (ly:pitch-notename tonic)) 7))
               (pitch (ly:make-pitch (ly:pitch-octave tonic) third (or
(ly:assoc-get third alts) NATURAL)))
               (diff (- (ly:pitch-semitones pitch) (ly:pitch-semitones tonic))))
               (display third)
               (display diff)
          (if (or (eqv? diff 4) (eqv? diff -8))
            (ly:context-set-property! c 'shapeNoteStyles #(fa #f la fa
#f la mi))
            (ly:context-set-property! c 'shapeNoteStyles #(la mi fa #f
la fa #f)))
    )))
  ))

Basically, it tests for a major third by comparing the third degree
with the tonic, then sets the shapeNoteStyles based on the result (4
or -8 semitones for a major third, depending on the degree of the
scale).

There's a slight limitation in that if the key signature changes, the
function needs to be called again to pick up the mode and set the
correct note head styles.

Also, if there's no Staff context explicitly declared, the tonic is
undefined, so the shapeNoteStyles will not be set (I tried to include
a warning for this, but can't get round the problem of MIDI output,
since it junks the tonic, resulting in a warning whenever a midi {}
block is included).

Regards,
Neil




reply via email to

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