Re: Get the positions of a beam (or other grob with positions)
Hi David, i'm writing just to let you know that the function changing arpeggio length: offsetArpeggioPositions = #(define-music-function (parser location offsets) (pair?) #{ \override Arpeggio #'positions = #(lambda (grob) (let* ((func (assoc-get 'positions (cdr (ly:grob-basic-properties grob (pos (func grob))) (coord-translate pos offsets))) #}) suffered form exactly the same problem as the \shape functions (if it was used before another override of the same object, LilyPond crashed). Fortunately, the same fix can be applied! Here is a more generic version of the funciton (takes context name and grob name as argument) that doesn't have this bug: offsetPositions = #(define-music-function (parser location context-name grob-name offsets) (string? string? pair?) #{ \override $context-name . $grob-name #'positions = #(lambda (grob) (let* ((func (assoc-get 'positions (reverse(ly:grob-basic-properties grob (pos (func grob))) (coord-translate pos offsets))) #}) % example of use: \layout { \offsetPositions Staff Arpeggio #'(-1 . 1) \offsetPositions PianoStaff Arpeggio #'(-3 . 2) } \relative c' { c e g c2\arpeggio } \new PianoStaff \relative c' \set PianoStaff.connectArpeggios = ##t \new Staff { e g2\arpeggio } \new Staff { \clef bass c, e2\arpeggio } this is cool! :D I wish it was possible to add context to grob name in a more LilyPondish way (i.e. with a dot) cheers, Janek ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Get the positions of a beam (or other grob with positions)
Janek Warchoł janek.lilyp...@gmail.com writes: I wish it was possible to add context to grob name in a more LilyPondish way (i.e. with a dot) It is conceivable as a parser extension, like 3/4 is nowadays generally read as '(3 . 4). One would turn aa.bb.cc (no spaces!) to #'(aa bb cc) in the lexer. It would likely be somewhat tricky to make sure that one does not get surprises in lyrics and so on. Since aa is rendered as a _string_, it might be more consistent to just read aa.bb.cc as one string and leave splitting to the music function. I have not found a choice that would really be convincingly consistent, so I have not done anything of the sort yet. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Get the positions of a beam (or other grob with positions)
On Wed, May 23, 2012 at 1:02 PM, David Kastrup d...@gnu.org wrote: Janek Warchoł janek.lilyp...@gmail.com writes: I wish it was possible to add context to grob name in a more LilyPondish way (i.e. with a dot) It is conceivable as a parser extension, That's good news! like 3/4 is nowadays generally read as '(3 . 4). I'm very happy that this is the case. It's one of the small things that make Lily more user-friendly. One would turn aa.bb.cc (no spaces!) to #'(aa bb cc) in the lexer. It would likely be somewhat tricky to make sure that one does not get surprises in lyrics and so on. Since aa is rendered as a _string_, it might be more consistent to just read aa.bb.cc as one string and leave splitting to the music function. I have not found a choice that would really be convincingly consistent, so I have not done anything of the sort yet. I'm not sure which one is better, either. Maybe GLISS will introduce some changes that will make the descision easier. best, Janek ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Get the positions of a beam (or other grob with positions)
2012/5/23 Janek Warchoł janek.lilyp...@gmail.com: On Wed, May 23, 2012 at 1:02 PM, David Kastrup d...@gnu.org wrote: Janek Warchoł janek.lilyp...@gmail.com writes: I wish it was possible to add context to grob name in a more LilyPondish way (i.e. with a dot) It is conceivable as a parser extension, That's good news! like 3/4 is nowadays generally read as '(3 . 4). I'm very happy that this is the case. It's one of the small things that make Lily more user-friendly. One would turn aa.bb.cc (no spaces!) to #'(aa bb cc) in the lexer. It would likely be somewhat tricky to make sure that one does not get surprises in lyrics and so on. Since aa is rendered as a _string_, it might be more consistent to just read aa.bb.cc as one string and leave splitting to the music function. I have not found a choice that would really be convincingly consistent, so I have not done anything of the sort yet. I'm not sure which one is better, either. Maybe GLISS will introduce some changes that will make the descision easier. best, Janek Hi, I tried it similar to `overrideProperty' from `music-functions-init.ly' But I didn't manage to get rid of the -signs, when specifying the coctext. Is this possible? \version 2.15.38 offsetPositions = #(define-music-function (parser location name offsets) (string? pair?) (let ((name-components (string-split name #\.)) (context-name Voice) (grob-name #f)) (if ( 2 (length name-components)) (set! grob-name (car name-components)) (begin (set! grob-name (list-ref name-components 1)) (set! context-name (list-ref name-components 0 #{ \override $context-name . $grob-name #'positions = #(lambda (grob) (let* ((func (assoc-get 'positions (reverse(ly:grob-basic-properties grob (pos (func grob))) (coord-translate pos offsets))) #})) % example of use: \layout { \offsetPositions Arpeggio #'(-1 . 1) \offsetPositions PianoStaff.Arpeggio #'(-3 . 2) } \relative c' { c e g c2\arpeggio } \new PianoStaff \relative c' \set PianoStaff.connectArpeggios = ##t \new Staff { e g2\arpeggio } \new Staff { \clef bass c, e2\arpeggio } -Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Get the positions of a beam (or other grob with positions)
On Wed, May 23, 2012 at 1:43 PM, Thomas Morley thomasmorle...@googlemail.com wrote: I tried it similar to `overrideProperty' from `music-functions-init.ly' But I didn't manage to get rid of the -signs, when specifying the coctext. Is this possible? \version 2.15.38 offsetPositions = #(define-music-function (parser location name offsets) (string? pair?) (let ((name-components (string-split name #\.)) (context-name Voice) (grob-name #f)) (if ( 2 (length name-components)) (set! grob-name (car name-components)) (begin (set! grob-name (list-ref name-components 1)) (set! context-name (list-ref name-components 0 #{ \override $context-name . $grob-name #'positions = #(lambda (grob) (let* ((func (assoc-get 'positions (reverse(ly:grob-basic-properties grob (pos (func grob))) (coord-translate pos offsets))) #})) Thank you! Making unnecessary would be great, but it's already excellent! Janek ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Get the positions of a beam (or other grob with positions)
Thomas Morley thomasmorle...@googlemail.com writes: I tried it similar to `overrideProperty' from `music-functions-init.ly' But I didn't manage to get rid of the -signs, when specifying the coctext. Is this possible? \version 2.15.38 offsetPositions = #(define-music-function (parser location name offsets) (string? pair?) (let ((name-components (string-split name #\.)) (context-name Voice) (grob-name #f)) (if ( 2 (length name-components)) (set! grob-name (car name-components)) (begin (set! grob-name (list-ref name-components 1)) (set! context-name (list-ref name-components 0 #{ \override $context-name . $grob-name #'positions = #(lambda (grob) (let* ((func (assoc-get 'positions (reverse(ly:grob-basic-properties grob (pos (func grob))) (coord-translate pos offsets))) #})) % example of use: \layout { \offsetPositions Arpeggio #'(-1 . 1) \offsetPositions PianoStaff.Arpeggio #'(-3 . 2) } Not at the moment. You could make the second string argument optional, but you would have to write this without dot between PianoStaff and Arpeggio, as \offsetPositions PianoStaff Arpeggio #'(... If you don't like the string, you could use string-or-pair? as predicate, and then use either Arpeggio or #'(PianoStaff . Arpeggio) That's currently the best sort of deal you can get from the parser. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Get the positions of a beam (or other grob with positions)
Hi David all, i want to make arpeggios longer (so that they overshoot the chords a bit). I've modified your offsetBeamPositions function to work on Arpeggios instead of Beams (that was easy), but i'm quite surprised to find that it doesn't work correctly with cross-staff arpeggios. Do you have any ideas why? Maybe this is a bug in LilyPond? offsetArpeggioPositions = #(define-music-function (parser location offsets) (pair?) #{ \override Arpeggio #'positions = #(lambda (grob) (let* ((func (assoc-get 'positions (cdr (ly:grob-basic-properties grob (pos (func grob))) (coord-translate pos offsets))) #}) \relative c' { c e g c2\arpeggio \offsetArpeggioPositions #'(-1 . 1) % works perfectly c e g c2\arpeggio } \new PianoStaff \relative c' \set PianoStaff.connectArpeggios = ##t \new Staff { \offsetArpeggioPositions #'(-10 . 10) % strange results e g2\arpeggio } \new Staff { \clef bass c, e2\arpeggio } % compare with output without your function: \new PianoStaff \relative c' \set PianoStaff.connectArpeggios = ##t \new Staff { e g2\arpeggio } \new Staff { \clef bass c, e2\arpeggio } % cheers, % janek ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Get the positions of a beam (or other grob with positions)
Hi Janek, On Sat, May 19, 2012 at 8:03 AM, Janek Warchoł janek.lilyp...@gmail.comwrote: Hi David all, i want to make arpeggios longer (so that they overshoot the chords a bit). I've modified your offsetBeamPositions function to work on Arpeggios instead of Beams (that was easy), but i'm quite surprised to find that it doesn't work correctly with cross-staff arpeggios. Do you have any ideas why? Maybe this is a bug in LilyPond? This isn't a bug: cross-staff arpeggios belong to a different context. In your case, they are a part of PianoStaff, so the override will have no impact. If you do this, it will work: offsetCrossStaffArpeggioPositions = #(define-music-function (parser location offsets) (pair?) #{ \override PianoStaff.Arpeggio #'positions = #(lambda (grob) (let* ((func (assoc-get 'positions (cdr (ly:grob-basic-properties grob (pos (func grob))) (coord-translate pos offsets))) #}) OK, that name is out of control :) HTH, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Get the positions of a beam (or other grob with positions)
Hi David, On Sat, May 19, 2012 at 3:30 PM, David Nalesnik david.nales...@gmail.com wrote: This isn't a bug: cross-staff arpeggios belong to a different context. In your case, they are a part of PianoStaff, so the override will have no impact. Ah, silly me! Thank you very much! And by the way, once again you gave me a hint - i think i know now why cross-voice arpeggios often collide with other things. I'll have to write a bug report about this, but i don't know when i'll have time... thanks! Janek ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Get the positions of a beam (or other grob with positions)
Hi, I am very much enjoying now to tweak slurs and other curves using offsets instead of hardcoded control-points. I wonder if it would be interesting to have a similar approach to grobs with a positions property (e.g. beams). While it is comparably easy to find usable #'positions for a beam this is then of course hard-coded and won't work if either the system-system spacing changes for whatever reason, or the music is transposed. Of course it must be quite straightforward to read out lilypond's decision and apply offsets to that in a music function? And if that works one could even enhance the \shape function? The wrapper function could check against a list of grob names and call the appropriate helper function (i.e. if its a Slur then call shape-curve). Maybe it's even possible to make that still more generic. Is it possible to check if a given grob has a given property? (i.e. if the grob has a control-points property then call shape-curve, else if it has positions then call shape-positions [elseif used so that a slurs control-points take precedence over its positions]). So it could be possible to write shape Slur #'((1 . 0) (3 . -2) (0 . 0) (0 . 1)) or shape Beam #'(2 . -1) or shape Arpeggio #'(-1 . 2) Would be awesome I think. Maybe one could even have more ideas to make this offset approach even more general/generic. Instead of ready-made functions, I would also appreciate hints on how to achieve this (as said, I'm quite interested in getting used to write Scheme functions myself, without always having to ask here). Best Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Get the positions of a beam (or other grob with positions)
Hi Urs, On Thu, May 17, 2012 at 5:08 AM, Urs Liska li...@ursliska.de wrote: Hi, I am very much enjoying now to tweak slurs and other curves using offsets instead of hardcoded control-points. I wonder if it would be interesting to have a similar approach to grobs with a positions property (e.g. beams). While it is comparably easy to find usable #'positions for a beam this is then of course hard-coded and won't work if either the system-system spacing changes for whatever reason, or the music is transposed. Of course it must be quite straightforward to read out lilypond's decision and apply offsets to that in a music function? One issue here is that 'positions of Slur are calculated differently from Beam. You can find a function which offsets 'positions of Slur here: http://lsr.dsi.unimi.it/LSR/Snippet?id=748 Basically, this function offsets the Y-coordinate of the first and last control-points. For something like Beam, you can do something like this: \version 2.15.38 offsetBeamPositions = #(define-music-function (parser location offsets) (pair?) #{ \once \override Beam #'positions = #(lambda (grob) (let* ((func (assoc-get 'positions (cdr (ly:grob-basic-properties grob (pos (func grob))) ; both of above assignments may be replaced by: ; (pos (beam::place-broken-parts-individually grob)) (coord-translate pos offsets))) #}) \relative c'' { \offsetBeamPositions #'(-1 . -2) c8[ d e f] } I imagine that this could be generalized to cover other grobs using the 'positions property. With that in mind, I've had it look up the callback which calculates 'positions (the commented-out lines give you a variant which uses that specific callback for Beam). (Thank you Harm for showing me this method.) And if that works one could even enhance the \shape function? The wrapper function could check against a list of grob names and call the appropriate helper function (i.e. if its a Slur then call shape-curve). Maybe it's even possible to make that still more generic. Is it possible to check if a given grob has a given property? (i.e. if the grob has a control-points property then call shape-curve, else if it has positions then call shape-positions [elseif used so that a slurs control-points take precedence over its positions]). So it could be possible to write shape Slur #'((1 . 0) (3 . -2) (0 . 0) (0 . 1)) or shape Beam #'(2 . -1) or shape Arpeggio #'(-1 . 2) Would be awesome I think. Maybe one could even have more ideas to make this offset approach even more general/generic. Instead of ready-made functions, I would also appreciate hints on how to achieve this (as said, I'm quite interested in getting used to write Scheme functions myself, without always having to ask here). Though it is entirely too much fun to work out these puzzles, I'll leave it at that! I hope what I've given you will give you a place to start with this. Best, David Best Urs __**_ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/**listinfo/lilypond-userhttps://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user