[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [LSR v-2.18] "Easy Rhythm Template Creation" does not compile.
From: |
David Kastrup |
Subject: |
Re: [LSR v-2.18] "Easy Rhythm Template Creation" does not compile. |
Date: |
Tue, 25 Feb 2014 23:04:31 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Thomas Morley <address@hidden> writes:
> 2014-02-25 9:11 GMT+01:00 Pierre Perol-Schneider
> <address@hidden>:
>> Any idea ?
>
> Hi Pierre,
>
> you could use event-chord-wrap!
> see attached file
>
> I feel the snippet should be rewritten to reflect 'EventChord changes.
> Though, I can only start looking deeper into it next weekend.
We had it already in
<URL:http://comments.gmane.org/gmane.comp.gnu.lilypond.general/72885>
but it can be done easier using make-relative in 2.18:
\version "2.18.0"
rhythmTemplate =
#(define-scheme-function (parser location pattern) (ly:music?)
(define-music-function (parser location chord) (ly:music?)
(make-relative (chord) chord
(map-some-music
(lambda (m)
(and (music-is-of-type? m 'skip-event)
(let ((dur (ly:music-property m 'duration))
(art (ly:music-property m 'articulations))
(res (ly:music-deep-copy chord)))
;; transfer duration of skip to all elements with duration
(for-some-music
(lambda (c)
(and (ly:duration? (ly:music-property c 'duration))
(begin
(set! (ly:music-property c 'duration) dur)
#t)))
res)
;; transfer articulations of skip to all relevant targets
(for-some-music
(lambda (c)
(let ((prop
(cond ((music-is-of-type? c 'event-chord) 'elements)
((music-is-of-type? c 'rhythmic-event)
'articulations)
(else #f))))
(and prop
(begin
(set! (ly:music-property c prop)
(append (ly:music-property c prop)
art))
#t))))
res)
res)))
(ly:music-deep-copy pattern)))))
rhya = \rhythmTemplate {s8.-> s16 s8}
rhyb = \rhythmTemplate {s8[ r16 s16 s8]}
rhyc = \rhythmTemplate {s16 s~ s4}
rhyd = \rhythmTemplate { \times 2/3 { s8 s8 s8 } s4 s4 s8 s8 s4 }
rhye = \rhythmTemplate { \times 2/3 { s8---\pp s8-- s8-- } s4--
s4-- s8-- s8-- s4-- }
rhyf = \rhythmTemplate { \times 2/3 { s4 \times 2/3 { s8 s-> s } s4 } }
\score
{
\new Staff \relative c'
{
\time 6/8
\rhya c \rhyb c' |
\rhya <c, e> \rhyb <c f> |
\rhyc <c e> \rhyc <c d> |
\time 5/4
\rhyd c
\rhyd e
\rhye <c e g>
\time 4/4
\rhyf c \rhyf d
}
}
And of course, this just _begs_ for the "pure rhythm" feature of 2.19:
\version "2.19.0"
rhythmTemplate =
#(define-scheme-function (parser location pattern) (ly:music?)
(define-music-function (parser location chord) (ly:music?)
(make-relative (chord) chord
(map-some-music
(lambda (m)
(and (music-is-of-type? m 'note-event)
(not (or (ly:music-property m 'pitch #f)
(ly:music-property m 'drum-type #f)))
(let ((dur (ly:music-property m 'duration))
(art (ly:music-property m 'articulations))
(res (ly:music-deep-copy chord)))
;; transfer duration of skip to all elements with duration
(for-some-music
(lambda (c)
(and (ly:duration? (ly:music-property c 'duration))
(begin
(set! (ly:music-property c 'duration) dur)
#t)))
res)
;; transfer articulations of skip to all relevant targets
(for-some-music
(lambda (c)
(let ((prop
(cond ((music-is-of-type? c 'event-chord) 'elements)
((music-is-of-type? c 'rhythmic-event)
'articulations)
(else #f))))
(and prop
(begin
(set! (ly:music-property c prop)
(append (ly:music-property c prop)
art))
#t))))
res)
res)))
(ly:music-deep-copy pattern)))))
rhya = \rhythmTemplate {8.-> 16 8}
rhyb = \rhythmTemplate {8[ r16 16 8]}
rhyc = \rhythmTemplate {16 16~ 4}
rhyd = \rhythmTemplate { \times 2/3 { 8 8 8 } 4 4 8 8 4 }
rhye = \rhythmTemplate { \times 2/3 { 8---\pp 8-- 8-- } 4--
4-- 8-- 8-- 4-- }
rhyf = \rhythmTemplate { \times 2/3 { 4 \times 2/3 { 8 8-> 8 } 4 } }
\score
{
\new Staff \relative c'
{
\time 6/8
\rhya c \rhyb c' |
\rhya <c, e> \rhyb <c f> |
\rhyc <c e> \rhyc <c d> |
\time 5/4
\rhyd c
\rhyd e
\rhye <c e g>
\time 4/4
\rhyf c \rhyf d
}
}
But it will be some time before that is available in a stable version of
LilyPond.
--
David Kastrup
Re: [LSR v-2.18] "Easy Rhythm Template Creation" does not compile., Thomas Morley, 2014/02/25