RE: [SPAM] Re: Tweaking in scheme
>-Original Message- >From: David Kastrup [mailto:d...@gnu.org] >Sent: Monday, June 29, 2015 12:40 PM >To: Thomas Morley >Cc: Peter Gentry; lilypond-user >Subject: [SPAM] Re: Tweaking in scheme > >Thomas Morley 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 Thanks for that I have downloaded 2.19.22 for even more fun ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: [SPAM] Re: Tweaking in scheme
"Peter Gentry" writes: >>-Original Message- >>From: David Kastrup [mailto:d...@gnu.org] >>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. > > Thanks for that I have downloaded 2.19.22 for even more fun Well, people got used to the entrails of LilyPond hanging all over their code for the last dozen years or however long music functions existed. But the road to working with Scheme is less yucky if one can keep them out of sight until needed. And (tweak 'color red (tweak 'style 'harmonic m)) beats having to write ((ly:music-function-extract tweak) parser location 'color red ((ly:music-function-extract tweak) parser location 'style 'harmonic m)) even though the latter was likely faster since it did not bother checking the arguments for correctness. But I don't actually think any user-level code ever used ly:music-function-extract: people either used #{...#} once it was powerful enough for that, or manually emulated whatever the music function did. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: [SPAM] Re: Tweaking in scheme
David Kastrup writes: > "Peter Gentry" writes: > >>>-Original Message- >>>From: David Kastrup [mailto:d...@gnu.org] > >>>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) Yikes. Of course (music-is-of-type? m 'note-event) here. >>>(tweak 'color red (tweak 'style 'harmonic m >>> music)) -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user