lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: improving Janek's \dynamic function (for combo dynamics)


From: Thomas Morley
Subject: Re: improving Janek's \dynamic function (for combo dynamics)
Date: Tue, 29 Aug 2017 14:27:09 +0200

2017-08-27 22:34 GMT+02:00 David Kastrup <address@hidden>:

> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]