lilypond-user
[Top][All Lists]
Advanced

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

Re: Adding a new accidental style


From: Thomas Morley
Subject: Re: Adding a new accidental style
Date: Sun, 14 Apr 2019 18:28:46 +0200

Am So., 14. Apr. 2019 um 17:22 Uhr schrieb Edward Lilley <address@hidden>:
>
> Dear all,
>
> I am trying extend Lilypond in Scheme to add a new accidental
> style. What I am currently stuck on is how to add a new item to the
> "accidental-styles" alist in such a way that it is visible to the
> \accidentalStyle command.
>
> I have a file called "hist-accidentals.scm" that contains the following:
>
> > (define-public (hist-accidental-rule context pitch barnum measurepos)
> >   "An accidental rule that only typesets sharps and flats, indicating
> >   relative alteration compared to the key signature."
> >   (let* ((keysig (ly:context-property context 'localAlterations))
> >   (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)))))))))
> >
> > (set! accidental-styles
> > (cons hist #f
> > (Staff ,(make-accidental-rule 'same-octave 0))
> > (Staff ,(make-accidental-rule 'same-octave 1)
> > hist-accidental-rule)))
> > accidental-styles))
>
> (currently the contents of "hist-accidental-rule" is just a copy of the
> "teaching" accidental style)
>
> At the top of the relevant lilypond file, I load the scheme file with
>
> > #(load "hist-accidentals.scm")
>
> But when I come to write
>
> > \accidentalStyle hist
>
> later on, lilypond complains with "warning: unknown accidental style:
> hist". How do I modify variables defined using "define-public"? Or, what
> should I be doing instead?
>
> Thanks,
> Edward

Hi,

please attach the file in future: From here it looks like the syntax
is messed up for brackets/semiquotes and unquotes.
It's not unheard some email-client done such things, though ...

Anyway, below should do:

(set! accidental-styles
  (cons
    `(hist #f
           (Staff ,(make-accidental-rule 'same-octave 0))
           (Staff ,(make-accidental-rule 'same-octave 1)
                  ,hist-accidental-rule))
    accidental-styles))

Cheers,
  Harm



reply via email to

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