Re: Thanks to David Nalesnik and Jan-Peter Voigt
On Thu, Oct 2, 2014 at 7:28 AM, David Nalesnik wrote: > > > On Wed, Oct 1, 2014 at 4:41 PM, Jay Vara wrote: > >> >> >> >>> I wonder two things: >>> >>> (1) Is there a way to combine the notes and rests in the 1/4 division of >>> the bars? >>> >> >> Not sure what you mean. >> > > In the example below, it looks strange that there are two tied eighth-note > Gs instead of a single quarter-note. The engraver ought to combine them, > especially since I asked for 1/4. (It does this when the division is 2/8 > as well.) > > >> >>> (2) Why the inconsistency in the rests in the 3/8 divisions? >>> Quarter-eighth is correct. Why is this reversed the second time? >>> >>> I think what it has done is correct. It is reversed the second time >> because in that case the first rest is split into eights by the >> Completion_rest_engraver. Whatever rest occurs on the barline is split and >> no attempt is made to correct the input. Is this not what you expect? >> > > I'm expecting the result to be notated correctly, and this snippet isn't. > The 3/8 division of the bar should be notated with a dotted-quarter rest > (or in older practice a quarter rest followed by an eighth). An eighth > followed by a quarter rest is incorrect. > > For me this sort of thing would be a deal-breaker with using the > completion engraver with compound meters. These are errors I'd like to be > able to correct, and you can't do it here. At least not that I know of. > Perhaps the notational problems here are related to the obviously bad results below. Don't believe I'm doing anything wrong. Why does the dotted half refuse to be split? I'll have to do some study of the code to see what's going on. \version "2.18.2" musicA = { \compoundMeter #'(3 2 3 8) \relative c' { c'2. d4 b2. c4 a2. b4 g2. a4 f2. g4 } } patterning = { \repeat unfold 8 { \set Staff.completionUnit = #(ly:make-moment 3 8) s4. \bar "!" \set Staff.completionUnit = #(ly:make-moment 2 8) s4 \bar "!" \set Staff.completionUnit = #(ly:make-moment 3 8) s4. \bar "||" } } \score { \new Staff << \new Voice \musicA \new Voice \patterning >> \layout { \context { \Voice \override SpacingSpanner.uniform-stretching = ##t \remove Note_heads_engraver \consists Completion_heads_engraver \remove Rest_engraver \consists Completion_rest_engraver } } } %%% --David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
On Thu, Oct 2, 2014 at 7:11 AM, Jay Vara wrote: > David, > > I tried your snippet with a different meter and it gives some weird > results. It seems to produce additional bars - I changed the bar after the > compound meter to double bar so we can see the extraneous bars. And the > notes are not placed properly. Am I doing something totally foolish here? > > > > \version "2.18.2" > > musicA = { > > \compoundMeter #'((2 4) (4 4)) > > \relative c' { > > c'2. d4 b2. c4 a2. b4 g2. a4 f2. g4 > > } > The problem is here: you need to change the durations of the spacer rests to reflect your measure divisions: patterning = { \repeat unfold 8 { \set Staff.completionUnit = #(ly:make-moment 2 4) s2 \bar "!" \set Staff.completionUnit = #(ly:make-moment 4 4) s1 \bar "||" } } Then it works just fine! David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
On Wed, Oct 1, 2014 at 4:41 PM, Jay Vara wrote: > > > >> I wonder two things: >> >> (1) Is there a way to combine the notes and rests in the 1/4 division of >> the bars? >> > > Not sure what you mean. > In the example below, it looks strange that there are two tied eighth-note Gs instead of a single quarter-note. The engraver ought to combine them, especially since I asked for 1/4. (It does this when the division is 2/8 as well.) > >> (2) Why the inconsistency in the rests in the 3/8 divisions? >> Quarter-eighth is correct. Why is this reversed the second time? >> >> I think what it has done is correct. It is reversed the second time > because in that case the first rest is split into eights by the > Completion_rest_engraver. Whatever rest occurs on the barline is split and > no attempt is made to correct the input. Is this not what you expect? > I'm expecting the result to be notated correctly, and this snippet isn't. The 3/8 division of the bar should be notated with a dotted-quarter rest (or in older practice a quarter rest followed by an eighth). An eighth followed by a quarter rest is incorrect. For me this sort of thing would be a deal-breaker with using the completion engraver with compound meters. These are errors I'd like to be able to correct, and you can't do it here. At least not that I know of. --David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
David, I tried your snippet with a different meter and it gives some weird results. It seems to produce additional bars - I changed the bar after the compound meter to double bar so we can see the extraneous bars. And the notes are not placed properly. Am I doing something totally foolish here? \version "2.18.2" musicA = { \compoundMeter #'((2 4) (4 4)) \relative c' { c'2. d4 b2. c4 a2. b4 g2. a4 f2. g4 } } patterning = { \repeat unfold 8 { \set Staff.completionUnit = #(ly:make-moment 2 4) s4. \bar "!" \set Staff.completionUnit = #(ly:make-moment 4 4) s4 \bar "||" } } \score { \new Staff << \new Voice \musicA \new Voice \patterning >> \layout { \context { \Voice \override SpacingSpanner.uniform-stretching = ##t \remove Note_heads_engraver \consists Completion_heads_engraver \remove Rest_engraver \consists Completion_rest_engraver } } } %%% [image: Inline image 1] ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
David > Apparently, the context property completionUnit needs to be set for the > engraver to recognize sub-bar groupings. > > This gets better results: > > Nice. I did try the completionUnit before, but I was trying to put it in the music section rather than the pattern section and there it would not work because you do not have the luxury of repeat unfold. This method seems to work better, although the engraver is automatic. > I wonder two things: > > (1) Is there a way to combine the notes and rests in the 1/4 division of > the bars? > Not sure what you mean. > > (2) Why the inconsistency in the rests in the 3/8 divisions? > Quarter-eighth is correct. Why is this reversed the second time? > > I think what it has done is correct. It is reversed the second time because in that case the first rest is split into eights by the Completion_rest_engraver. Whatever rest occurs on the barline is split and no attempt is made to correct the input. Is this not what you expect? > > > Anyway, hope this helps. > > It idefinitely helps in many ways. Not only does it help with the immediate problem, it also teaches ways of doing things in lilypod and guile in more depth than the manuals. I am quite thankful for this. Jay ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
On Wed, Oct 1, 2014 at 12:14 PM, Jay Vara wrote: Also, I just saw your next note - that note and rest events do not cross > added bar lines. In that case, what do they mean by sub-bar units in > lily/completion-noteheads-engraver.cc? If they mean sub-bar units of the > compound meter, they should work for your snippet and they do not. > Apparently, the context property completionUnit needs to be set for the engraver to recognize sub-bar groupings. This gets better results: \version "2.19.10" musicA = { \compoundMeter #'((3 8) (1 4)) \relative c' { c4 d e f g r4 r r r r } } patterning = { \repeat unfold 4 { \set Staff.completionUnit = #(ly:make-moment 3/8) s4. \bar "!" \set Staff.completionUnit = #(ly:make-moment 1/4) s4 } } \score { \new Staff << \new Voice \musicA \new Voice \patterning >> \layout { \context { \Voice \remove Note_heads_engraver \consists Completion_heads_engraver \remove Rest_engraver \consists Completion_rest_engraver } } } %%% I wonder two things: (1) Is there a way to combine the notes and rests in the 1/4 division of the bars? (2) Why the inconsistency in the rests in the 3/8 divisions? Quarter-eighth is correct. Why is this reversed the second time? Anyway, hope this helps. --David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
> > Hi David, > > The problem is that the Completion_heads_engraver and the > Completion_rests_engraver do not appear to respond to sub-bar patterning, > as the following snippet demonstrates: > > > I would need to spend more time with lily/completion-noteheads-engraver.cc > to understand what goes on there, but a comment at the head of the file > suggests that my snippet should work: > > "Every time process_music () is called and there are note events, we > figure out how long the note to typeset should be. It should be no longer > than what's specified, than what is left to do and it should not cross > barlines or sub-bar units." > > The gist is, I don't know if it's possible to do what you'd like to do > without fixing or enhancing the C++ engravers. > > --David > > > I initially had the sub-bar dotted lines generated by adding a simultaneous silent voice with bar lines as in {s2 s4 \bar "!" s1 \bar "|"} for the compound time (3 4 4). I had to go the engraver route mainly because Completion_heads_engraver was not working. For now, we know that there is an issue with timing of when we set the measureLength and when Completion heads gets involved. However, for all the compound meters that I am using, it seems to be working. Also, I just saw your next note - that note and rest events do not cross added bar lines. In that case, what do they mean by sub-bar units in lily/completion-noteheads-engraver.cc? If they mean sub-bar units of the compound meter, they should work for your snippet and they do not. Thanks, Jay ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
On Wed, Oct 1, 2014 at 11:52 AM, David Nalesnik wrote: > > > "Every time process_music () is called and there are note events, we > figure out how long the note to typeset should be. It should be no longer > than what's specified, than what is left to do and it should not cross > barlines or sub-bar units." > > Unfortunately, note- and rest-events do cross added barlines. So much for a super-simple solution. \version "2.18.0" musicA = { \compoundMeter #'((3 2 16)) \relative c' { c8 d e f g r8 r r r r } } patterning = { \repeat unfold 4 { s8. \bar "!" s8 } } \score { \new Staff << \new Voice \musicA \new Voice \patterning >> \layout { \context { \Voice \remove Note_heads_engraver \remove Rest_engraver \consists Completion_heads_engraver \consists Completion_rest_engraver } } } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
Hi Jay, On Mon, Sep 29, 2014 at 3:42 AM, Jay Vara wrote: > Hi David, > > Thank you very much. Now I know how to use the listeners! > > With your change it seems to work for the two-staff example with (7 4) (1 > 4) (2 4) meter. This is the only case of compound metre that I commonly use > that has a (1 4) as one of the components. > > Just to be sure, I did check a few other metres, and whenever there is a > (1 4) an issue is possible. Typically the problems seem to be in the first > few measures. For example, the two staff example with meter = #'((1 4) (2 > 4)) gives the following. > > True, it does break down. I strongly suspect that the issue is one of timing. Perhaps measureLength is being changed too late in the game for the Completion_heads_engraver to make use of it as you would like. I wonder about the approach here. You are wanting to feed a series of algorithmically generated durations into LilyPond and have it return rhythms which are adjusted to fit within a given meter, such that durations are split across barlines and durations are split across the sub-bar units specified by the meter. You would like to have the sub-bars marked by regular barlines and the ordinary bars replaced by double barlines. If I'm understanding this correctly, I see two issues: (1) The standard way to notate this would be with dotted barlines within the measures, which are separated by standard barlines, (2) Resetting measureLength messes up measure numbering. It should not be too difficult to achieve the sub-bars--add this type of barline every so many moments. The problem is that the Completion_heads_engraver and the Completion_rests_engraver do not appear to respond to sub-bar patterning, as the following snippet demonstrates: \version "2.18.0" musicA = { \compoundMeter #'((3 2 16)) \relative c' { c8 d e f g r8 r r r r } } \score { \new Staff \musicA \layout { \context { \Voice \remove Note_heads_engraver \remove Rest_engraver \consists Completion_heads_engraver \consists Completion_rest_engraver } } } I would need to spend more time with lily/completion-noteheads-engraver.cc to understand what goes on there, but a comment at the head of the file suggests that my snippet should work: "Every time process_music () is called and there are note events, we figure out how long the note to typeset should be. It should be no longer than what's specified, than what is left to do and it should not cross barlines or sub-bar units." The gist is, I don't know if it's possible to do what you'd like to do without fixing or enhancing the C++ engravers. --David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
Hi David, Thank you very much. Now I know how to use the listeners! With your change it seems to work for the two-staff example with (7 4) (1 4) (2 4) meter. This is the only case of compound metre that I commonly use that has a (1 4) as one of the components. Just to be sure, I did check a few other metres, and whenever there is a (1 4) an issue is possible. Typically the problems seem to be in the first few measures. For example, the two staff example with meter = #'((1 4) (2 4)) gives the following. [image: Inline image 2] Best regards Jay On Mon, Sep 29, 2014 at 1:37 AM, David Nalesnik wrote: > Hi Jay, > > On Sun, Sep 28, 2014 at 7:24 PM, David Nalesnik > wrote: >> >> >> Possibly the problem is that the custom engraver is setting measureLength >> too late for Completion_heads_engraver to use it? >> >> > That just might be it. The Completion_heads_engraver listens for > note-events. So, doing this same with the custom engraver gives us the > code below: > > alternateTiming = > #(lambda (sig) >(lambda (context) > (let ((last-bnum 0)) >(make-engraver > (listeners ((note-event engraver event) > (let* ((bnum (ly:context-property context > 'currentBarNumber)) >(len (length sig)) ; how many terms in compound > meter >(pos (modulo bnum len)) >(pos (if (= 0 pos) len pos)) ; first bar in > pattern, second... >(pos-in-list (1- pos)) ; because elements of > list are numbered from 0 >(desired-measure-len (to-moment (list-ref sig > pos-in-list > (ly:context-set-property! context 'measureLength > desired-measure-len) > (format #t "bnum = ~a len ~a pos ~a measurelength ~a > completion ~a~%" > bnum len pos > (ly:context-property context 'measureLength) > (ly:context-property context 'completionUnit)) > (if (= pos-in-list 0) > (begin >(if (> bnum last-bnum) >(ly:context-set-property! context 'whichBar > "||")) >(set! last-bnum bnum)) > > %%% > > This appears to work with your two-staff example. How it fares with > others, I don't know. Keep your fingers crossed. > > Note: You're using an older syntax for Scheme engravers. I've adapted > this one to use the make-engraver macro that David Kastrup introduced at > some point. > > Best, > David > > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
Hi David, Actually, your logic and reasoning were quite correct. Only, the format statement was before the measureLength was set. I moved the format statement after the context-set-property and it now shows that the engraver does successfully reset the meter. I think the real problem is with the Completion_heads_engraver (probably a bug). To illustrate this, I added another line of simultaneous music - the only difference is the 4th note f - quarter note in one case and half note in the other. Here is the what it prints out: [image: Inline image 1] In the top staff, the second measure should have one quarter note and it has a half note (which should have been split and tied). In the third measure it should have had two quarter notes - it has instead only one quarter note. In the bottom staff, the second and third measure have the correct number of quarter notes. However, the a2 note in the third measure is split into two a4 notes and tied! It is looking more like a Completion_heads_engraver bug. Here is the program: \version "2.18.0" meter = #'((7 4) (1 4) (2 4)) #(define (to-moment arg) (ly:make-moment (car arg) (cadr arg))) alternateTiming = #(lambda (sig) (lambda (context) (let ((last-bnum 0)) `((process-music . ,(lambda (trans) (let* ((bnum (ly:context-property context 'currentBarNumber)) (len (length sig)) ; how many terms in compound meter (pos (modulo bnum len)) (pos (if (= 0 pos) len pos)) ; first bar in pattern, second... (pos-in-list (1- pos)) ; because elements of list are numbered from 0 (desired-measure-len (to-moment (list-ref sig pos-in-list (ly:context-set-property! context 'measureLength desired-measure-len) (format #t "bnum = ~a len ~a pos ~a measurelength ~a ~%" bnum len pos (ly:context-property context 'measureLength)) (if (= pos-in-list 0) (begin (if (> bnum last-bnum) (ly:context-set-property! context 'whichBar "||")) (set! last-bnum bnum)) musicA = { \compoundMeter #meter \relative c' {c d e2 f4 g2 a b c4 b2 a g4 f2 e d c d e f g a b c d4} } musicB = { \compoundMeter #meter \relative c' {c d e2 f g2 a b c4 b2 a g4 f2 e d c d e f g a b c d4} } \score { << \new Staff \musicA \new Staff \musicB >> \layout { \context { \Score \consists #(alternateTiming meter) } \context { \Voice \remove Note_heads_engraver \remove Rest_engraver \consists Completion_heads_engraver \consists Completion_rest_engraver } } } On Sun, Sep 28, 2014 at 10:24 PM, David Nalesnik wrote: > Hi Jay, > > > On Sun, Sep 28, 2014 at 3:29 PM, Jay Vara wrote: > >> David, >> >> If I use the compound meter which has a (1 4) as one of the moments, it >> does not work. It seems to be treated as a (2 4). Actually, I think the >> Completion_heads_engraver may be the one with a problem. I checked by >> varying the music and for situations where the Completion_heads_engraver >> did not have to create a tie in the (1 4) measure, it was OK. >> >> meter = #'((7 4) (1 4) (2 4)) >> >> > I > This makes my head hurt, and my reasoning may need straightening out... > > Taking a shorter example: > > meter = #'((3 4) (2 4)) > > used with > > music = { > \compoundMeter #meter > \relative c' {c1 c4} > } > > suggests to me that the problem happens when the engraver doesn't > successfully reset the meter. > > The log for the above values is: > bnum = 1 measurelength # > bnum = 2 measurelength # > bnum = 2 measurelength # > bnum = 3 measurelength # > > So measureLength of the first bar is 5/4--that is, the sum of the terms of > the compound meter, which is what was assigned by \compoundMeter #meter. > The meter has not been reset. > > There needs to be a second note within the proposed first division of 3/4 > for the new meter to take effect. > > meter = #'((3 4) (2 4)) > > \relative c' {c2 c2} > > The log shows that the measureLength of the first measure is reset: > > bnum = 1 measurelength # > bnum = 1 measurelength # > bnum = 2 measurelength # > bnum = 2 measurelength # > > At the moment, my head is too tangled up to do something positive with > this information. I hope it will help, in any case. > > --David. > > > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
Hi Jay, On Sun, Sep 28, 2014 at 7:24 PM, David Nalesnik wrote: > > > Possibly the problem is that the custom engraver is setting measureLength > too late for Completion_heads_engraver to use it? > > That just might be it. The Completion_heads_engraver listens for note-events. So, doing this same with the custom engraver gives us the code below: alternateTiming = #(lambda (sig) (lambda (context) (let ((last-bnum 0)) (make-engraver (listeners ((note-event engraver event) (let* ((bnum (ly:context-property context 'currentBarNumber)) (len (length sig)) ; how many terms in compound meter (pos (modulo bnum len)) (pos (if (= 0 pos) len pos)) ; first bar in pattern, second... (pos-in-list (1- pos)) ; because elements of list are numbered from 0 (desired-measure-len (to-moment (list-ref sig pos-in-list (ly:context-set-property! context 'measureLength desired-measure-len) (format #t "bnum = ~a len ~a pos ~a measurelength ~a completion ~a~%" bnum len pos (ly:context-property context 'measureLength) (ly:context-property context 'completionUnit)) (if (= pos-in-list 0) (begin (if (> bnum last-bnum) (ly:context-set-property! context 'whichBar "||")) (set! last-bnum bnum)) %%% This appears to work with your two-staff example. How it fares with others, I don't know. Keep your fingers crossed. Note: You're using an older syntax for Scheme engravers. I've adapted this one to use the make-engraver macro that David Kastrup introduced at some point. Best, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
Hi Jay, On Sun, Sep 28, 2014 at 5:46 PM, Jay Vara wrote: > Hi David, > > Actually, your logic and reasoning were quite correct. Only, the format > statement was before the measureLength was set. I moved the format > statement after the context-set-property and it now shows that the engraver > does successfully reset the meter. > > I think the real problem is with the Completion_heads_engraver (probably a > bug). To illustrate this, I added another line of simultaneous music - the > only difference is the 4th note f - quarter note in one case and half note > in the other. > > Here is the what it prints out: > > [image: Inline image 1] > > In the top staff, the second measure should have one quarter note and it > has a half note (which should have been split and tied). In the third > measure it should have had two quarter notes - it has instead only one > quarter note. > > In the bottom staff, the second and third measure have the correct number > of quarter notes. However, the a2 note in the third measure is split into > two a4 notes and tied! > > It is looking more like a Completion_heads_engraver bug. > > I couldn't say. The Completion_heads_engraver seems pretty hardy, however. I mean it can deal with this example: \version "2.18.0" music = { \relative c' {c1 c c c c c c c8} } \score { \new Staff << \new Voice { \music } \new Voice { \repeat unfold 6 { \time 5/16 s16*5 \time 3/8 s4. \time 1/2 s2 } } >> \layout { \context { \Voice \remove Note_heads_engraver \remove Rest_engraver \consists Completion_heads_engraver \consists Completion_rest_engraver } } } %%% Possibly the problem is that the custom engraver is setting measureLength too late for Completion_heads_engraver to use it? --David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
Hi Jay, On Sun, Sep 28, 2014 at 3:29 PM, Jay Vara wrote: > David, > > If I use the compound meter which has a (1 4) as one of the moments, it > does not work. It seems to be treated as a (2 4). Actually, I think the > Completion_heads_engraver may be the one with a problem. I checked by > varying the music and for situations where the Completion_heads_engraver > did not have to create a tie in the (1 4) measure, it was OK. > > meter = #'((7 4) (1 4) (2 4)) > > I This makes my head hurt, and my reasoning may need straightening out... Taking a shorter example: meter = #'((3 4) (2 4)) used with music = { \compoundMeter #meter \relative c' {c1 c4} } suggests to me that the problem happens when the engraver doesn't successfully reset the meter. The log for the above values is: bnum = 1 measurelength # bnum = 2 measurelength # bnum = 2 measurelength # bnum = 3 measurelength # So measureLength of the first bar is 5/4--that is, the sum of the terms of the compound meter, which is what was assigned by \compoundMeter #meter. The meter has not been reset. There needs to be a second note within the proposed first division of 3/4 for the new meter to take effect. meter = #'((3 4) (2 4)) \relative c' {c2 c2} The log shows that the measureLength of the first measure is reset: bnum = 1 measurelength # bnum = 1 measurelength # bnum = 2 measurelength # bnum = 2 measurelength # At the moment, my head is too tangled up to do something positive with this information. I hope it will help, in any case. --David. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
>I am not top-posting David, All I can say is I am amazed at your expertise. You have already saved me a few days of work! Thank you for the original idea for this engraver and many more thanks for this refinement. Jay > > Here's an idea to make the engraver more flexible: > > \version "2.18.0" > > meter = #'((3 4) (5 4) (2 4)) > > #(define (to-moment arg) > (ly:make-moment (car arg) (cadr arg))) > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
Hi Jay, On Sun, Sep 28, 2014 at 12:48 PM, David Nalesnik wrote: > > > On Sun, Sep 28, 2014 at 10:30 AM, Jay Vara wrote: > >> I wanted to get bar lines after each sub-meter of a compound meter, and >> to have Completion_heads_engraver recognize these bar lines and split >> and tie notes as needed. >> >> Thanks to David and Jan-Peter, I was able to change their >> doubleBarlinesAfterTimeSig engraver to achieve this effect. I still have >> a little more work to do since some of the moment variables currently >> have fixed values. > > Here's an idea to make the engraver more flexible: \version "2.18.0" meter = #'((3 4) (5 4) (2 4)) #(define (to-moment arg) (ly:make-moment (car arg) (cadr arg))) alternateTiming = #(lambda (sig) (lambda (context) (let ((last-bnum 0)) `((process-music . ,(lambda (trans) (let* ((bnum (ly:context-property context 'currentBarNumber)) (len (length sig)) ; how many terms in compound meter (pos (modulo bnum len)) (pos (if (= 0 pos) len pos)) ; first bar in pattern, second... (pos-in-list (1- pos)) ; because elements of list are numbered from 0 (desired-measure-len (to-moment (list-ref sig pos-in-list (format #t "bnum = ~a measurelength ~a ~%" bnum (ly:context-property context 'measureLength)) (ly:context-set-property! context 'measureLength desired-measure-len) (if (= pos-in-list 0) (begin (if (> bnum last-bnum) (ly:context-set-property! context 'whichBar "||")) (set! last-bnum bnum)) music = { \compoundMeter #meter \relative c' {c d e2 f g4 a2 b c4 b2 a g4 f2 e d c d e f g a b c d4} } \score { \new Staff \music \layout { \context { \Score \consists #(alternateTiming meter) } \context { \Voice \remove Note_heads_engraver \remove Rest_engraver \consists Completion_heads_engraver \consists Completion_rest_engraver } } } Some notes: I moved last-bnum into the engraver, as there's no need for it to be a global variable. Initialize it in the let-block. The compound meter can be any length (well, there should be a guard against 0, I suppose). It's easy enough to create the moments you need for measureLength with a function. HTH, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
On Sun, Sep 28, 2014 at 10:30 AM, Jay Vara wrote: > I wanted to get bar lines after each sub-meter of a compound meter, and > to have Completion_heads_engraver recognize these bar lines and split > and tie notes as needed. > > Thanks to David and Jan-Peter, I was able to change their > doubleBarlinesAfterTimeSig engraver to achieve this effect. I still have > a little more work to do since some of the moment variables currently > have fixed values. > > The engraver works well as seen in the code below. Again, I do not > really understand the significance of why, for example time-signature is > set to '() although it does not change in the engraver. Also, when I > tried to change the variable last-fraction to last-bnum, it resulted in > a syntax error, even after changing the #f to #0. Perhaps someone may > know the answer to this. > > Here is the modified engraver. Currently, it sets up timings of 3/4, 5/4 > and 2/4 and puts a double bar at the end of the three measures. Also > notice how the double notes are split and tied across the bar lines. > Pretty cool, I would say. > > \version "2.18.0" > > %{ > Based on a Scheme engraver that places > double bar lines before time signature changes > Provided by Jan-Peter Voigt > Presumably written by David Nalesnik > I think you must have gotten this here: http://www.mail-archive.com/lilypond-user%40gnu.org/msg78039.html It says it's written by Jan-Peter, based on something I wrote. What that something could be, I don't know anymore :) --David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Thanks to David Nalesnik and Jan-Peter Voigt
On Sun, Sep 28, 2014 at 10:30 AM, Jay Vara wrote: > I wanted to get bar lines after each sub-meter of a compound meter, and > to have Completion_heads_engraver recognize these bar lines and split > and tie notes as needed. > > Thanks to David and Jan-Peter, I was able to change their > doubleBarlinesAfterTimeSig engraver to achieve this effect. I still have > a little more work to do since some of the moment variables currently > have fixed values. > > The engraver works well as seen in the code below. Again, I do not > really understand the significance of why, for example time-signature is > set to '() although it does not change in the engraver. Actually, the entire let-block is unnecessary, since neither of the variables is used in your adaptation. If you delete it, you also must get rid of the invocation of stop-translation-timestep, whose only purpose here is to reset the unnecessary variable time-signature to the empty-list. This variable is presumably in your source to serve as a collector of time signature grobs as they are encountered. We start with the empty-list to which the grobs are consed. The list is then cleared to make way for a new one. (This list would be have been populated through an acknowledger of the time-signature-interface, which apparently has been stripped here.) Hope this helps, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user