[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Editorial accidentals
From: |
Thomas Morley |
Subject: |
Re: Editorial accidentals |
Date: |
Sun, 25 Jun 2017 10:33:41 +0200 |
2017-06-25 8:40 GMT+02:00 Menu Jacques <address@hidden>:
> Thanks Simon for the idea.
>
> I’ve defined the following Scheme function for my needs, with accidental
> style forced to ‘forget' for the given note:
>
> editorialAccidental =
> #(define-music-function
> (note)
> (ly:music?)
> #{
> \once\accidentalStyle forget
> \once\set suggestAccidentals = ##t
> #note
> #})
>
> {
> \editorialAccidental cis4
> cis4
> dis4
> \editorialAccidental cis4
> }
>
> JM
Hi Jaques,
while calling a variable, here 'note', in embedded lily-code, i.e. in
#{ ... #}, always use $note not #note.
Doing something with #note destructively changes 'note', so you can't
access the unchanged 'note' anymore.
Working on $note works on a copy of 'note' so you still have access to
the original 'note'.
To illustrate:
In the scheme-sandbox, i.e. after having done in terminal:
lilypond scheme-sandbox
Try the following sequence:
(define xy #{ c''1 #})
(display-lily-music xy)
(display-lily-music #{ \withMusicProperty #'duration
#(ly:make-duration 2) #xy #})
(display-lily-music xy)
As opposed to:(define xyz #{ c''1 #})
(display-lily-music xyz)
(display-lily-music #{ \withMusicProperty #'duration
#(ly:make-duration 2) $xyz #})
(display-lily-music xyz)
Admittedly, you will not notice any difference in your example, it's a
minimal example, though.
In real life code you may experience some surprises under certain conditions.
Cheers,
Harm