Le mardi 13 juin 2023 à 11:13 +0200, Valentin Petzel a écrit : > ``` > bargrid = > #(define-music-function (d type mus) (pair? string? ly:music?) > (let* ((mus-len (ly:music-length mus)) > (mus-len (/ (ly:moment-main-numerator mus-len) > (ly:moment-main-denominator mus-len))) > (d (/ (car d) (cdr d))) > (n (floor (/ mus-len d)))) > #{ > << > #mus > { > $@(apply > append > (make-list n > (list > (make-music 'SkipEvent 'duration (ly:make-duration > 0 0 d)) > (make-music 'BarEvent 'bar-type type)))) > } > ```
Danger: here you are sharing the same SkipEvent and BarEvent music expressions n times, without copying. While mutations on those are relatively rare I think, they could happen. For example, with \scaleDurations. If you want to go this route, I think it's easier to just do ``` \version "2.25.5" #(set-default-paper-size "a0") #(set-global-staff-size 15) mus = { \relative c''''' \repeat unfold 2 { c c c c }} % modify the \repeat unfold value for testing, final version should be 40 #(define my-semitone->pitch (make-semitone->pitch (music-pitches #{ { c cis d ees e f fis g gis a bes b } #}))) bargrid = #(define-music-function (d mus) (ly:duration? ly:music?) (let* ((mus-len (ly:moment-main (ly:music-length mus))) (n (floor (/ mus-len (ly:moment-main (ly:duration-length d)))))) #{ << #mus \repeat unfold #n { s $d \allowBreak } >> #})) \new StaffGroup << #@(map (lambda (i) #{ \new Staff { \bargrid 1 \scaleDurations #(cons 120 i) { \transpose c' #(my-semitone->pitch (- (- 120 i))) { #(cond ((<= 108 i 120) #{ \ottava 2 #}) ((<= 97 i 107) #{ \ottava 1 #}) ((<= 72 i 96) #{ \ottava 0 #}) ((<= 48 i 71) #{ \clef bass #}) ((<= 33 i 47) #{ \clef bass \ottava -1 #} ) (else #{ #})) \mus } } } #}) (iota 88 120 -1)) >> \layout { indent = #0 \context { \Score \override SpacingSpanner.base-shortest-duration = #(ly:make-moment 1/4) proportionalNotationDuration = #(ly:make-moment 1/10) \override SpacingSpanner.uniform-stretching = ##t \override SpacingSpanner.strict-note-spacing = ##t %forbidBreakBetweenBarLines = ##f \cadenzaOn } \context { \Staff \remove Time_signature_engraver } \context { \Voice \remove Forbid_line_break_engraver } } ```
signature.asc
Description: This is a digitally signed message part