Hello Lukas, I don’t think this is a particularly good idea. Lilypond conceptually first creates data for the sementic meaning of the music (or the actual content) and have engravers turn this into graphical content.
Mapping pitches to other pitches is not a layout option, but a musical transformation and should thus be done on the music level, not the layout level. Using an engraver will mean it is hard to combine this with other musical transformations, and it will also cause order issues as soon as you have an engraver that depends on the pitch property. Cheers, Valentin Am Donnerstag, 31. August 2023, 14:35:45 CEST schrieb Lukas-Fabian Moser: > Hi Michael, > > over time, I found that doing something like this in an engraver (as > opposed to a music function) is actually much easier and conceptually > clear, in spite of the seeming difficulty of the engraver syntax. The > advantage of using an engraver being that you see the "actual" pitches > and don't have to fight with problems of \relative, \transpose and so on. > > \version "2.24.0" > > pitch-replace-dictionary = > #(list > (cons #{ c #} #{ cis #}) > (cons #{ d #} #{ des #}) > ) > > #(define (pitch-class= p q) > (and > (= (ly:pitch-notename p) (ly:pitch-notename q)) > (= (ly:pitch-alteration p) (ly:pitch-alteration q)))) > > Pitch_replace_engraver = > #(lambda (context) > (make-engraver > (listeners > ((note-event engraver event) > (let* > ((pitch (ly:event-property event 'pitch)) > (rule (assoc pitch pitch-replace-dictionary pitch-class=))) > > (if rule > (ly:event-set-property! > event 'pitch > (ly:make-pitch (ly:pitch-octave pitch) > (ly:pitch-notename (cdr rule)) > (ly:pitch-alteration (cdr rule)))))))))) > > \layout { > \context { > \Score > \consists #Pitch_replace_engraver > } > } > > \relative { > c'4 d e c8 8 > \transpose f c \relative { > f'4 g a > } > } > > This engraver can also be added to just a single score (\layout inside > \score {}) or even a single Staff or Voice. At the moment, the > replacement dictionary is global, but this could be changed if needed. > > At the moment the mechanism I chose is too crude to do replacements that > involve changing the pitch-octave (eg from c to b,). Do you need this? > > Lukas > > Am 31.08.23 um 12:53 schrieb Michael Winter via LilyPond user discussion: > > I would like to do something (hopefully simple), which is basically a > > custom find and replace for a set of notes in an entire score. > > > > For example {c cis d dis fih g aih} -> {c cis dih dis f gis a} > > > > So basically on arbitrary list of pitches / scale to another. > > > > Is this possible without writing a custom function. If not, any hints > > on how to tackle the problem would be much appreciated. Thanks in advance. > > > > -Michael
signature.asc
Description: This is a digitally signed message part.