Re: Help with correct pitch after function call within \relative

2024-01-08 Thread David Kastrup
Artur Dobija  writes:

> 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 can't figure out your function details, but assuming you have
sequential music mus that should (in \relative) follow relative rules
but only have the first note affect the sequence, you would wrap it in

(make-relative (mus) (make-music 'EventChord mus)
  ...)

This works by casting the expression to an EventChord before running it
through the \relative wringer (in case this occurs in \relative) but
making the permanent effect on \relative come from the first element.

The ... itself is never seen by \relative, only the EventChord is.  The
result can, of course, end up something that isn't a valid chord but it
is only used for passing through \relative and then thrown away.


-- 
David Kastrup



Re: Help with correct pitch after function call within \relative

2024-01-08 Thread David Kastrup
Artur Dobija  writes:

> Dear Lilypond-user,
> I sent this mail to the wrong mail, I should have send it to
> lilypond-user-requ...@gnu.org ! Sorry!

No, you sent it to the right address.  lilypond-user-request is the
address for sending list server commands.  Send it an Email with "help"
in the body and it will tell you what it can do for you.

-- 
David Kastrup



Re: Help with correct pitch after function call within \relative

2024-01-08 Thread Artur Dobija
Dear Lilypond-user,
I sent this mail to the wrong mail, I should have send it to
lilypond-user-requ...@gnu.org ! Sorry!
Best,
Artur Dobija

pon., 8 sty 2024 o 23:56 Artur Dobija  napisał(a):

> 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 }
> >>
>
> % ArturJD, Engraving Chant, https://www.instagram.com/engraving.chant/
>
>


Help with correct pitch after function call within \relative

2024-01-08 Thread Artur Dobija
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 }
>>

% ArturJD, Engraving Chant, https://www.instagram.com/engraving.chant/