2016-04-13 19:51 GMT+02:00 Jay Vara <j...@diljun.com>:

> I have some music where I have Glissandos between each note of a phrase.
> This happens often enough to warrant a Music of Scheme function that takes
> a piece of music and adds glissandos between the notes.
>
> In the example code below, for example, such a function would take music
> and convert it musicsl.
>
> %%%%%%%%%%%%%%%%%%%%%%
>
> \version "2.19.39"
> music = \relative c' {c8 (d e f g)}
>
> musicsl = \relative c' { c8 (\glissando d \glissando e \glissando f
> \glissando g)}
>
> \new Staff { \music}
>
> \new Staff {\musicsl}
>
> %%%%%%%%%%%%%%%%%%%%%%%%
>
> I tried working with the snippet that adds articulations
> http://lsr.di.unimi.it/LSR/Snippet?id=82, but was not sure how to
> proceed. Is there a function already that does this?
>
>
How about:

\version "2.19.36"

#(define (add-glissando m)
;; Adds 'GlissandoEvent to the 'elements of an 'EventChord
;; or to the 'articulations of a 'NoteEvent not being in an 'EventChord
;; otherwise returns unspecified
  (let ((make-glissando (make-music 'GlissandoEvent)))
    (case (ly:music-property m 'name)
      ((EventChord)
        (set! (ly:music-property m 'elements)
              (cons make-glissando (ly:music-property m 'elements))))
      ((NoteEvent)
        (set! (ly:music-property m 'articulations)
              (cons make-glissando (ly:music-property m
'articulations)))))))

addGliss =
#(define-music-function (music)(ly:music?)
;; Applies `add-glissando' to all `EventChords and 'NoteEvent in `music'
apart
;; from the last
  (let ((notes-and-evcs (extract-named-music music '(EventChord
NoteEvent))))
    (for-each add-glissando (drop-right notes-and-evcs 1))
    music))

%%%%%%%%%%%%%%%
%% EXAMPLE
%%%%%%%%%%%%%%%

music =
\relative c' {
  c8 (d e f g) r <g b> \set glissandoMap = #'((1 . 0) (0 . 0)) < c e >  g
}

\new Staff \displayMusic \addGliss \music

Cheers,
  Harm
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to