Am Mi., 17. Juli 2024 um 11:02 Uhr schrieb Werner LEMBERG <w...@gnu.org>:
>
>
> >> ```
> >> \version "2.25.18"
> >>
> >> foo =
> >> #(define-music-function () ()
> >>   #{
> >>     <<
> >>       c'4
> >>       \new Voice { g''4 }
> >>     >>
> >>   #})
> >>
> >> {
> >>  \override Staff.NoteColumn.ignore-collision = ##t
> >>   c'4 \foo \stemUp \foo \stemDown \foo
> >> }
> >> ```
> >>
> >> As can be seen, the `\new Voice` doesn't react to `\stemUp` and
> >> `\stemDown`.  Is there a way to fix this, maybe by 'cloning' all
> >> properties of the `Stem` grob in the current `Voice` context to the
> >> new one?
> >
> > why not:
> >   [\once] \override Staff.Stem.direction = #UP/DOWN
> > ?
>
> Well, if I could get this info within the music function, I would pass
> it on to `\new Voice` as you describe.  So: How do I get this info
> from the current context?
>
>
>     Werner

Well, obviously I don't understand what you want.
Typing \stemUp/Down or [\once] \override Staff.Stem.direction =
#UP/DOWN is no real difference, if you need to enter such a command.

You could do:

foo =
#(define-music-function () ()
  #{
    <<
      \applyContext
      #(lambda (ctx)
        (let* ((stem-direction
                 (assoc-get 'direction (ly:context-grob-definition ctx 'Stem)))
               (ctx-parent (ly:context-parent ctx)))
        (when (number? stem-direction)
          (ly:context-pushpop-property
            ctx-parent
            'Stem
            'direction
            stem-direction))))
      c'4
      \new Voice { g''4 \revert Staff.Stem.direction  }
    >>
  #})

{
 \override Staff.NoteColumn.ignore-collision = ##t
  c'4 \foo \once \stemUp \foo \foo \stemDown \foo
}

But there is still the Stem.direction-override.
Apart from that I'm not convinced above coding is suffiviently robust.
You may need ti test thoroughly.

Cheers,
  Harm

Reply via email to