lilypond-devel
[Top][All Lists]
Advanced

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

Re: \mark\markup\left-align bug


From: Nicolas Sceaux
Subject: Re: \mark\markup\left-align bug
Date: Sat, 17 Jan 2004 00:18:37 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

[oops, follow-up mistake, back to devel]

Fri, 16 Jan 2004 19:48:19 +0100, Han-Wen a dit : 

 > address@hidden writes:
 >> 
 >> Thu, 15 Jan 2004 15:55:39 +0100, Han-Wen a dit : 
 >> 
 >> 
 >> >> \note    (The syntax for this is really bad!  Why not just \note 2. 
 >> >> <dir>,
 >> >> and let the computer compute logarithms and count dots?)
 >> 
 >> > I added a TODO. If anyone feels challenged, feel free to change. My
 >> > suggestion:
 >> 
 >> >   \note #"2."
 >> 
 >> This one might be used to parse the duration argument:

 > Great! Can you add code to do handle breve, longa and maxima too? Thanks!

What would the duration string look like in these cases?
"longa" "breve.." "maxima."?

(use-modules (ice-9 optargs)
             (ice-9 regex))

(define-public log2 
  (let ((divisor (log 2)))
    (lambda (z) (inexact->exact (/ (log z) divisor)))))

(define (parse-simple-duration duration-string)
  "Parse the `duration-string', eg ''4..'' or ''breve.'', and return a (log 
dots) list."
  (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") 
duration-string)))
    (if (and match (string=? duration-string (match:substring match 0)))
        (let ((len  (match:substring match 1))
              (dots (match:substring match 2)))
          (list (cond ((string=? len "breve")  -1)
                      ((string=? len "longa")  -2)
                      ((string=? len "maxima") -3)
                      (else (log2 (string->number len))))
                (if dots (string-length dots) 0)))
        (error "This is not a valid duration string:" duration-string))))

nicolas





reply via email to

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