Here is an improved version:

\version "2.19.44"

#(define (nth n l)
  (if (or (> n (length l)) (< n 0))
    (error "Index out of bounds.")
    (if (eq? n 0)
      (car l)
      (nth (- n 1) (cdr l)))))

#(define (scale-notehead scale tonic)
   (lambda (grob)
     (let ((mod-position (modulo (- (ly:grob-property grob 'staff-position)
tonic)
                               7)))
     (nth mod-position scale)
     )
   )
   )

aiken = #(list 'do 're 'miMirror 'fa 'sol 'la 'ti)
sacredHarp = #(list 'fa 'sol 'la 'fa 'sol 'la 'mi)


% Standard definitions for \aikenHeads or \sacredHarpHeads may be
% found in lilypond/usr/share/lilypond/current/ly/property-init.ly:
%
%
% aikenHeads      = \set shapeNoteStyles = ##(do re miMirror fa sol la ti)
% aikenHeadsMinor = \set shapeNoteStyles = ##(la ti do re miMirror fa sol)
% funkHeads =  \set shapeNoteStyles = ##(doFunk reFunk miFunk faFunk
solFunk laFunk tiFunk)
% funkHeadsMinor =  \set shapeNoteStyles = ##(laFunk tiFunk doFunk reFunk
miFunk faFunk solFunk)
% sacredHarpHeads = \set shapeNoteStyles = ##(fa sol la fa sol la mi)
% sacredHarpHeadsMinor = \set shapeNoteStyles = ##(la mi fa sol la fa sol)
% southernHarmonyHeads =   \set shapeNoteStyles = ##(faThin sol laThin
faThin sol laThin miThin)
% southernHarmonyHeadsMinor =  \set shapeNoteStyles = ##(laThin miThin
faThin sol laThin faThin sol)
% walkerHeads =  \set shapeNoteStyles = ##(doWalker reWalker miWalker
faWalker solFunk laWalker tiWalker)
% walkerHeadsMinor =  \set shapeNoteStyles = ##(laWalker tiWalker doWalker
reWalker miWalker faWalker solFunk)


\layout {
  \context {
    \Voice
    \consists "Ambitus_engraver"
  }
  \override AmbitusNoteHead.style = #(scale-notehead sacredHarp 2)
}

\relative {
  \sacredHarpHeads
  \clef violin
  \key d \major
  cis'4 d e fis g a b cis d
}

The \override AmbitusNoteHead.style = #(scale-notehead sacredHarp 2) now
works in the following way: It expects a scale (I predefied sacredHarp and
aiken) and a number which gives the position of the tonic root of your key
in the staff - middle line is 0, and so on; I chose d major, and using
violin clef, a d is on position 2 (two steps above the middle line).

The reason it has to be this way is, that at the time the ambitus is
printed, you know neither clef nor key signature; so it's easiest to
specify the desired graphic position of the tonic note.

Best
Lukas

2017-08-11 11:23 GMT+02:00 Barry Parsons <oulip...@gmail.com>:

