lilypond-user
[Top][All Lists]
Advanced

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

Re: always glissandi


From: David Nalesnik
Subject: Re: always glissandi
Date: Thu, 23 Jun 2016 18:37:09 -0500

On Thu, Jun 23, 2016 at 6:14 PM, David Nalesnik
<address@hidden> wrote:
> Hi Tobias,
>
> On Thu, Jun 23, 2016 at 5:15 PM, Tobias Hagedorn
> <address@hidden> wrote:
>> Hello everybody!
>> Does anybody know how to get always glissandi without writing \glissando 
>> after every Note?
>> Thanks for answer!
>> Tobias
>>
>
> You need to define a music function for this.
>
> How about:
>
> \version "2.19.30"
>
> addGlissandi =
> #(define-music-function (music) (ly:music?)
>    (music-map
>     (lambda (mus)
>       (if (music-is-of-type? mus 'event-chord)
>           (append! (ly:music-property mus 'elements)
>             (list (make-music 'GlissandoEvent))))
>       (if (music-is-of-type? mus 'note-event)
>           (set! (ly:music-property mus 'articulations)
>                 (cons (make-music 'GlissandoEvent)
>                   (ly:music-property mus 'articulations))))
>
>       mus)
>     music)
>    music)
>
>
> {
>   \addGlissandi { c'4 g' c'' g' }
>   c'1
>   \addGlissandi { <c' e'>4 <g' c''> <c'' e''> <g' c''> }
>   <c' e'>1
> }
>
> %%%

Let's discount tied notes:

%%%%%%%%%%%%%%%
\version "2.19.30"

#(define (tie-present? mus)
   (any (lambda (a) (music-is-of-type? a 'tie-event)) mus))

addGlissandi =
#(define-music-function (music) (ly:music?)
   (music-map
    (lambda (mus)
      (if (and (music-is-of-type? mus 'event-chord)
               (not (tie-present? (ly:music-property mus 'elements))))
          (append! (ly:music-property mus 'elements)
            (list (make-music 'GlissandoEvent))))
      (if (and (music-is-of-type? mus 'note-event)
               (not (tie-present? (ly:music-property mus 'articulations))))
          (set! (ly:music-property mus 'articulations)
                (cons (make-music 'GlissandoEvent)
                  (ly:music-property mus 'articulations))))

      mus)
    music)
   music)


{
  \addGlissandi { g4 c'~ c' g' c'' g' }
  c'1
  \addGlissandi { <c' e'>1~ <c' e'>4 <g' c''> <c'' e''> <g' c''> }
  <c' e'>1
}
%%%%%%%%%%%%%%%

(If you want glissandi suppressed on repeated notes, that's a whole
new level of sophistication.)

-David



reply via email to

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