lilypond-user
[Top][All Lists]
Advanced

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

Re: How does \musicMap not return music?


From: David Nalesnik
Subject: Re: How does \musicMap not return music?
Date: Wed, 18 Jan 2017 14:10:58 -0600

On Wed, Jan 18, 2017 at 2:04 PM, David Kastrup <address@hidden> wrote:
> Simon Albrecht <address@hidden> writes:
>
>> Hello,
>>
>> surely I overlooked something:
>>
>> I’m writing a function to truncate MMRs for rehearsal MIDI. This is
>> the code so far:
>>
>> %%%%%%%%%%%%%
>> \version "2.19.53"
>>
>> truncateRests =
>> #(define-music-function (mus) (ly:music?)
>>    (let ((trunc-rests (lambda (e) (if (music-is-of-type? e
>> 'multi-measure-rest-event)
>>                                      (ly:music-set-property! e
>> 'duration (ly:make-duration -1))))))
>>      (musicMap trunc-rests mus)))
>>
>> \truncateRests { \time 4/2 R\breve*10 }
>> %%%%%%%%%%%%%%
>>
>> Now Lily complains on that, saying ‘document.ly:9:1: error: music
>> function cannot return ##<unspecified>’. I’m puzzled – musicMap is
>> itself a music function, so how could truncateRests not return music?
>
> Because trunc-rests doesn't?
>
> Its last expression should be e but instead is
>
> (if ... (ly:music-set ...))
>
> which evaluates to *undefined* .
>

Just about to reply with:

truncateRests =
#(define-music-function (mus) (ly:music?)
   (let ((trunc-rests (lambda (e) (if (music-is-of-type? e
'multi-measure-rest-event)
                                      (ly:music-set-property! e
'duration (ly:make-duration -1)))
                        e)))
     (musicMap trunc-rests mus)))

-DN



reply via email to

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