> Amazing, thanks Lukas!
>
> I'll play around with this later but at first glance it looks like it
> ought to be able to do what I'd like.
>
> Regarding your point about key changes within a piece, it's luckily not
> really relevant to me since the kind of music that's written using shape
> notes almost never changes key.
>
> Cheers!
> Barry
>
>
> On 11 Aug 2017 10:07 am, "Lukas-Fabian Moser" <l...@gmx.de> wrote:
>
> Hi Barry,
>
> nevertheless, here is a working solution (derived from
> http://lilypond.org/doc/v2.18/Documentation/learning/advance
> d-tweaks-with-scheme). Beware though: The notehead style is chosen here
> on a by-sounding-pitch basis, so it has to be adapted for pieces in another
> key. But for the reasons I explained, I'm not sure that this is not
> basically "right".
>
> Of course, there certainly is a way to write a routine in such a way that
> you can give the desired style and desired key signature once while issuing
> \override AmbitusNoteHead.style = ... - the routine then rotate the note
> heads around accordingly - but this exceeds both my scheme skills and
> available time :-).
>
>
> \version "2.19.44"
>
>
> #(define (style-sacredHarp-notehead grob)
>    "Change the notehead style according to pitch class."
>    (let ((mod-position (modulo (ly:grob-property grob 'staff-position)
>                                7)))
>      (case mod-position
>        ;;   Return styles
>        ((1) 'fa)  ; for C
>        ((2) 'sol)  ; for D
>        ((3) 'la)  ; for E
>        ((4) 'fa)  ; for F
>        ((5) 'sol)  ; for G
>        ((6) 'la)  ; for A
>        ((0) 'mi)  ; for B
>        )))
>
> % Standard definitions for \aikenHeads or \sacredHarpHeads may be
> % found in lilypond/usr/share/lilypond/current/ly/property-init.ly:
> %
> %
> % aikenHeads      = \set shapeNoteStyles = ##(do re miMirror fa sol la ti)
> % aikenHeadsMinor = \set shapeNoteStyles = ##(la ti do re miMirror fa sol)
> % funkHeads =  \set shapeNoteStyles = ##(doFunk reFunk miFunk faFunk
> solFunk laFunk tiFunk)
> % funkHeadsMinor =  \set shapeNoteStyles = ##(laFunk tiFunk doFunk reFunk
> miFunk faFunk solFunk)
> % sacredHarpHeads = \set shapeNoteStyles = ##(fa sol la fa sol la mi)
> % sacredHarpHeadsMinor = \set shapeNoteStyles = ##(la mi fa sol la fa sol)
> % southernHarmonyHeads =   \set shapeNoteStyles = ##(faThin sol laThin
> faThin sol laThin miThin)
> % southernHarmonyHeadsMinor =  \set shapeNoteStyles = ##(laThin miThin
> faThin sol laThin faThin sol)
> % walkerHeads =  \set shapeNoteStyles = ##(doWalker reWalker miWalker
> faWalker solFunk laWalker tiWalker)
> % walkerHeadsMinor =  \set shapeNoteStyles = ##(laWalker tiWalker doWalker
> reWalker miWalker faWalker solFunk)
>
>
> \layout {
>   \context {
>     \Voice
>     \consists "Ambitus_engraver"
>   }
>   \override AmbitusNoteHead.style = #style-sacredHarp-notehead
> }
>
> \relative {
>   \sacredHarpHeads
>   c'4 d e b'
> }
>
> 2017-08-11 10:47 GMT+02:00 Lukas-Fabian Moser <l...@gmx.de>:
>
>> Hi Barry,
>>
>> unfortunately I do not have a ready-made solution - while it's possible
>> to change the ambitus note heads to a single specific sign by issuing (for
>> example) \override AmbitusNoteHead.style = #'do in the \layout block, this
>> is not a solution since it changes both ambitus note heads at the same time
>> -, I just want to point out an inherent problem:
>> As far as I understand, \sacredHarpHeads and \aikenHeads depend on the
>> key signature chosen (in much the same way that movable do syllables do).
>> So, it's a bit dodgy to issue ambitus information using these signs since
>> the key signature might change in the course of the piece. (Strictly
>> speaking, the ambitus signs occur at a place before a key signature is
>> issued - but this slight inconsistency applies to ambitus marks in general
>> since they show note heads *left* to the first clef ever encountered by the
>> singer.)
>>
>> Best
>> Lukas
>>
>>
>> 2017-08-11 10:02 GMT+02:00 Barry Parsons <oulip...@gmail.com>:
>>
>>> Hi all,
>>>
>>> As a newbie to this wonderful software I have a slightly odd request.
>>>
>>> I set vocal music using shape notes (\sacredHarpHeads or \aikenHeads).
>>> I've recently discovered the ambitus function, which is really useful.
>>>
>>> I wonder, is it possible to add the correct shaped noteheads to the
>>> ambitus at the start of a score, instead of ordinary round noteheads?
>>>
>>> Thanks in advance,
>>> Barry
>>>
>>>
>>> _______________________________________________
>>> lilypond-user mailing list
>>> lilypond-user@gnu.org
>>> https://lists.gnu.org/mailman/listinfo/lilypond-user
>>>
>>>
>>
>
>
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to