lilypond-user
[Top][All Lists]
Advanced

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

Re: Slashed beam


From: Thomas Morley
Subject: Re: Slashed beam
Date: Sun, 25 Dec 2011 01:41:03 +0100

Hi Paolo,

2011/12/25 Paolo Prete <address@hidden>:
> Unfortunately the snippet doesn't work (--> wrong slash position) if I 
> \override Stem #'direction = #down
>
> In addition, the example I linked gives me more control of the slash (offset, 
> length etc.)
>
> --- Dom 25/12/11, James <address@hidden> ha scritto:
>
>> Da: James <address@hidden>
>> Oggetto: Re: Slashed beam
>> A: "Paolo Prete" <address@hidden>
>> Cc: address@hidden
>> Data: Domenica 25 dicembre 2011, 00:51
>> Hello,
>>
>> On 24 December 2011 23:46, Paolo Prete <address@hidden>
>> wrote:
>> > Hi,
>> >
>> > is there a way to have a slash on the beam of a
>> _sequence_ of notes?
>> >
>> > Something like a slash for an acciaccatura with
>> multiple notes, but intended for normal (not acciaccatura)
>> notes.
>> >
>> > This piece of code wuold be very useful, but it
>> doesn't compile on 2.15.21
>> >
>> > http://lists.gnu.org/archive/html/lilypond-user/2007-04/msg00422.html
>> >
>> > At least, how can I modify it so to compile it?
>> >
>>
>>
>> http://lsr.dsi.unimi.it/LSR/Item?id=721
>>
>> ?
>>
>> (works on latest 2.15 code)
>>
>>
>> --
>> --
>>
>> James

this should compile (tested with "2.15.20"):

\version "2.15.20"

\layout {
   ragged-right = ##f
   point-and-click = ##f
}

%% Arguments to Makeslash (all numbers are in staff units):
%%
%% #1: angle
%% #2: length of the left  half of the slash
%% #3: length of the right half of the slash
%% #4: thickness
%% #5: factor to shift the slash relative to the stem (+1/-1 =
attached to top/bottom)
%% #6: offset as a pair (x-offset, y-offset)
%%
%% Values other than +/-1 in arguments #5 and #6 are interpolated.

MakeSlash = #(define-music-function (parser location angle len-left
len-right thick y-factor offset)
                                    (number? number? number? number?
number? pair?)
#{
\once \override Voice.Stem #'text = \markup {
    \postscript #(let ((x-off (car offset))
                       (y-off (cdr offset)))
    (string-append
    (ly:number->string (car offset)) " " (ly:number->string (cdr
offset)) " translate "
    (ly:number->string angle) " rotate "
    (ly:number->string (- x-off)) " "
    (ly:number->string (- y-off)) " translate 0 setlinewidth "
    (ly:number->string (- x-off len-left))  " " (ly:number->string (+
y-off thick)) " moveto "
    (ly:number->string (- x-off len-left))  " " (ly:number->string y-off)
                                             " " (ly:number->string
thick) " 90 270 arc "
    (ly:number->string (+ x-off len-right)) " " (ly:number->string y-off)
                                             " " (ly:number->string
thick) " 270 90 arc "
                                             " gsave fill grestore stroke")) }

\once \override Voice.Stem #'stencil = #(lambda (grob)
    (let* ((sten1 (ly:stem::print grob))
           (sten2 (ly:text-interface::print grob))
           (extent1 (ly:stencil-extent sten1 Y))
           (extent2 (ly:stencil-extent sten2 Y)))
    (ly:stencil-add
        sten1
        (ly:stencil-translate sten2
                              (cons 0 (+ (* y-factor (cdr extent1))
                                         (* (- 1 y-factor) (car extent1))))))))
#})



slash = { \MakeSlash #40 #1.5 #3.0 #0.15 #1.0 #'(0 . 0) }

\relative c'
{
    \slash c16[
    \slash b']

    \MakeSlash #-20 #2.0 #1.0 #0.05 #0.75 #'(0 . 0)
    f2
    r8
    r4
}

But it is a little uncomfortable. :)

HTH,
  Harm



reply via email to

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