lilypond-user
[Top][All Lists]
Advanced

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

Re: Using other NoteHeads with \harmonicByFret?


From: Thomas Morley
Subject: Re: Using other NoteHeads with \harmonicByFret?
Date: Thu, 2 Feb 2012 21:42:37 +0100

Hi,

2012/2/2 David Kastrup <address@hidden>:
> Peter Crighton <address@hidden> writes:
>
>> No, unfortunately it doesn't have the desired effect.
>> First, there was a "$" missing before "fret" in the "\override
>> TabNoteHead" line.
>
> Not if you are using a version of LilyPond from about 2.15.18 onward.
> It gets along with a lot less $ inside of #{ ... #} while allowing you
> to use $ outside of it as well.
>
> So basing this on Marc's comment
>
>> \harmonicBy... is defined in ly/music-functions-init.ly; based on this
>> definition, something like
>
> you should likely pick up the respective code from _your_ version of
> ly/music-functions-init.ly and try making analogous changes to it.
>
> --
> David Kastrup
>
>
> _______________________________________________
> lilypond-user mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-user

to avoid confusions about $ and other complications depending on the
used version, you should always post your version-number and a short
example.

Based on Marc's work I come up with the code below.

\version "2.14.2"

mixedHarmonicByFret = #(define-music-function (parser location fret
music) (number? ly:music?)
 (_i "Convert @var{music} into mixed harmonics; the resulting notes resemble
harmonics played on a fretted instrument by touching the strings above @var{fret
}.")
 (let* ((fret (number->string fret))
        (pitch (fret->pitch fret)))
       (make-sequential-music
        (list
         #{
           \override TabNoteHead #'stencil =
#(tab-note-head::print-custom-fret-label $fret)
           \override NoteHead #'stencil = #(lambda (grob)
                        (ly:grob-set-property! grob 'style 'harmonic-mixed)
                        (ly:note-head::print grob))
         #}
         (make-harmonic
           (calc-harmonic-pitch pitch music))
         #{
           \revert TabNoteHead #'stencil
           \revert NoteHead #'stencil
         #}))))

music = {

  \mixedHarmonicByFret #5
  d,16\4
  \mixedHarmonicByFret #4
  d,16\4
  \mixedHarmonicByFret #3
  d,8\4
  \mixedHarmonicByFret #5
  <g,\3 b,\2>2.

  c'4 d' e' f' g'1
}
\score {
  <<
    \new Staff { \clef "G_8" \music }
    \new TabStaff { \music }
  >>
}

HTH,
  Harm



reply via email to

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