lilypond-user
[Top][All Lists]
Advanced

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

Re: Brackets between notes


From: Thomas Morley
Subject: Re: Brackets between notes
Date: Sat, 16 Mar 2013 23:47:53 +0100

2013/3/16 Noeck <address@hidden>:
>> I would like to have brackets/spanners between notes like they are
>> common in musical education to show semitones (= \/) and tone (= |_|) as
>> shown on this page: http://www.akkorde.info/dur-akkorde.html
>> (I would prefer them without slope/ends on same vertical position).
>
> I tried also \[ and \] which looks like one of those - but it is always
> above the staff and the semitone-version is missing.
>
> Any ideas, how to achieve this?
>
> Joram
>

Hi Joram,

below some code which seems to do what you want, hijacking Glissando.
It is mostly taken and modified from:

https://codereview.appspot.com/7615043/
Adds Ferneyhough hairpins to LilyPond.
by Mike Solomon

and

http://lists.gnu.org/archive/html/lilypond-user/2013-03/msg00560.html
by Rama Gottffried


\version "2.16.2"

#(define ((elbowed-glissando coords) grob)

 (define (pair-to-list pair)
    (list (car pair) (cdr pair)))

 (define (normalize-coords goods x y)
   (map
     (lambda (coord)
       (cons (* x (car coord)) (* y (cdr coord))))
     goods))

 (define (my-c-p-s points thick)
   (make-connected-path-stencil
     points
     thick
     1.0
     1.0
     #f
     #f))

; outer let to trigger suicide
 (let ((sten (ly:line-spanner::print grob)))
   (if (grob::is-live? grob)
       (let* ((thick (ly:grob-property grob 'thickness 0.1))
              (xex (ly:stencil-extent sten X))
              (lenx (interval-length xex))
              (yex (ly:stencil-extent sten Y))
              (xtrans (car xex))
              (ytrans (car yex))
              (uplist
                (map pair-to-list
                     (normalize-coords coords lenx 3)))
              (downlist
                (map pair-to-list
                     (normalize-coords coords lenx -3))))

  (ly:stencil-translate
      (my-c-p-s uplist thick)
    (cons xtrans ytrans)))
  '())))

#(define semi-tone-gliss
  (elbowed-glissando '((0.5 . -1.0) (1.0 . 0.15))))

#(define tone-gliss
  (elbowed-glissando '((0 . -0.5) (1.0 . -0.35) (1.0 . 0.16))))

#(define three-semi-tone-gliss
  (elbowed-glissando '((0 . -0.5) (0.5 . -1.0) (1.0 . -0.35) (1.0 . 0.15))))

semiTone =
  \override Glissando #'stencil = #semi-tone-gliss

tone =
  \override Glissando #'stencil = #tone-gliss

threeSemiTone =
  \override Glissando #'stencil = #three-semi-tone-gliss



addGliss =
#(define-music-function (parser location music)
     (ly:music?)
  "Adds \\glissando to all notes of @var{music}"

  (define (add-gliss m)
    (case (ly:music-property m 'name)
      ((NoteEvent) (set! (ly:music-property m 'articulations)
                       (append (ly:music-property m 'articulations)
                          (list (make-music (quote GlissandoEvent)))))
                    m)
      (else #f)))

  #{
    %\once
    \override Glissando #'Y-offset = #-1
    \override Glissando #'thickness = #0.2
    \override Glissando #'bound-details =
      #'((left    (padding . 0.2))
         (right   (end-on-accidental . #f) (padding . 0.2)))
    $(map-some-music add-gliss music)
  #})

\relative c' {
  \override Staff.TimeSignature #'stencil = ##f
  \override Staff.BarLine #'stencil = ##f
  \addGliss {
      \tone
      c1
      \semiTone
      d
      \tone
      ees
      f
      \semiTone
      g
      \threeSemiTone
      as
      \semiTone
      b!
  }
      c
  \revert Staff.BarLine #'stencil
  \bar "|."
}


>
> And I have found a possible solution in the German Lilypond forum:
> http://www.lilypondforum.de/index.php?topic=658.0
> However, these brackets do not adapt to the distance of notes (see
> example below).

Am I right you've subscribed to the german forum?
:)

HTH,
  Harm

Attachment: scale-analysis-brackets.png
Description: PNG image


reply via email to

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