Dear Experts,
I am working on writing my own function which combines several notes into one custom symbol (ligature).
(For the context, I now about Mensural_ligature_engraver, but I want to create something that will allow for more flexibility, as I try to engrave symbols as close to one of different manuscripts from different eras and by different hands)
My code is like:
\relative { a \customLigatura { b c d } f }
In my approach, I want to remove all the notes except the first, which will receive the ligature stencil.
I need to *remove* them, not only hide, because if they are still there, they still heavily affect the spacing in unexpected ways!
What I ask you is: how to remove notes "c" and "d" in such a way, that it would not mess up the relative mode and think, that the note "f" is calculated from the note "d" (otherwise it will be octave lower)? The function is agnostic of the pitch before and pitch after.
What I tried:
– \resetRelativeOctave
– setting to-relative-callback note property to ##f
customLigatura =
#(define-music-function
(music)
(ly:music?)
(let ((notes (list)) ; notes participating in ligature creation: pitch, duration, shape (square, punctum, obliqua, pes, )
(total-duration (make-duration-of-length (ly:music-length music))))
; get all those notes only that will form ligature's stencil
(for-some-music
(lambda (m)
(if (equal? (ly:music-property m 'name) 'NoteEvent)
(set! notes
(append notes
(list (make-music
'NoteEvent
'pitch (ly:music-property m 'pitch)
'duration (ly:music-property m 'duration)
'mensural-ligature-shape (ly:music-property m 'mensural-ligature-shape)))))
#f))
music)
#{
\once \override MensuralVoice.NoteHead.stencil = #ly:text-interface::print
\once \override MensuralVoice.NoteHead.text = \markup \translate #'(0 . -0.5) "Ligatura" % this will be my stencil.
% only the first note with new stencil must be printed
#(make-music
'NoteEvent
'duration total-duration
'pitch (ly:music-property (list-ref notes 0) 'pitch))
%{************************************************************
What goes here to trick the relative mode to think
that it must calculate the pitch from the LAST note
(and not the given note)?
something like: \countRelativeFrom d
I tried:
(ly:make-music-relative! music (ly:make-pitch
-1
(quotient
(ly:pitch-steps (ly:make-pitch 1 0))
2)))
\resetRelativeOctave #(last (music-pitches music))
************************************************************%}
#}))
% TESTS
<<
\new MensuralStaff \new MensuralVoice \relative { \clef F g,1 \ligatura { a a' c,, g''} a }
\new MensuralStaff \new MensuralVoice \relative { \clef F g,1 a a' c,, g'' a }
>>
<<
\new MensuralStaff \new MensuralVoice \relative { a1 \ligatura { b c d } f }
\new MensuralStaff \new MensuralVoice \relative { a1 b c d f }
>>