[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Repeated durations: pitches vs rests
From: |
Jean Abou Samra |
Subject: |
Re: Repeated durations: pitches vs rests |
Date: |
Mon, 22 Feb 2021 22:25:32 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 |
Hello,
For what it's worth, you can do the following.
Please be aware, however, that not being fully
knowledgeable about LilyPond's representation of
music, I cannot guarantee the correctness of this
code in all cases.
Best,
Jean
\version "2.22.0"
implicitRests =
#(define-music-function (music) (ly:music?)
(map-some-music
(lambda (m)
(ly:music-set-property!
m
'elements
(let loop ((remaining-elements (ly:music-property m 'elements))
(last-rhythmic-event #f)
(acc '()))
(if (null? remaining-elements)
(reverse acc)
(let ((next-event (car remaining-elements))
(other-events (cdr remaining-elements)))
(if (and (music-is-of-type? next-event 'note-event)
(null? (ly:music-property next-event 'pitch)))
(loop other-events
last-rhythmic-event
(cons
(make-music (ly:music-property
last-rhythmic-event 'name)
'pitch
(ly:music-property
last-rhythmic-event 'pitch)
'duration
(ly:music-property next-event
'duration))
acc))
(loop other-events
(if (music-is-of-type? next-event
'rhythmic-event)
next-event
last-rhythmic-event)
(cons next-event acc)))))))
#f)
music))
\implicitRests \new Voice \relative {
c'4 4 r4 4
c'4 4 r8 8 4
c d8 r8 8 r4 8
<< { c'4 4 r8 4 8 } \\ { r8 8 16 16 16. 32 2 } >>
}
- Re: Repeated durations: pitches vs rests, (continued)
- Re: Repeated durations: pitches vs rests, David Bellows, 2021/02/22
- Re: Repeated durations: pitches vs rests, Timothy Lanfear, 2021/02/22
- Re: Repeated durations: pitches vs rests, David Bellows, 2021/02/22
- Re: Repeated durations: pitches vs rests, David Kastrup, 2021/02/22
- Re: Repeated durations: pitches vs rests, David Bellows, 2021/02/22
- Re: Repeated durations: pitches vs rests, Martín Rincón Botero, 2021/02/22
- Re: Repeated durations: pitches vs rests, David Bellows, 2021/02/22
- Re: Repeated durations: pitches vs rests, Martín Rincón Botero, 2021/02/22
- Re: Repeated durations: pitches vs rests, David Kastrup, 2021/02/22
- Re: Repeated durations: pitches vs rests, Martín Rincón Botero, 2021/02/23
- Re: Repeated durations: pitches vs rests,
Jean Abou Samra <=
- Re: Repeated durations: pitches vs rests, David Bellows, 2021/02/22
- Re: Repeated durations: pitches vs rests, Jean Abou Samra, 2021/02/22
Re: Repeated durations: pitches vs rests, antlists, 2021/02/22
Re: Repeated durations: pitches vs rests, Flaming Hakama by Elaine, 2021/02/22