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: David Kastrup
Subject: Re: improving Janek's \dynamic function (for combo dynamics)
Date: Sun, 27 Aug 2017 11:56:02 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Thomas Morley <address@hidden> writes:

> 2017-08-26 21:35 GMT+02:00 David Kastrup <address@hidden>:
>> Thomas Morley <address@hidden> writes:
>>
>>> 2017-08-26 20:24 GMT+02:00 David Kastrup <address@hidden>:
>>>>
>>>> Uh, this was a proposal for a user interface that does not need to look
>>>> at punctuation etc but rather goes by [...] for figuring out where the
>>>> "true" dynamics are, likely defaulting to taking the first pair for
>>>> alignment as well as Midi dynamics.
>>>
>>> Ok, lol
>>>
>>> Valentins original code used underscores, iirc.
>>
>> Hm, [...] might actually be used for editorial annotations.  So maybe
>> not the best markup for this application.  {...} maybe?
>>
>> --
>> David Kastrup
>
> Do you mean something at the lines below?
> (Only the markup-part for now)
>
> #(define char-set:dynamics
>   (char-set #\f #\m #\p #\r #\s #\z))
>
> #(define (split-string strg char-pair)
> ;; split a string at all occurrences of both characters in char-pair
> ;; remark: with guilev2 string-split accepts a char-set as second argument
>   (append-map
>     (lambda (s) (string-split s #\}))
>     (string-split strg #\{)))
>
>
> #(define-markup-command (dyn-test layout props strg)(string?)
> #:properties ((chars (cons #\{ #\})))
>   (interpret-markup layout props
>     (make-concat-markup
>       (map
>         (lambda (word)
>           (if (string-every char-set:dynamics word)
>               (make-dynamic-markup word)
>               word))
>       (split-string strg chars)))))
>
> \markup \dyn-test #"poco {f}, but {p} sub. ma non troppo"

Well, it's partly too robust and partly too fragile...  silently not
using dynamic markup for {huh} while still removing the braces is never
going to be sensible behavior I think.  Treating opening and closing
braces (and parts left and right from them) equally is half-defeating
the principal idea of being more robust against wrong detection of
dynamics, admittedly not likely a big problem.

I was more thinking along the lines of

#(define-markup-command (dyn-test layout props strg) (markup?)
  (define (fixstring arg)
     (let ((res (fold-matches "\\{[^{}*\\}" arg '(0)
             (lambda (m prev) ...
  (define (fixtree arg)
    (cond ((pair? arg) (cons (fixtree (car arg)) (fixtree (cdr arg))))
          ((string? arg (fixstring arg)))
          (else arg)))

Uh, well, you get the drift.  I just remembered that we still need the
relative positions in the string and the recursive approach wouldn't
really work with that.  Either way, fold-matches seems like something
one could work with here.

But, well, regarding the results of this particular call, yes that was
more or less what I meant.

-- 
David Kastrup



reply via email to

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