[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Override a StaffSymbol property outside \new Staff { ... } context

From: Aaron Hill
Subject: Re: Override a StaffSymbol property outside \new Staff { ... } context
Date: Wed, 15 Jan 2020 19:49:50 -0800
User-agent: Roundcube Webmail/1.3.8

On 2020-01-15 6:41 pm, Paolo Prete wrote:
Sorry Aaron, I was not precise in my question.
I need to override a property of StaffSymbol, for every staff, outside any music expression/block context. Probably I'm not using the right words even
But what I need is a sort of a "global" variable which is set for any staff without having to put it into some music expression (like \layout {\context
{...}} , or \new Staff \with { ... } etc.).
This is why I asked if is there a Scheme solution

To my knowledge, there is nothing more "global" than the top-level \layout. (The same goes for \header, \paper, and \midi.)

If you are insistent on using Scheme, I believe the following is functionally equivalent:

\version "2.19.83"

% LilyPond:
%   \layout { \context { \Staff \override StaffSymbol.color = #red } }
% Scheme:
#(ly:output-def-set-variable! $defaultlayout 'Staff
      (ly:output-def-lookup $defaultlayout 'Staff)
      #{ \with { \override StaffSymbol.color = #red } #}))

<< \new Staff { b'4 } \new Staff { b'4 } >>

Note that I still use LilyPond syntax to define the context-mod (i.e. \with block), but even that could be completely done in Scheme:

\version "2.19.83"

#(ly:output-def-set-variable! $defaultlayout 'Staff
      (ly:output-def-lookup $defaultlayout 'Staff)
      ; LilyPond:
      ;   #{ \with { \override StaffSymbol.color = #red } #}
      ; Scheme:
        `((assign StaffSymbol ,(ly:make-grob-properties
             `((color . ,red))))))))

<< \new Staff { b'4 } \new Staff { b'4 } >>

However, why jump through such Scheme hoops when LilyPond syntax is more direct?

-- Aaron Hill

reply via email to

[Prev in Thread] Current Thread [Next in Thread]