lilypond-user
[Top][All Lists]
Advanced

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

Re: Replace ly:music elements in a Scheme function


From: paolo prete
Subject: Re: Replace ly:music elements in a Scheme function
Date: Mon, 5 Mar 2018 14:12:35 +0100

Hello David,
thanks for the snippet but I ask if it is possible to modify only the body of my function, inside lambda (x y)( ...  ) so to obtain the same result.
Something like:


%%%%%%%%

fun = #(define-music-function (parser location music1 music2) (ly:music? ly:music?)
(let
    (
      (musicList1 (ly:music-property music1 'elements))
      (musicList2 (ly:music-property music2 'elements))
    )
    (map 
        (lambda (x y) 
          ;  
          ;  place HERE the code for copying the WHOLE y element to the whole x element
          ;  (where y and x have the same position in their corresponding lists)
          ;
        ) 
     musicList1 musicList2
    )
)
#{ $music1 #})

{
\fun {c' r e'} {f' g' a'}
}

2018-03-05 13:42 GMT+01:00 David Kastrup <address@hidden>:
paolo prete <address@hidden> writes:

> in the snippet below I want to replace, while iterating two lists, the
> elements of music1 with the elements of music2.
> The code shows how to do that for pitches, but how can I replace the whole
> element? (for example, a rest or a note with its articulation)
> %%%%%%%%
>
> fun = #(define-music-function (parser location music1 music2) (ly:music?
> ly:music?)
> (let
>     (
>       (musicList1 (ly:music-property music1 'elements))
>       (musicList2 (ly:music-property music2 'elements))
>     )
>     (map
>         (lambda (x y)
>           ;iterate notes
>           (display "note found\n")
>           ;(set! (ly:music-property x 'pitch) #{c'#})
>           ;(ly:music-set-property! x 'pitch #{c' #})
>           (ly:music-set-property! x 'pitch (ly:music-property y 'pitch))
>         )
>      musicList1 musicList2
>     )
> )
> #{ $music1 #})
>
> {
> \fun {c' d' e'} {f' g' a'}
> }

Something like



I'm fuzzy on what music1 is actually good for at all since only a scant
sketch of its structure is used at all.  Probably you need to vary/copy
more from the original.  The music-clone function can take additional
arguments: maybe that allows you to do something more useful.

--
David Kastrup



reply via email to

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