lilypond-user
[Top][All Lists]
Advanced

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

stem slash ornament


From: Mike
Subject: stem slash ornament
Date: Fri, 15 Jun 2012 07:24:20 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

This is a modification of tremolo to use it for stem ornaments
in early English keyboard (virginals) music.

The problem with tremolo is that I could not find a way to
prevent it adjusting the slash separation to match any
beaming, so I redid the stencil in ps.

It only works in 2.15 - in 2.14 the postscript prints
in the wrong place.

Submitted for comments, improvements and possible inclusion in LSR 
if people think it might be helpful.

Here is a Byrd alman which I think has worked quite well.
I had to adjust the stem length and beam postion each on
one occasion, but otherwise it is untweaked.

http://www.divshare.com/download/18366931-9b7

Mike

\version "2.15"
%% set tremolo-type to generate only one flag
sstemtr = 
#(define-music-function (parser location sequential-music)
        (ly:music?)
        "single slashed stem trill for early english keyboard music"
        (let (
                (result-sequential-music (ly:music-deep-copy sequential-music))
                (dur (ly:duration-log 
                        (ly:music-property sequential-music 'duration)))
                (trem 8)
        )
        (cond 
                ((equal? dur 3)(set! trem 16))
                ((equal? dur 4)(set! trem 32))
                ((equal? dur 5)(set! trem 64))
                ((equal? dur 6)(set! trem 128))
                )
        (set! (ly:music-property result-sequential-music 'articulations)
                (cons (make-music 'TremoloEvent 'tremolo-type trem)
                (ly:music-property result-sequential-music 'articulations)))
        result-sequential-music))

%% two flags
stemtr = 
#(define-music-function (parser location sequential-music)
        (ly:music?)
        "double slashed stem trill for early english keyboard music"
        (let (
                (result-sequential-music (ly:music-deep-copy sequential-music))
                (dur (ly:duration-log 
                        (ly:music-property sequential-music 'duration)))
                (trem 16)
        )
        (cond 
                ((equal? dur 3)(set! trem 32))
                ((equal? dur 4)(set! trem 64))
                ((equal? dur 5)(set! trem 128))
                ((equal? dur 6)(set! trem 256))
                )
        (set! (ly:music-property result-sequential-music 'articulations)
                (cons (make-music 'TremoloEvent 'tremolo-type trem)
                (ly:music-property result-sequential-music 'articulations)))
        result-sequential-music))

%% Stencil prints one slash if flag-count == 1, otherwise 2
%% Too few flags and stem engraver refuses to typeset it
%%    too many and the stem length is increased unnecessarily.

stemtrill= #(lambda(grob)
        (let* (
        (stem (ly:grob-parent grob X))
        (duration (ly:grob-property stem 'duration-log))
        (dir(ly:grob-property stem 'direction))
        (flag-count(ly:grob-property grob 'flag-count))
                
        ; give a little exra space for minims
        (base-pos (if (= 0 duration)
                0.5
                -0.2))
        (separation (if (= 1 flag-count)
                      0
                      0.6))
        (ps(format #f "
        /width 0.65  def
        /rise 0.5 def
        /thickness 0.3  def
        /slash {gsave
            currentpoint translate
              newpath
               -1 width mul exch   moveto
              2 width mul rise rlineto
              0 -1 thickness mul rlineto
              -2 width  mul  -1 rise mul rlineto
              closepath
              fill
              grestore} def          
            ~s slash
             ~s slash"  (* base-pos dir) (* (- base-pos separation) dir)))
        )
        (if  ( > flag-count 2)
                (format #t "\nWarning Stemtrill duration: ~s flags: ~s\n" 
                        duration flag-count))
        (ly:make-stencil (list 'embedded-ps ps
     )
    (cons 0 0)
    (cons 0 0))))


\layout{
  \context { 
    \Voice
    \override StemTremolo #'stencil = \stemtrill
  }
}
   
{
%% Use either notation: the wrappers enforce the correct number of flags
        \stemtr g'1 \stemtr d''8 c'' b' d'' \sstemtr c'' b' a' c'' g'4:16 
        }




reply via email to

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