Hello Marc,

Thanks for teaching me this.

As it turns out, we’re better off specifying durations at crucial points to 
avoid « inheriting » such default values, see:

  c'4 d e f \notesToRests \fragment f'8 e c2

below.

JM


\version "2.19.32"

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'4 d e f \notesToRests { g a b2 g8 c } f e c2
}

\relative {
  c'4 d e f \notesToRests \relative { g' a b2 g8 c } f' e c2
}


fragment = \relative { g'4 a b2 g8 c }

\relative {
  c'4 d e f \notesToRests \fragment f'8 e c2
}



> Le 24 nov. 2015 à 08:32, Marc Hohl <m...@hohlart.de> a écrit :
> 
> Am 24.11.2015 um 08:27 schrieb Jacques Menu:
>> Hello Malte,
>> 
>> Interesting, but why are there halves instead of quarters in the second
>> staff?
>> 
> 
> Because the first \relative bock ends with halves and this duration is
> used for the next \relative block as well.
> 
> Just using \relative multiple times doesn't reset the default duration to 4 
> (which would be quite a nuisance, anyway).
> 
> Marc
> 
>> JM
>> 
>> 
>> \version "2.19.32"
>> 
>> 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
>> }
>> 
>> \relative {
>>   c' d e f \notesToRests \relative { g' a b2 g8 c } f' e c2
>> }
>> 
>> 
>> 
>>> Le 24 nov. 2015 à 08:21, Malte Meyn <lilyp...@maltemeyn.de
>>> <mailto:lilyp...@maltemeyn.de>> a écrit :
>>> 
>>> 
>>> 
>>> Am 24.11.2015 um 08:10 schrieb Marc Hohl:
>>>> Thanks or sharing! The drawbacks in relative mode are neglectable, I'll
>>>> use absolute mode.
>>>> 
>>> 
>>> Alternatively you could use
>>> 
>>> 1. another \relative block inside of notesToRests
>>> \relative {
>>>  c' d e f \notesToRests \relative { g' a b2 g8 c } f' e c2
>>> }
>>> 
>>> or
>>> 
>>> 2. octave checks if you don’t mind the warnings
>>> \relative {
>>>  c' d e f \notesToRests { g a b2 g8 c } f='' e c2
>>> }
>>> 
>>> _______________________________________________
>>> lilypond-user mailing list
>>> lilypond-user@gnu.org <mailto:lilypond-user@gnu.org>
>>> https://lists.gnu.org/mailman/listinfo/lilypond-user
>> 
>> 
>> 
>> _______________________________________________
>> lilypond-user mailing list
>> lilypond-user@gnu.org
>> https://lists.gnu.org/mailman/listinfo/lilypond-user
>> 
> 
> 
> _______________________________________________
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to