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

2020-01-16 Thread Paolo Prete
On Thu, Jan 16, 2020 at 1:43 PM Simon Albrecht 
wrote:

> Hi Paolo,
>
> it seems like you have some very specific setup of lilypond files and
> framework and need a solution that works within that, but you’re trying
> to avoid explaining the whole setup either because it’s too much effort
> or for privacy or similar.


Sorry. I just explained all in the previous post, in reply to Aaron. Wrong
topic/question.
I think now all is clear.
Best,
Paolo


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

2020-01-16 Thread Paolo Prete
On Thu, Jan 16, 2020 at 4:49 AM Aaron Hill  wrote:

>
> However, why jump through such Scheme hoops when LilyPond syntax is more
> direct?
>
>
Thank you Aaron. I used a misleading topic, sorry. I wanted a set of layout
properties which is shared by all the scores I edit. So I can simply import
it with \include.
I thought that it was necessary to replicate these props in all the layout
blocks of all the scores. Then I asked for a "Scheme solution"
But this is not true:

%%%
\version "2.19.45"
\layout {
  \context {
\Staff
  \override StaffSymbol.color = #red
  }
}

\layout {
  \context {
\Staff
  \override StaffSymbol.line-count = 3
  }
}

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


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

2020-01-16 Thread Simon Albrecht

Hi Paolo,

it seems like you have some very specific setup of lilypond files and 
framework and need a solution that works within that, but you’re trying 
to avoid explaining the whole setup either because it’s too much effort 
or for privacy or similar. From my experience, when I get into that kind 
of situation I have usually ended up in some kind of ‘rabbit hole’ and 
the problem would be easier solved with a different setup in the first 
place.


Can you describe the reason why you need this?

Best, Simon

On 16.01.20 03:41, Paolo Prete wrote:
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 now.
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




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

2020-01-15 Thread Aaron Hill

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

now.
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:context-def-modify
  (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:context-def-modify
  (ly:output-def-lookup $defaultlayout 'Staff)
  ; LilyPond:
  ;   #{ \with { \override StaffSymbol.color = #red } #}
  ; Scheme:
  (ly:make-context-mod
`((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



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

2020-01-15 Thread Paolo Prete
On Thu, Jan 16, 2020 at 3:15 AM Aaron Hill  wrote:

> On 2020-01-15 5:15 pm, Paolo Prete wrote:
> > Hello,
> >
> > is it possible to override a property of StaffSymbol outside a
> >  \new Staff \with { ... }
> > context?
> >
> > I would like to obtain something like:
> >
> > %%%
> >
> > #scheme-code-for-overriding-staffsymbol-for-all-the-staves-in-the-score
> > {
> >   c' c' c' c'
> > }
> >
> > %%%
>
> Without needing to mess with Scheme, you can do this using the \layout
> block providing you want to change all staves:
>
> 
> \version "2.19.83"
>
> \layout {
>\context {
>  \Staff
>  \override StaffSymbol.color = #red
>}
> }
>
> \new Staff { b'4 }
> \new Staff { b'4 }
> \new Staff { b'4 }
> 
>
> (That is a top-level \layout block, but the same can be done within a
> \score to scope the effect.)
>  \name RedStaff
>  \alias Staff
>  \override StaffSymbol.color = #red
>}
>\inherit-acceptability RedStaff Staff
> }
>
>
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
now.
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

thanks!
Paolo


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

2020-01-15 Thread Aaron Hill

On 2020-01-15 5:15 pm, Paolo Prete wrote:

Hello,

is it possible to override a property of StaffSymbol outside a
 \new Staff \with { ... }
context?

I would like to obtain something like:

%%%

#scheme-code-for-overriding-staffsymbol-for-all-the-staves-in-the-score
{
  c' c' c' c'
}

%%%


Without needing to mess with Scheme, you can do this using the \layout 
block providing you want to change all staves:



\version "2.19.83"

\layout {
  \context {
\Staff
\override StaffSymbol.color = #red
  }
}

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


(That is a top-level \layout block, but the same can be done within a 
\score to scope the effect.)


If you only need to affect specific staves but want to avoid duplicating 
the overrides, put them in a variable to reference as needed:



\version "2.19.83"

redLines = \with { \override StaffSymbol.color = #red }

\new Staff { b'4 }
\new Staff \with { \redLines } { b'4 }
\new Staff \with { \redLines } { b'4 }


Lastly, you could even define your own Staff-like context and embed the 
property changes within it:



\version "2.19.83"

\layout {
  \context {
\Staff
\type Engraver_group
\name RedStaff
\alias Staff
\override StaffSymbol.color = #red
  }
  \inherit-acceptability RedStaff Staff
}

\new Staff { b'4 }
\new RedStaff { b'4 }
\new RedStaff { b'4 }



-- Aaron Hill



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

2020-01-15 Thread Paolo Prete
Hello,

is it possible to override a property of StaffSymbol outside a

 \new Staff \with { ... }

context?


I would like to obtain something like:

%%%

#scheme-code-for-overriding-staffsymbol-for-all-the-staves-in-the-score

{

  c' c' c' c'

}

%%%


Thanks