[Top][All Lists]

[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!

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?)
     (lambda (m)
       (if (or (music-is-of-type? m 'sequential-music)
               (music-is-of-type? m 'simultaneous-music))
             (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)
                             (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
                                  (make-music (ly:music-property last-rhythmic-event 'name)
                                              (ly:music-property last-rhythmic-event 'pitch)
                                              (ly:music-property next-event 'duration))
                         (loop other-events
                               (if (music-is-of-type? next-event 'rhythmic-event)
                               (cons next-event acc))))))))

\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:

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):


reply via email to

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