lilypond-user
[Top][All Lists]
Advanced

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

Re: [Scheme coding] how to turn pitches into music


From: Aaron Hill
Subject: Re: [Scheme coding] how to turn pitches into music
Date: Sat, 25 Jan 2020 08:36:15 -0800
User-agent: Roundcube Webmail/1.3.8

On 2020-01-25 8:23 am, Aaron Hill wrote:
On 2020-01-25 7:48 am, Kieren MacMillan wrote:
Also: I notice that rests and skips are ignored:

This is intuitive/understandable to me (given the functions we’re
using); and I’m glad they’re just ignored [rather than causing
errors]. But how can I turn every rest or skip into a skip [of
equivalent duration] in the output? My intuition tells me I should use
an if statement… but I’m betting there’s a more automagic way.  =)

My reading comprehension skills are quite lacking today... :P

You wanted to convert rests to skips, and I ignored that. This should work:

%%%%
\version "2.19.83"

rests-to-skips =
#(define-music-function (music) (ly:music?)
  (music-map
    (lambda (elem)
      (if (memq 'rest-event (ly:music-property elem 'types))
(make-music 'SkipEvent 'duration (ly:music-property elem 'duration))
        elem))
    music)
  music)

test = { c'4 r d' s e' r f' s g' }

<<
  { \test }
  { \rests-to-skips \test }

%%%%


-- Aaron Hill



reply via email to

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