[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 23:01:28 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 |
Le 22/02/2021 à 22:42, David Bellows a écrit :
Hello Jean,
That works basically like I was hoping it would! Thank you very much
for the effort you put into this. I suppose the only issue is that it
spits out a warning when a tilde is used: "r8~ 16" but still prints it
out properly.
I know absolutely nothing about Scheme coding in LilyPond so I have no
idea how correct your code is, hopefully someone will take a closer
look at it?
Thank you very much!
Dave
Try this version that stops adding empty
'elements on every event, and suppresses
tie events from rest events:
\version "2.22.0"
implicitRests =
#(define-music-function (music) (ly:music?)
(map-some-music
(lambda (m)
(if (or (music-is-of-type? m 'sequential-music)
(music-is-of-type? m 'simultaneous-music))
(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 (music-is-of-type? next-event 'rest-event)
(ly:music-set-property!
next-event
'articulations
(filter
(lambda (maybe-tie)
(not (music-is-of-type? maybe-tie
'tie-event)))
(ly:music-property next-event 'articulations))))
(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))
\displayMusic \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 } >>
}
If you want to learn about Scheme coding:
https://scheme-book.ursliska.de/introduction/index.html
There is also the extending manual, of which
this section is particularly relevant (basically,
\displayMusic does the job of showing you how
to construct and modify music):
lilypond.org/doc/v2.22/Documentation/extending/displaying-music-expressions.html
Regards,
Jean
- Re: Repeated durations: pitches vs rests, (continued)
- 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, 2021/02/22
- Re: Repeated durations: pitches vs rests, David Bellows, 2021/02/22
- Re: Repeated durations: pitches vs rests,
Jean Abou Samra <=
Re: Repeated durations: pitches vs rests, antlists, 2021/02/22
Re: Repeated durations: pitches vs rests, Flaming Hakama by Elaine, 2021/02/22