[prev in list] [next in list] [prev in thread] [next in thread]
List: lilypond-user
Subject: Re: Snippet
From: Jacques Menu <imj-muzhic () bluewin ! ch>
Date: 2022-04-22 8:05:40
Message-ID: 8DFF5E68-A52F-45F3-BB5C-A915983AE9E6 () bluewin ! ch
[Download RAW message or body]
THANKS A LOT, Jean, that's precisely what I've been struggling with for xml2ly these days…, solved!
I'll use your solution this way:
\score {
\context Staff = "staff1" {
c1
\mergeFullBarRests {
\compressEmptyMeasures
R1 R1 R1 % NO '|' bar mark here!
\bar "||"
| % bar mark is optional here
}
}
}
JM
> Le 22 avr. 2022 à 09:35, MartÃn Rincón Botero <martinrinconbotero@gmail.com> a écrit :
>
> Thank you!
>
> On abr. 21 2022, at 9:10 pm, Jean Abou Samra <jean@abou-samra.fr> wrote:
> Le 21/04/2022 à 19:50, MartÃn Rincón Botero a écrit :
> > Would it be possible to update it to work on Lilypond 2.22.1?
>
>
> The code contains spurious Unicode "zero-width space" characters, one among
> the newlines between the end of append-merge and "mergeSkips =", and another
> between the end of \mergeFullBarRests and \score. Try removing these.
> Updated
> snippet:
>
> \version "2.22.2"
>
> #(define (append-merge x l r)
> "Add x to the head of list l, merging skips,
> and if r is true also merging full measure rests."
> (if (and (pair? l)
> (ly:music? x)
> (ly:music? (car l))
> (or (and (music-is-of-type? x 'skip-event)
> (music-is-of-type? (car l) 'skip-event))
> (and r
> (music-is-of-type? x 'multi-measure-rest)
> (music-is-of-type? (car l) 'multi-measure-rest)))
> (not (pair? (ly:music-property (car l) 'articulations))))
> (let ((total
> (ly:moment-add
> (ly:music-duration-length (car l))
> (ly:music-duration-length x)
> )))
> (set! (ly:music-property x 'duration)
> (make-duration-of-length total))
> (cons x (cdr l)))
> (cons x l)))
>
> mergeSkips = #(define-music-function
> (parser location rests-also music) ((boolean?) ly:music?)
> "Merge successive skips in sequential music,
> optionally merge full-measure rests as well."
> (music-map
> (lambda (m)
> (if (music-is-of-type? m 'sequential-music)
> (ly:music-set-property! m
> 'elements
> (fold-right (lambda (x l)
> (append-merge x l rests-also))
> '()
> (ly:music-property m 'elements))))
> m)
> music))
>
> mergeFullBarRests = #(define-music-function
> (parser location music) (ly:music?)
> #{ \mergeSkips ##t $music #})
>
> \score {
> \mergeFullBarRests {
> \context Staff = "staff1" {
> \compressEmptyMeasures
> c1 R1 R1 R1
> }
> }
> }
>
>
> Best,
> Jean
>
[Attachment #3 (unknown)]
<html><head><meta http-equiv="Content-Type" content="text/html; \
charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
line-break: after-white-space;" class="">THANKS A LOT, Jean, that's precisely what \
I've been struggling with for xml2ly these days…, solved!<div class=""><br \
class=""></div><div class="">I'll use your solution this way:</div><div class=""><br \
class=""></div><div class=""><div class="">\score {</div><div class=""> \
\context Staff = "staff1" {</div><div class=""> c1</div><div \
class=""> \mergeFullBarRests {</div><div class=""> \
\compressEmptyMeasures</div><div class=""> R1 R1 R1 % \
NO '|' bar mark here!</div><div class=""> \bar "||"</div><div \
class=""> | % bar mark is optional here</div><div \
class=""> }</div><div class=""> }</div><div \
class="">}</div></div><div class=""><br class=""></div><div class="">JM<br \
class=""><div><br class=""><blockquote type="cite" class=""><div class="">Le 22 avr. \
2022 à 09:35, MartÃn Rincón Botero <<a \
href="mailto:martinrinconbotero@gmail.com" \
class="">martinrinconbotero@gmail.com</a>> a écrit :</div><br \
class="Apple-interchange-newline"><div class=""><div class="">Thank you!</div><br \
class=""><div class="gmail_quote_attribution">On abr. 21 2022, at 9:10 pm, Jean Abou \
Samra <<a href="mailto:jean@abou-samra.fr" class="">jean@abou-samra.fr</a>> \
wrote:</div><blockquote class=""><div class=""><div class="">Le 21/04/2022 Ã 19:50, \
MartÃn Rincón Botero a écrit :</div><div class="">> Would it be possible \
to update it to work on Lilypond 2.22.1?</div><br class=""><br class=""><div \
class="">The code contains spurious Unicode "zero-width space" characters, one \
among</div><div class="">the newlines between the end of append-merge and "mergeSkips \
=", and another</div><div class="">between the end of \mergeFullBarRests and \score. \
Try removing these.</div><div class="">Updated</div><div class="">snippet:</div><br \
class=""><div class="">\version "2.22.2"</div><br class=""><div class="">#(define \
(append-merge x l r)</div><div class="">"Add x to the head of list l, merging \
skips,</div><div class="">and if r is true also merging full measure \
rests."</div><div class=""> (if (and (pair? l)</div><div \
class=""> (ly:music? \
x)</div><div class=""> \
(ly:music? (car l))</div><div \
class=""> (or (and \
(music-is-of-type? x 'skip-event)</div><div \
class=""> \
(music-is-of-type? (car l) 'skip-event))</div><div \
class=""> \
(and r</div><div class=""> \
(music-is-of-type? x 'multi-measure-rest)</div><div \
class=""> \
(music-is-of-type? (car l) 'multi-measure-rest)))</div><div \
class=""> (not (pair? \
(ly:music-property (car l) 'articulations))))</div><div \
class=""> (let ((total</div><div \
class=""> \
(ly:moment-add</div><div \
class=""> \
(ly:music-duration-length (car l))</div><div \
class=""> \
(ly:music-duration-length x)</div><div \
class=""> \
)))</div><div class=""> (set! (ly:music-property \
x 'duration)</div><div \
class=""> \
(make-duration-of-length total))</div><div \
class=""> (cons x (cdr l)))</div><div \
class=""> (cons x l)))</div><br class=""><div class="">mergeSkips = \
#(define-music-function</div><div class=""> (parser location rests-also music) \
((boolean?) ly:music?)</div><div class=""> "Merge successive skips in sequential \
music,</div><div class=""> optionally merge full-measure rests as \
well."</div><div class=""> (music-map</div><div class=""> (lambda \
(m)</div><div class=""> (if (music-is-of-type? m \
'sequential-music)</div><div class=""> \
(ly:music-set-property! m</div><div \
class=""> \
'elements</div><div class=""> \
(fold-right (lambda (x l)</div><div \
class=""> \
(append-merge x l rests-also))</div><div \
class=""> \
'()</div><div class=""> \
(ly:music-property m 'elements))))</div><div class=""> \
m)</div><div class=""> music))</div><br class=""><div \
class="">mergeFullBarRests = #(define-music-function</div><div class=""> (parser \
location music) (ly:music?)</div><div class=""> #{ \mergeSkips ##t $music \
#})</div><br class=""><div class="">\score {</div><div class=""> \
\mergeFullBarRests {</div><div class="">\context Staff = "staff1" {</div><div \
class=""> \compressEmptyMeasures</div><div class=""> c1 R1 R1 \
R1</div><div class="">}</div><div class=""> }</div><div class=""> \
}</div><br class=""><br class=""><div class="">Best,</div><div \
class="">Jean</div></div></blockquote><img class="mailspring-open" alt="Sent from \
Mailspring" width="0" height="0" style="border:0; width:0; height:0;" \
src="https://link.getmailspring.com/open/F20B217E-826F-46EC-9F77-4B0084C04B20@getmails \
pring.com?me=8a1a64be&recipient=bGlseXBvbmQtdXNlckBnbnUub3Jn"></div></blockquote></div><br \
class=""></div></body></html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic