On 24/05/2020 20:35, Frédéric wrote:

Halas, my web server is under raspberry pi which has only lilypond
2.18.2. But 2.18.2 does not give a suitable output (too many natural
signs).
Try that:
\version "2.18.2"
{
   \override AccidentalCautionary.parenthesized = ##f
   \accidentalStyle teaching
   \key d \major
   d'4 fis' d' fis' d'4 fis' d' fis'
}
and you'll get a natural sign on second, third and fourth d. But it's
perfectly fine on 2.19.84.

Any possibility to install a more recent version of lilypond on
raspberry or to make it work on 2.18.2?


You could try the attached, which is the 2.20.0 source code for the teaching accidental style (+some helper functions) with one change to accommodate 2.18 syntax, i.e. the key signature is obtained from the localKeySignature context property instead of localAlterations. Thus the code does not work with Lilypond 2.20.0. Also note the override is no longer necessary.

--
Timothy Lanfear, Bristol, UK.

\version "2.18.2"

#(begin

(define (key-entry-bar-number entry)
  "Return the bar number of an entry in @code{localAlterations}
or @code {#f} if the entry does not have a bar number.
See @code{key-entry-notename} for details."
  (and (pair? (cdr entry)) (caddr entry)))

(define (key-entry-measure-position entry)
  "Return the measure position of an entry in @code{localAlterations}
or @code {#f} if the entry does not have a measure position.
See @code{key-entry-notename} for details."
  (and (pair? (cdr entry)) (cdddr entry)))

(define (key-entry-alteration entry)
  "Return the alteration of an entry in localAlterations

For convenience, returns @code{0} if entry is @code{#f}."
  (if entry
      (if (number? (cdr entry))
          (cdr entry)
          (cadr entry))
      0))

(define-public (my-teaching-accidental-rule context pitch barnum measurepos)
  "An accidental rule that typesets a cautionary accidental if it is
included in the key signature @emph{and} does not directly follow a note
on the same staff line."
  (let* ((keysig (ly:context-property context 'localKeySignature))
         (entry (find-pitch-entry keysig pitch #t #t)))
    (if (not entry)
        (cons #f #f)
        (let* ((global-entry (find-pitch-entry keysig pitch #f #f))
               (key-acc (key-entry-alteration global-entry))
               (acc (ly:pitch-alteration pitch))
               (entrymp (key-entry-measure-position entry))
               (entrybn (key-entry-bar-number entry)))
          (cons #f (not (or (equal? acc key-acc)
                            (and (equal? entrybn barnum) (equal? entrymp measurepos)))))))))
)

\layout {
  \context {
    \Score
    autoAccidentals  = #`(Staff ,my-teaching-accidental-rule)
  }
}

{
  \key d\major
  d'4 e' fis' g' a' b' cis'' d''
  d'4 fis' d' fis' d'4 fis' d' fis'
}

Reply via email to