lilypond-user
[Top][All Lists]
Advanced

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

problems with a difficult function


From: Mark Polesky
Subject: problems with a difficult function
Date: Fri, 26 Jul 2013 01:21:13 -0700 (PDT)

Hi everyone,

I'm trying to write a function to deal with a peculiar problem;
I've tried everything I know and I've hit the wall.

I know it's weird, but the function would do this:

1) connect contiguous notes with glissandos
2) replace tied notes with spacers (except the first in a series),
   thus allowing glissandos to pass over the spacers
3) do the same with chords

The attached png makes it easier to see what I'm describing.

Task #1 above has been solved, thanks to the kind help of David
Kastrup.  (see the "glissandoize" function below).  However, the
other tasks continue to elude me, after many hours of trying to
solve them.  I sort of solved #2 for very simple cases, but my
solution utterly fails when things like tuplets get in the way.

Any help or advice would be greatly appreciated.

Thanks.
- Mark

****************************

gl = \glissando

<<
  \new Staff {
  \relative f' {
    \set Staff.instrumentName = #"input"
    \tuplet 3/2 { f8 g a~ } a4~ 
    \tuplet 3/2 { a8 g f~ } f8 r

    \tuplet 3/2 { <f a>8 <g b> <a c>~ } q4~ 
    \tuplet 3/2 { q8 <g b> <f a>~ } q8 r
  }
}

\new Staff {
  \relative f' {
    \set Staff.instrumentName = #"output"
    \tuplet 3/2 { f8\gl g\gl a\gl } s4
    \tuplet 3/2 { s8 g\gl f } s8 r

    \set glissandoMap = #'((0 . 0) (1 . 1)) 
    \tuplet 3/2 { <f a>8\gl <g b>\gl <a c>\gl } s4
    \tuplet 3/2 { s8 <g b>\gl <f a> } s8 r
  }
}
>>

glissandoize =
#(define-music-function
   (p l music)
   (ly:music?)
   (let ((rh (extract-typed-music music 'rhythmic-event)))
     (if (pair? rh) 
       (for-each (lambda (a b)
                   (if (and (music-is-of-type? a 'note-event)
                            (music-is-of-type? b 'note-event))
                     (set! (ly:music-property a 'articulations)
                       (cons (ly:music-deep-copy glissando)
                             (ly:music-property a 'articulations)))))
                 rh (cdr rh))))
   music)

\relative f' {
  \glissandoize {
    % glissandos work with single notes
    \tuplet 3/2 { f8 g a~ } a4~
    \tuplet 3/2 { a8 g f~ } f8 r

    % but not with chords
    \tuplet 3/2 { <f a>8 <g b> <a c>~ } q4~
    \tuplet 3/2 { q8 <g b> <f a>~ } q8 r
  }
}

Attachment: preview.png
Description: PNG image


reply via email to

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