lilypond-user
[Top][All Lists]
Advanced

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

Re: Harp Pedals?


From: Valentin Villenave
Subject: Re: Harp Pedals?
Date: Thu, 14 Aug 2008 16:50:18 +0200

2007/7/8 Dewdman42 <address@hidden>:
>
> I can't seem to find anything in the Lilypond manual about creating harp
> pedal symbols.  I would think this issue has been covered a lot by users of
> Lilypond.  how do I do it, or something like it:
>
> http://www.nabble.com/file/p11492013/ScreenHunter_03%2BJul.%2B08%2B12.40.jpg

Greetings Carl, hi everybody,

I've been trying to implement this harp diagrams feature for a while,
but my implementation is quite dirty and not fully working. Basically,
I tried to write a markup command that would take seven arguments, one
for each pedal. However, for some reason I cannot pass more than three
arguments to the markup command (see below).

1 - What I'd really like to achieve is to have one single argument
containing the whole set of pedals, like you do with your diagrams,
such as
\harp #"0;-1;0;1;0;0;1;"
instead of
\harp #0 #-1 #0 #1 #0 #0 #1

However, I cannot parse the string to extract the values (I've tried
to figure it out from your code, but it's way over my skills).

2 - The implementation I provide is very dirty, as I said. I don't
know if it would be best to haave a separate stencil function, and
inside the function I don't know how I can increment the values for
the horizontal placement of the boxes in an elegant way.

3 - Ideally, we should add something like
(if (> a 0) set! a 1
(if (< a 0) set! a 1))
so to allow users to use any values bigger values than 1 or lower than
-1 without breaking their result.

Can you please have a quick look at the code below, when you have a minute?


% I have to define some variables  separately or else
% compiling fails miserably.

% The following three are already
% defined using the main function

%#(define d 0)
%#(define c 0)
%#(define b 0)
#(define e 0)
#(define f 0)
#(define g 0)
#(define a 0)

#(define-markup-command (harp layout props d c b) (integer? integer? integer?)
     ; FIXME the size variable should be defined by a prop. lookup

  (define sz 1.2)
     ; TODO is it worth adding a thickness variable here?

  (let ((x (* sz 4))
        (y (* sz 2))
        (box-width (* sz 0.4))
        (box-height (* sz 1))
        (space (* sz 0.5)))
    (ly:stencil-add
      (ly:make-stencil
       `(draw-line 0.2 ; horizontal line
           ,(- 0 x) ,y ,x ,y))
      (ly:make-stencil
       `(draw-line 0.2 0 0 0 ,(* y 2))) ; vertical line (shorter)

     ;; FIXME: the boxes should be drawn using a separate function

      (make-filled-box-stencil   ;;  pedal D
        (cons (- space x) (+ (- space x) box-width))
        (cons (+ (- y (/ box-height 2)) d) (+ (+ y (/ box-height 2)) d)))

      (make-filled-box-stencil  ;; pedal C
        (cons (+ (- (* space 2) x) box-width) (- (* (+ space box-width) 2) x))
        (cons (+ (- y (/ box-height 2)) c) (+ (+ y (/ box-height 2)) c)))

      (make-filled-box-stencil  ;; pedal B
        (cons (+ (- (* space 3) x) (* box-width 2)) (- (* (+ space
box-width) 3) x))
        (cons (+ (- y (/ box-height 2)) b) (+ (+ y (/ box-height 2)) b)))

      (make-filled-box-stencil  ;; pedal E
        (cons space (+ space box-width))
        (cons (+ (- y (/ box-height 2)) e) (+ (+ y (/ box-height 2)) e)))

      (make-filled-box-stencil  ;; pedal F
        (cons (+ (* space 2) box-width) (* (+ space box-width) 2))
        (cons (+ (- y (/ box-height 2)) f) (+ (+ y (/ box-height 2)) f)))

      (make-filled-box-stencil  ;; pedal G
        (cons (+ (* space 3) (* box-width 2)) (* (+ space box-width) 3))
        (cons (+ (- y (/ box-height 2)) g) (+ (+ y (/ box-height 2)) g)))

      (make-filled-box-stencil  ;; pedal A
        (cons (+ (* space 4) (* box-width 3)) (* (+ space box-width) 4))
        (cons (+ (- y (/ box-height 2)) a) (+ (+ y (/ box-height 2)) a))))))


\new Staff {
c1-\markup {

 % This function should take 7 arguments, or
 % the seven pedal indications in one single arg.
  \harp #1 #-1 #0
  }
}




Thanks,
Valentin




reply via email to

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