lilypond-user
[Top][All Lists]
Advanced

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

Re: Coloring of key signature accidentals based on their pitch


From: David Nalesnik
Subject: Re: Coloring of key signature accidentals based on their pitch
Date: Fri, 21 Aug 2015 08:57:49 -0500

Hi Paul,

On Thu, Aug 20, 2015 at 9:26 PM, Paul Morris <address@hidden> wrote:
Hi David,

> On Aug 19, 2015, at 10:27 PM, David Nalesnik <address@hidden> wrote:
>
> Thanks for doing this!  (I should have thought to write it this way in the first place!)

Glad to!  Thanks for leading the way on how to convert these C++ functions to Scheme.

> By the way, later in the thread I posted a correction of the version you're commenting, which makes the spacing of naturals tally with the original.  There's a parens error: should be an extra parens in line 136 to close the inner loop and one fewer in line 191.  (I also moved a variable into a named let, but that's just cosmetic.)

Got it.  I’ve attached a new version that fixes this.

> By the way, I've also recoded hairpin::print in Scheme, and I'm attaching that to this email in case you're interested. Hairpins are another popular candidate for customizations and this should make it easier--changing the size of the circled-tip, some sort of "shorten-pair," easy addition of circles to Ferneyhough hairpins, etc.

Thanks for this! 

You're welcome.  Just for kicks, I've attached a .cc file which you could drop into the lily subdirectory and build.  It makes Line_interface::line available to Scheme. You'd just need to replace the two instances in the hairpin function with calls to ly:line-interface:line. So, lines 405-10 become

                 (set! mol (ly:line-interface::line grob x starth width endh))

                 (set! mol
                       (ly:stencil-add
                        mol
                        (ly:line-interface::line grob x (- starth) width (- endh))))

This enables drawing of the different line styles (dashed, zigzag, etc), based on overrides of Hairpin.  AFAICT this makes the Scheme stencil callback have all the same functionality as the C++ original.  So

\override Hairpin.style = #'zigzag

will work.

You can also override dash-definition, and the like.
  
(I will put this new line function forward as a patch for review when the system is over the upcoming bump.)
 
Seeing how you’ve done these is giving me some confidence that I might be able to do the same for the ledger line print function.

I looked at this briefly, enough to see that it will be more involved!  You'll need to track down the data structures used there and see if there's a convenient Scheme alternative  But pretty complicated things are possible--see the Scheme rewrite of the ambitus engraver in the snippets.
   

I made a “commented c++” version of your hairpin code.  This time I used somewhat larger blocks of code which works better than line by line.  I ended up also redoing the key signature file that way while I was at it — and made the paren correction.  Both attached.

Thanks!  The larger blocks of code are a good idea, especially when the translation becomes less line-for-line.  (I kept pretty literal in my adaptation, though.)

I found an error in the hairpin code rewrite--we need to exit the entire function when a bad grow-direction is found, so everything after line 44 needs to be a clause of the if-structure beginning in 41.  Simple removal of the parenthesis in 44 and addition of one at the end fixes this.  I went ahead and attached the correction with the indentation redone.  In this connection, I'm noticing is that it's easy to get very nested structures in Scheme when the C++ original exits at a number of points through returns.  Maybe there's an easy way to avoid this but I don't know of it.

Best,
David

Attachment: hairpin-print-to-scm-commented2.ly
Description: Text Data

Attachment: line-interface-scheme.cc
Description: Text Data


reply via email to

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