lilypond-user
[Top][All Lists]
Advanced

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

Re: Catch direction operators


From: David Kastrup
Subject: Re: Catch direction operators
Date: Tue, 01 Oct 2013 14:55:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Urs Liska <address@hidden> writes:

> Am 01.10.2013 12:19, schrieb Urs Liska:
>> Am 01.10.2013 12:17, schrieb Franciszek Boehlke:
>>> lambda (x) (car x) is exactly the same as car. You should be able
>>> to write just
>>>   #(map car all-grob-descriptions)
>>> instead.
>>>
>>
>> Thanks. Now I see that it didn't _seem_ to work because I ran the
>> wrong LilyPond version :-[
>>
>
> Hi again,
>
> sorry to have to insist on perhaps basic questions.
> As it is the function now works as I want, but not in 2.16.
> From the versions I have available to test it works with 2.17.6
> onwards and not with 2.17.3 and less.
> Somehow I suspect the change between 2.17.3 and .4
>
> My best bet is that
>
>   #{ $@(map (lambda (s) #{ $colorizeDir $s #}) debug-direction-grob-list) #})
>
>
> in the mapList function is the offending piece of code.

No, that one's fine (uses 2.15.41+ functionality).  But \tweak is quite
less versatile before 2.17.6.

> Is there a way to write this so it compiles both with 2.16.2 and with
> current versions?

You'll probably need to provide your own symbol-or-music? predicate (or
symbol-list-or-music?) and then split into \override and \tweak
depending on the argument.  Or decide whether colorizeDir should do a
tweak or override, and then use it only for one of the two.

> Please refer to the attached version of the function.

Here is a rework based on the "only override" theory.  Quite uglier and
less versatile.  Also turns out that it barfs under 2.16.0 due to an
unsolved issue 2808, but it would appear that 2.16.1 already contains
the fix.

\version "2.16.1"

% Define appearance
#(cond ((not (defined? 'debug-direction-up-color))
        (define debug-direction-up-color darkgreen)))
#(cond ((not (defined? 'debug-direction-down-color))
        (define debug-direction-down-color blue)))
#(cond ((not (defined? 'debug-direction-grob-list))
        (define debug-direction-grob-list 
          (map car all-grob-descriptions))))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Directions set with ^ and _ %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

colorizeDir =
#(define-music-function (parser location item)
  (symbol?)
  (define (grob-colorize-dir grob)
    (let ((ev (event-cause grob)))
      (case (and ev (ly:event-property ev 'direction))
              ((1) debug-direction-up-color)
              ((-1) debug-direction-down-color)
              (else '()))))
  #{ \override $(symbol->string item) #'color = #grob-colorize-dir #})

mapList =
#(define-music-function (parser location)()
  #{ $@(map (lambda (s) #{ $colorizeDir $s #}) debug-direction-grob-list) #})


\layout {
  \context {
    \Voice
    \mapList
  }
}

%%%%%%%%%%%%%%%
% Usage example
%%%%%%%%%%%%%%%

{
  a4-.( b)
  a4^( b)
  \stemUp
  a''8 g''( b)\noBeam c' \stemNeutral
  c''4-3\4-"xy"
  c''_3^\4^"xy"
  c''^3_\4_"xy"
  a'-. a'^.
  g'\mf g'^\mf\>
  a' b'\!^\< c''
  b'\!
}
-- 
David Kastrup

reply via email to

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