Multi non static substition
I have defined this function in an include.ly file MyMarkup = { \markup \override #'(adjust-x-pos . 1.0) \override #'(adjust-length . 1.5) } I have found the explanation for non-static substitution in the documentation. http://lilypond.org/doc/v2.18/Documentation/learning/saving-typing-with-variables-and-functions.en.html How can I extend that example so I can use one call to the function passing both pos and length variable in the callout. Something like: \MyMarkup #1.0 #1.5 Thanks, Ursus___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Multi non static substition
HI Ursus, You will need to use a music function. You can look this up in the notation reference (NR). Also, you are making overrides of properties but have not specified any markup to apply them to. Not sure what you are after. As usual, let me take a moment to suggest it would be great for you to move to the 2.19.83 release (I assum you are on 2.18 from your link). Much better in every respect - many more years of development. And also my usual comment; it's called unstable but this is traditional open source conservatism (and it is _technically_ so) but in practice it's very, very reliable and solid. And if for some remote reason it does not work for you, nothing is stopping you from reverting. Andrew On Sat, 20 Apr 2019 at 19:48, E Appeldoorn wrote: > I have defined this function in an include.ly file > > MyMarkup = { > \markup > \override #'(adjust-x-pos . 1.0) >\override #'(adjust-length . 1.5) > } > > I have found the explanation for non-static substitution in the > documentation. > > http://lilypond.org/doc/v2.18/Documentation/learning/saving-typing-with-variables-and-functions.en.html > > How can I extend that example so I can use one call to the function > passing both pos and length variable in the callout. Something like: > > \MyMarkup #1.0 #1.5 > > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re[3]: Multi non static substition
Wrote my first music function and it crashed with a lot of error messages. TieMarkup = #(define-music-function (parser location xpos len) (number? number?) #{ \markup \override #'(adjust-x-pos . #xpos) \override #'(adjust-length . #len) \undertie #}) Calling it with \TieMarkup #1.0 #1.5 Can anyone point me in the right direction? Thanks in advance. Ursus Starten lilypond-windows.exe 2.18.2 [Score.ly]... Verwerken van 'D:/Lilypond/_Voorbeelden/Undertie Lyrics/Score.ly' Ontleden... D:/Lilypond/_Voorbeelden/Undertie Lyrics/undertie.ly:138:2 <0>: fout: GUILE signaleerde een fout voor de expressie beginnend alhier # (define-music-function D:/Lilypond/_Voorbeelden/Undertie Lyrics/undertie.ly:138:2 <1>: fout: syntax error, unexpected EVENT_IDENTIFIER # (define-music-function D:/Lilypond/_Voorbeelden/Undertie Lyrics/undertie.ly:139:34 <2>: fout: syntax error, unexpected EVENT_IDENTIFIER, expecting '=' (parser location xpos len ) D:/Lilypond/_Voorbeelden/Undertie Lyrics/undertie.ly:141:10 <3>: fout: GUILE signaleerde een fout voor de expressie beginnend alhier # { D:/Lilypond/_Voorbeelden/Undertie Lyrics/undertie.ly:143:28 <4>: fout: GUILE signaleerde een fout voor de expressie beginnend alhier \override # '(adjust-x-pos . #xpos) D:/Lilypond/_Voorbeelden/Undertie Lyrics/undertie.ly:143:27 <5>: fout: verkeert type voor argument 1. Verwacht pair, gevonden # \override #'(adjust-x-pos . #xpos) D:/Lilypond/_Voorbeelden/Undertie Lyrics/undertie.ly:143:50 <6>: unknown # object Unbound variable: { D:/Lilypond/_Voorbeelden/Undertie Lyrics/undertie.ly:143:49 <7>: unknown # object C:/Program Files (x86)/LilyPond/usr/share/lilypond/current/scm/lily.scm:1039:21 <8>: In procedure reverse! in expression (ly:parse-file file-name): C:/Program Files (x86)/LilyPond/usr/share/lilypond/current/scm/lily.scm:1039:21 <9>: Wrong type argument in position 1: (# . #f) Afgesloten met returncode 1. -- Origineel bericht -- Van: "E Appeldoorn" Aan: "Andrew Bernard" Verzonden: 20-4-2019 12:16:36 Onderwerp: Re[2]: Multi non static substition Andrew, I will upgrade. As to leaving out the markup text, I just did that for brevety. It has a LONG underlying include file. Most of which would be very distracting from my question. I'll look into functions. Thanks -- Origineel bericht -- Van: "Andrew Bernard" Aan: "E Appeldoorn" CC: "Lilypond" Verzonden: 20-4-2019 11:59:29 Onderwerp: Re: Multi non static substition HI Ursus, You will need to use a music function. You can look this up in the notation reference (NR). Also, you are making overrides of properties but have not specified any markup to apply them to. Not sure what you are after. As usual, let me take a moment to suggest it would be great for you to move to the 2.19.83 release (I assum you are on 2.18 from your link). Much better in every respect - many more years of development. And also my usual comment; it's called unstable but this is traditional open source conservatism (and it is _technically_ so) but in practice it's very, very reliable and solid. And if for some remote reason it does not work for you, nothing is stopping you from reverting. Andrew On Sat, 20 Apr 2019 at 19:48, E Appeldoorn wrote: I have defined this function in an include.ly file MyMarkup = { \markup \override #'(adjust-x-pos . 1.0) \override #'(adjust-length . 1.5) } I have found the explanation for non-static substitution in the documentation. http://lilypond.org/doc/v2.18/Documentation/learning/saving-typing-with-variables-and-functions.en.html How can I extend that example so I can use one call to the function passing both pos and length variable in the callout. Something like: \MyMarkup #1.0 #1.5 ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: scheme-question about accumulating lists of lists
Hi David, Am Sa., 20. Apr. 2019 um 03:52 Uhr schrieb David Pirotte : > > Hi again, > > Replying twice to myself in a row, how is that :) > A little tired I guess ... > > > > Note that the above will only work if the last 'blue item' has 3 > > > elements, you'd > > > need to adapt for other use case (which also 'speak' in favor of the > > > cleaner > > > approach. > > > Actually, I didn't like what I wrote, here is a slightly better code: > > And here is a corrected version: the code in the mail I'm answering now would > not > return proper (expected) results for any other operator then car ... this one > will > let you really walk :) > > (use-modules (ice-9 match)) > > (define blue > (cons '(a b c) (cons '(1 2 3) '(x y z > > (define fox > (cons '(a b c) (cons '(1 2 3) (cons '(x y z) '() Thanks pointing me to this possibility, in my use-case I then could do: (define (p) (cons '(1 2 3) '(4 5 6))) (define l1 '(a b c)) (define l2 '(x y z)) (cons* l1 l2 (car (p)) (cdr (p)) '()) => ((a b c) (x y z) (1 2 3) (4 5 6)) > > (define (blue-walk blue proc) > (let loop ((blue blue) > (result '())) > (match blue > ((a . rest) >(if (pair? a) >(loop rest > (cons (proc a) result)) >(reverse! (cons (proc (cons a rest)) >result > (() >(reverse! result) > > scheme@(guile-user)> (load "blue.scm") > ;;; note: source file /usr/alto/projects/guile/blue.scm > ;;; ... > scheme@(guile-user)> (blue-walk blue car) > $2 = (a 1 x) > scheme@(guile-user)> (blue-walk fox car) > $3 = (a 1 x) > scheme@(guile-user)> (blue-walk blue cdr) > $4 = ((b c) (2 3) (y z)) > scheme@(guile-user)> (blue-walk fox cdr) > $5 = ((b c) (2 3) (y z)) My guile-knowledge is mostly limited to what LilyPond needs. As far as I can tell (ice-9 match) isn't used in our source. So I need to study your `blue-walk´ from scratch. Thanks a lot, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Re[3]: Multi non static substition
Hi Ursus, Apologies, you most likely want to define a new markup function. Also in the NR. Andrew ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Re[2]: Slur with left and/or right arrow head
Am Fr., 19. Apr. 2019 um 23:37 Uhr schrieb Trevor : > > > Aaron, Harm > > Could I please comment on just one feature? The overrides to add or inhibit > arrow-heads at the left and right ends of the Slur are: > > \override Slur.details.arrow-left = #LEFT > \override Slur.details.arrow-right = #RIGHT > \override Slur.details.arrow-left = ##f > \override Slur.details.arrow-right = ##f > > This slightly confused me, especially when I tried > > \override Slur.details.arrow-right = #LEFT > > which draws a left-pointing arrow-head at the right end of the Slur. > Something I don't think anyone would want. > > Why not have the simpler and less confusing > > \override Slur.details.arrow-left = ##t > \override Slur.details.arrow-right = ##t > \override Slur.details.arrow-left = ##f > \override Slur.details.arrow-right = ##f > > ? > > Trevor Hi Trevor, yep, it's the same concern Lukas already raised. Attached the next iteration of the code. arrow-left/right will now operate on the boolean #f or any not-false value. If the not-false value is a procedure, it will be evaluated. This is needed to make alterBroken etc work (some commented examples in \layout). Regrettable this has some negative impact on the performance. Not sure whether this can be improved. If the not-false value is something else, it's taken as #t. Cheers, Harm \version "2.19.82" %% Thanks to Aaron Hill %% http://lists.gnu.org/archive/html/lilypond-user/2019-04/msg00240.html %% Does not work for 2.18.2 because of %% - grob::name (could be replaced by grob-name, see p.e. LSR) %% - minimum-length-after-break (no direct replacement possible, only used in %% the examples, though) #(ly:load "bezier-tools.scm") #(define (note-column-bounded? dir grob) "Checks wether @var{grob} is a spanner and whether the spanner is bounded in @var{dir}-direction by a note-column." (if (ly:spanner? grob) (grob::has-interface (ly:spanner-bound grob dir) 'note-column-interface) #f)) #(define (offset-number-pair-list l1 l2) "Offset the number-pairs of @var{l1} by the matching number-pairs of @var{l2}" ;; NB no type-checking or checking for equal lengths is done here (map (lambda (p1 p2) (offset-add p1 p2)) l1 l2)) #(define (bezier::point control-points t) "Given a Bezier curve of arbitrary degree specified by @var{control-points}, compute the point at the specified position @var{t}." (if (< 1 (length control-points)) (let ((q0 (bezier::point (drop-right control-points 1) t)) (q1 (bezier::point (drop control-points 1) t))) (cons (+ (* (car q0) (- 1 t)) (* (car q1) t)) (+ (* (cdr q0) (- 1 t)) (* (cdr q1) t (car control-points))) #(define (bezier::angle control-points t) "Given a Bezier curve of arbitrary degree specified by @var{control-points}, compute the slope at the specified position @var{t}." (let ((q0 (bezier::point (drop-right control-points 1) t)) (q1 (bezier::point (drop control-points 1) t))) (ly:angle (- (car q1) (car q0)) (- (cdr q1) (cdr q0) #(define* (bezier::approx-control-points-to-length control-points dir length #:optional (precision 0.01) (right-t 0.2) (left-t 0.8)) "Given a Bezier curve specified by @var{control-points}, return new control-points where the length of the Bezier specified by them is approx @var{length}. The procedure returns if difference of the new calculated length and the given @var{length} is lower than optional @var{precision}. The optional @var{left-t} and @var{right-t} represent the steps where new control-points are calculated relying on @var{dir}." ;; TODO ;; Do the values for precision, left-t, right-t cover all cases? (let* ((frst-cp (car control-points)) (last-cp (last control-points)) (actual-length (ly:length (- (car frst-cp) (car last-cp)) (- (cdr frst-cp) (cdr last-cp (diff (- (abs actual-length) (abs length (if (< diff precision) control-points (bezier::approx-control-points-to-length (if (positive? dir) (cdr (split-bezier control-points right-t)) (car (split-bezier control-points left-t))) dir length #(define (bezier::adjusted-arrow-head dir control-points) (lambda (curve) "Returns a stencil build from an arrowhead-glyph, adjusted to fit at start/end of a curve looking at the curve's @var{control-points}. Relying on @var{dir} for looking at left or right side of the curve." (if (not dir) empty-stencil (let* ((staff-space (ly:staff-symbol-staff-space curve)) ;; reducing fs-from-staff-space a bit looks nicer (fs-from-staff-space (1- (magnification->font-size staff-space))) (grob-font (ly:paper-get-font (ly:grob-layout curve) `(((font-encoding . fetaMusic) (font-size . ,fs-from-sta
Re: scheme-question about accumulating lists of lists
Hi Thomas, > ... > Thanks pointing me to this possibility, in my use-case I then could do: > (define (p) (cons '(1 2 3) '(4 5 6))) > (define l1 '(a b c)) > (define l2 '(x y z)) > (cons* l1 l2 (car (p)) (cdr (p)) '()) > => > ((a b c) (x y z) (1 2 3) (4 5 6)) Yes, if you can (you mentioned the code was not yours and couldn't be changed ...) that would be a lot cleaner, imo, and will let you use 'built-in' scheme, guile and srfi-1 procedures that work on lists, as mentioned in my first answer. > > (define (blue-walk blue proc) > > (let loop ((blue blue) > > (result '())) > > (match blue > > ((a . rest) > >(if (pair? a) > >(loop rest > > (cons (proc a) result)) > >(reverse! (cons (proc (cons a rest)) > >result > > (() > >(reverse! result) In the above code, I am performing an extra and therefore useless cons, here is a correction (not a bug, but one should _always_ avoid consing whenever possible): (define (blue-walk blue proc) (let loop ((blue blue) (result '())) (match blue ((a . rest) (if (pair? a) (loop rest (cons (proc a) result)) -> (reverse! (cons (proc blue) result (() (reverse! result) > My guile-knowledge is mostly limited to what LilyPond needs. > As far as I can tell (ice-9 match) isn't used in our source. > So I need to study your `blue-walk´ from scratch. In this particular case, match is 'convenient', but not really indispensable - and I see now it's not in guile-1.8. Here is a version that does not need match (though you might not even need it if you can (cons* a b c ... '()) as you mentioned here above): (define (fox-walk fox proc) (let loop ((fox fox) (result '())) (if (null? fox) (reverse! result) (let ((a (car fox))) (if (pair? a) (loop (cdr fox) (cons (proc a) result)) (reverse! (cons (proc fox) result))) Now, if/when you (lily devs I mean, not just you of course) plan to use 2.0, 2.2 or 3.0 (2.9.1 is it is ...) [*], it is highly recommended to use match 'everywhere' you'd use car, cdr, cadr ... but not only, look at the "7.7 Pattern Matching" section of a recent manual for more ... the code is/becomes a lot more readable, and match is not only extremely powerful, but also extremely fast (no figures, but it's being said there is no penalty compared to using 'older' destructuring techniques ... (referred to, among guilers, 'the car cdr hell' :)) David. [*] I know why the change hasn't been made, I don't expect any answer here, just mentioning that if/when ... (saying this so you save your energy and to avoid to start yet another conversation on this already deeply discussed mater among you ...) pgp_tUmxGgAZD.pgp Description: OpenPGP digital signature ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user