|
From: | Michael Winter |
Subject: | Re: function to force accidentals on a subset of notes |
Date: | Mon, 23 Oct 2023 00:47:22 +0200 (CEST) |
Hi Michael,
this is easily accomplished with an custom engraver. (I perfectly understand that the terms "easily" and "custom engraver" don't seem to go well together at first - I thought so for many years as well -, but after some getting used to it, the concept is actually quite simple and elegant.)
\version "2.24.0"forced-accidentals-pitches =#(music-pitches #{ bes b #})#(define (diatonic-pitch-class= p q)(and (= (ly:pitch-notename p) (ly:pitch-notename q))(= (ly:pitch-alteration p) (ly:pitch-alteration q))))Force_accidentals_engraver =#(lambda (context)(make-engraver(listeners((note-event engraver event)(if (member (ly:event-property event 'pitch)forced-accidentals-pitchesdiatonic-pitch-class=)(ly:event-set-property! event 'force-accidental #t))))))\layout {\context {\Voice\consists #Force_accidentals_engraver}}\transpose a c' \relative{a8 gis g fis g gis a4}Lukas
Am 21.10.23 um 11:37 schrieb Michael Winter via LilyPond user discussion:Thanks Jean,I am not sure I completely follow.Lets say I have a music sequence:a b c d e f g a bes c d e f g ...How do I apply what you have written as a function to only show the flats and naturals for b and bes. Again. I do not want to apply this to individual notes.Sorry if I am missing something.Best,MichaelOct 21, 2023, 01:37 by jean@abou-samra.fr:Try
\displayMusic c'!
This shows you that the
!
syntax corresponds to setting theforce-accidental
property to true. Thus, if you have identified the note events you want to force accidentals on, you can do(ly:music-set-property! the-note-event 'force-accidental #t)
on each of them.
Best,
Jean
[Prev in Thread] | Current Thread | [Next in Thread] |