lilypond-user
[Top][All Lists]
Advanced

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

Re: Tweaking in scheme


From: David Kastrup
Subject: Re: Tweaking in scheme
Date: Mon, 29 Jun 2015 13:40:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Thomas Morley <address@hidden> writes:

> How about:
>
> \version "2.19.21"
>
> %% regard output of:
> \displayMusic
> { \tweak style #'harmonic a'1 }
>
> tweakI =
> #(define-music-function (parser location music)(ly:music?)
>   (ly:music-set-property! music 'tweaks
>     (acons 'style 'harmonic
>       (acons 'color red
>         (ly:music-property music 'tweaks))))
>   music)
>
> { \tweakI a'1 }
>
> %% or:
>
> tweakII =
> #(define-music-function (parser location music)(ly:music?)
>   #{
>     \tweak color #red
>     \tweak style #'harmonic
>     $music
>   #})
>
> { \tweakII a'1 }

As 2.19.22 is now available for download, let me smugly suggest:

\version "2.19.22"
tweakIII =
#(define-music-function (music) (ly:music?)
  (tweak 'color red
    (tweak 'style 'harmonic music)))

However, like all of the previous proposals, this relies on "music"
being a single tweakable item.  For noteheads, there is the more
thorough style-note-heads function employed by \harmonicNote, so this
part could be done by (harmonicNote music) instead (\harmonicNote uses a
tweak for a single note and override/revert for everything else).

One can also try to do this kind of iteration oneself in order to only
use the less invasive tweaks and get the color covered:

\version "2.19.22"
tweakIV =
#(define-music-function (music) (ly:music?)
   (map-some-music
     (lambda (m)
       (and (music-is-of-type? 'note-event)
            (tweak 'color red (tweak 'style 'harmonic m))))
     music))

If version 2.19.22 is not available, one can retain the parser/location
arguments and replace the (tweak ...) line by the core of any of Harm's
proposals.  map-some-music has been available since 2.16.0 at least, and
all the rest for longer.

-- 
David Kastrup



reply via email to

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