[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    Re: improving Janek's \dynamic function (for combo dynamics)
From:       Thomas Morley <thomasmorley65 () gmail ! com>
Date:       2017-08-29 12:27:09
Message-ID: CABsfGyXL3bmE-9iO8oa_L8W0eU1Xt+LO7GFn3a+9_UPyJz=a8A () mail ! gmail ! com
[Download RAW message or body]

2017-08-27 22:34 GMT+02:00 David Kastrup <dak@gnu.org>:

> You are right that fold-matches is probably not worth the trouble in
> brain contortion here: processing the result from list-matches should be
> good enough without overflowing memory.



I now come up with (only markup again):

#(define-markup-command (dyn-test-II layout props strg)(string?)
#:properties ((reg-exp "\\{[^{}]*\\}")
              (separators (char-set #\{ #\}))
              (dynamcs (char-set #\f #\m #\p #\r #\s #\z)))
  (interpret-markup layout props
    (make-line-markup
      (map
        (lambda (s)
          (let* ((matches (list-matches reg-exp s)))
            (if (null? matches)
                s
                (let* ((poss-dyns (map match:substring matches)))
                  (append-map
                    (lambda (p-d)
                      (let* ((cand (string-trim-both p-d separators)))
                        (if (string-every char-set:dynamics cand)
                            (make-concat-markup
                              (list
                                (make-concat-markup
                                  (map match:prefix matches))
                                (make-dynamic-markup cand)
                                (make-concat-markup
                                  (map match:suffix matches))))
                            p-d)))
                    poss-dyns)))))
        (string-split strg #\space)))))

\markup \dyn-test-II #"poco {f}, but {p} sub. {ma} non troppo"

Though, if I split the string anyway (splitting at #\space should do
no harm, imho), it's probably cheaper to go for string-match instead
of list-matches.

Not sure...

Cheers,
  Harm

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic