lilypond-user
[Top][All Lists]
Advanced

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

Re: function to replace notes by rests


From: David Kastrup
Subject: Re: function to replace notes by rests
Date: Tue, 24 Nov 2015 09:52:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Marc Hohl <address@hidden> writes:

> Am 23.11.2015 um 21:41 schrieb Malte Meyn:
>> Am 23.11.2015 um 10:46 schrieb Marc Hohl:
>>> As the file is a bit lengthy, I think of a way to just redefine
>>> \xNotes to change every note to its corresponding rest, instead of
>>> rewriting the whole file (or using sed or any other external script).
>>>
>>> Has anyone a scheme routine at hand that does exactly this job?
>
> Malte,
>
>> I wrote this but it doesn’t work well in relative mode:
>>
>> \version "2.19.30"
>>
>> notesToRests =
>> #(define-music-function (music) (ly:music?)
>>     (music-map
>>      (lambda (m)
>>        (if (eq? (ly:music-property m 'name) 'NoteEvent)
>>            (make-music 'RestEvent
>>              'duration (ly:music-property m 'duration))
>>            m))
>>      music))
>>
>> \relative {
>>    c' d e f \notesToRests { g a b2 g8 c } f e c2
>> }
>
> Thanks or sharing! The drawbacks in relative mode are neglectable,
> I'll use absolute mode.

\version "2.19.30"

notesToRests =
#(define-music-function (music) (ly:music?)
   (make-relative (music) music
    (music-map
     (lambda (m)
       (if (eq? (ly:music-property m 'name) 'NoteEvent)
           (make-music 'RestEvent
             'duration (ly:music-property m 'duration))
           m))
     (ly:music-deep-copy music))))

\relative {
   c' d e f \notesToRests { g a b2 g8 c } f e c2
}
-- 
David Kastrup

reply via email to

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