lilypond-user
[Top][All Lists]
Advanced

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

Tremolo functions


From: Jay Anderson
Subject: Tremolo functions
Date: Sun, 8 Mar 2009 18:51:26 -0700

I made two tremolo utility functions today which may be of interest to
some here. Before adding them to LSR I just want a few people to take
a look at them.

\tremolos #16 {c4 d8 e f g a4 b c2}

expands to

\repeat tremolo 4 c16
  \repeat tremolo 2 d16
  \repeat tremolo 2 e16
  \repeat tremolo 2 f16
  \repeat tremolo 2 g16
  \repeat tremolo 4 a16
  \repeat tremolo 4 b16
  \repeat tremolo 8 c16

See the attached excerpt from Beethoven Symphony No.3 for an example use case.

The other is simply \unfoldTremolos. I usually use the midi to check
for errors I don't want to unfold the volta repeats, but not unfolding
tremolos sounds strange. \unfoldTremolos does just what it says.

Enjoy!

-----Jay

In use here: 
<http://github.com/horndude77/open-scores/blob/master/BeethovenSymphony3/defs.lyi>

#(define (tremolo-repeat-count dur music)
  (let* ((elements (ly:music-property music 'elements))
         (music-dur (ly:music-property (car elements) 'duration))
         (length (ly:duration-log music-dur))
         (dots (ly:duration-dot-count music-dur))
         (beats (* (- 2 (/ 1 (expt 2 dots))) (/ 4 (expt 2 length)))))
      (* beats (/ dur 4))))

#(define (make-tremolo dur music)
  (make-music
    'TremoloRepeatedMusic
    'elements
    '()
    'repeat-count
    (tremolo-repeat-count dur music)
    'element
    music))

#(define (tremoloize dur music)
  (if (eq? (ly:music-property music 'name) 'EventChord)
    (make-tremolo dur music)
    music))

%dur is 8, 16, 32, etc.
tremolos = #(define-music-function (parser location dur mus) (integer?
ly:music?)
  (music-map (lambda (x) (tremoloize dur x)) mus))

#(define (unfold-tremolos mus)
  (if (eq? (ly:music-property mus 'name) 'TremoloRepeatedMusic)
    (unfold-repeats mus)
    mus))

unfoldTremolos = #(define-music-function (parser location mus) (ly:music?)
  (music-map unfold-tremolos mus))

Attachment: beeth_tremolos.png
Description: PNG image


reply via email to

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