lilypond-user
[Top][All Lists]
Advanced

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

Re: Color tweaks (edition engraver)


From: David Nalesnik
Subject: Re: Color tweaks (edition engraver)
Date: Fri, 1 May 2015 10:56:48 -0500

Hi,

On Tue, Apr 28, 2015 at 10:29 AM, David Nalesnik <address@hidden> wrote:


On Mon, Apr 27, 2015 at 6:13 PM, David Nalesnik <address@hidden> wrote:
Hi Joram,

On Mon, Apr 27, 2015 at 5:30 PM, Noeck <address@hidden> wrote:
 
 

> There is something which has to be fixed, though.  All clefs get colored,

Can this be avoided (even at the cost of not coloring them even if tweaked)?

Sure, but I wouldn't want to settle!

The attached should work for the most part.
 
 

>  The best way to check, of
> course, is to run it with a large, heavily tweaked score.

That's my purpose, so I will give you feedback soon. The first
impression is that it colors too much (hairpins, dynamics and ranges of
note heads).

Make sure those aren't instances of \override rather than \once \override ...

Another issue of relevance here is that using \voiceOne, \voiceTwo and the like creates lots of overrides "behind the scenes".  These will of course be picked up and colored.

Run the attached.  In the log output you can clearly see the wealth of overrides which have bee added to the music _expression_ by the \voiceOne command.  Comment it out to see the color magically disppear.

There is no realistic way I can see to sort out "hidden overrides" caused by \voiceOne, \voiceTwo and actual explicit use of \override.

Now, if that isn't a problem... :)

DN

P.S. The attached won't play well with user overrides of 'after-line-breaking.  Optimistically, it's a corner case :) Anyway, I give up for the time being.

The code below will work much better.  Instead of modifying actual grobs, I've opted to insert music expressions.  Turns out there is no problem distinguishing between explicit overrides and ones introduced sneakily by \oneVoice and the like.

Note that overrides in a context block will not show up.  (They wouldn't in the other version of the code, either.)

Right now the effect is limited to [\once] \override and \revert.  \tweak could be accommodated without much difficulty.

The problem with after-line-breaking is gone.

Now, overrides to color aren't going to show up.  (The changed color would indicate override anyway!)  Making something transparent also won't show up :)

David

%%%%%%%%%%%%%

\version "2.19"

colorOverride =
#(define-music-function (parser location music) (ly:music?)
   (music-map
    (lambda (mus)
      (cond
       ((music-is-of-type? mus 'override-property-event)
        (let* ((grob-name (ly:music-property mus 'symbol))
               (prop-path (ly:music-property mus 'grob-property-path))
               (once? (ly:music-property mus 'once)))
          (cond
           ; non-user overrides don't set property path
           ((null? prop-path) #{ #}) 
           ((eq? #t once?)
            (set! mus
                  #{
                    \once \override #(list grob-name 'color) = #green
                    #mus
                  #}))
           (else
            (set! mus
                  #{
                    \override #(list grob-name 'color) = #green
                    #mus
                  #})))))
       ((and (music-is-of-type? mus 'layout-instruction-event)
             (eq? (ly:music-property mus 'name) 'RevertProperty))
        (let ((grob-name (ly:music-property mus 'symbol)))
          (set! mus
                #{
                  \revert #(list grob-name 'color)
                  #mus
                #}))))
      
      mus)
    music)
   music)


%\displayMusic
\colorOverride
\new PianoStaff <<
  \new Staff <<
    \new Voice {
      \voiceOne
      c''4
      \once \override NoteHead.after-line-breaking =
      #(lambda (grob)
         (let ((stil (ly:note-head::print grob)))
           (set! (ly:grob-property grob 'stencil)
                 (ly:stencil-scale stil 1.5 1.5))))
      d'' e''->
      \override Voice.Stem.padding = 2
      f''
      g''1                                          
    }
    \new Voice {
      \voiceTwo
      c'4 d'
      \override Script.font-size = 3
      e'-> f'->
      \revert Script.font-size
      g'1->
    }
  >>
  \new Staff <<
    \clef bass
    \new Voice { 
      \voiceOne
      c'4 d' e'->
      \override Voice.Stem.padding = 2
      f'
      g'1\fermata
    }
    \new Voice {
      \voiceTwo
      c4 d
      \override Script.font-size = 3
      e-> f->
      g1->
    }
  >>
>>


reply via email to

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