]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/new-markup.scm (parse-simple-duration): parse duration
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 17 Jan 2004 12:14:03 +0000 (12:14 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 17 Jan 2004 12:14:03 +0000 (12:14 +0000)
string to log & dots. (Thanks Nicolas!)

* scripts/convert-ly.py (FatalConversionError.sub_note): add \note rule.

ChangeLog
THANKS
input/mutopia/R.Schumann/romanze-op28-2.ly
input/regression/markup-note.ly
scm/new-markup.scm
scripts/convert-ly.py

index ddf2e11fed9822c37dc986f28170a58423c1fe38..99797d698bd035293c213779fb5aa6f0858c5a5d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-01-17  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * scm/new-markup.scm (parse-simple-duration): parse duration
+       string to log & dots. (Thanks Nicolas!)
+
+       * scripts/convert-ly.py (FatalConversionError.sub_note): add \note rule.
+
 2004-01-17  Heikki Junes   <hjunes@cc.hut.fi>
 
        * buildscripts/lilypond.words.py: remove unused files (THANKS Werner
diff --git a/THANKS b/THANKS
index 47a4408b605982c1416aa761320b6229a16e4c5a..21d40658a6a63995aac6724aa9f10bc84512c2cd 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -9,7 +9,7 @@ Jos
 Reuben Thomas
 Thomas Willhalm
 Werner Lemberg
-
+Nicolas Sceaux 
 
 Release 2.0
 ***********
index f86b26c69316c26377ab0709930c46309244a7ec..35bad4e51e614a1c5369eb2a6aea1efeccf30ada 100644 (file)
@@ -38,7 +38,7 @@ righta = \notes \transpose c cis' {
   \property Voice.TextScript \override #'extra-offset = #'(-8.0 . 2.5)
   \m  a,16[^\p( \u c^\markup {
       \large "Einfach ("
-      \note #3 #0 #1
+      \note #"8" #1
       \large " = 100)" }
   a c ] \m  g,[ \u c^3 ] \m  b,[ \u c^2 b c] \m  a,[ \u c^3]) | 
   \property Voice.TextScript \revert #'extra-offset
index 55b158797e49acf1ba772b76b68ab3c5cf54bde9..efb6e9f27d10258a78c14860bbbace0c1c835b1f 100644 (file)
@@ -3,40 +3,40 @@
     texidoc = "The note markup function is used to make metronome
  markings. It works for a variety of flag dot and duration settings."
 }
-\version "2.1.7"
+\version "2.1.11"
 
 \score { \notes { c4^\markup {
-    \note #0 #0 #1
-    \note #1 #0 #1
-    \note #2 #0 #1
-    \note #3 #0 #1
-    \note #4 #0 #1
-    \note #5 #0 #1
-    \note #6 #0 #1
+    \note #"1" #1
+    \note #"2" #1
+    \note #"4" #1
+    \note #"8" #1
+    \note #"16" #1
+    \note #"32" #1
+    \note #"64" #1
 
-    \note #0 #0 #-1
-    \note #1 #0 #-1
-    \note #2 #0 #-1
-    \note #3 #0 #-1
-    \note #4 #0 #-1
-    \note #5 #0 #-1
-    \note #6 #0 #-1
+    \note #"1" #-1
+    \note #"2" #-1
+    \note #"4" #-1
+    \note #"8" #-1
+    \note #"16" #-1
+    \note #"32" #-1
+    \note #"64" #-1
 
-    \note #0 #1 #-1
-    \note #1 #1 #-1
-    \note #2 #1 #-1
-    \note #3 #1 #-1
-    \note #4 #1 #-1
-    \note #5 #1 #-1
-    \note #6 #1 #-1
+    \note #"1." #-1
+    \note #"2." #-1
+    \note #"4." #-1
+    \note #"8." #-1
+    \note #"16." #-1
+    \note #"32." #-1
+    \note #"64." #-1
 
-    \note #0 #1 #1
-    \note #1 #1 #1
-    \note #2 #1 #1
-    \note #3 #1 #1
-    \note #4 #1 #1
-    \note #5 #1 #1
-    \note #6 #1 #1
+    \note #"1." #1
+    \note #"2." #1
+    \note #"4." #1
+    \note #"8." #1
+    \note #"16." #1
+    \note #"32." #1
+    \note #"64." #1
 
 }
 
index ff0dce12537964c19438c6854c4d92e9d1ee48e4..b3635719b316cbd65e03df48311a3bd7511a7ecb 100644 (file)
@@ -255,15 +255,42 @@ Syntax: \\fraction MARKUP1 MARKUP2."
 
 
 ;; TODO: better syntax.
+
+
+(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))))
+
+
 (define-public (note-markup paper props . rest)
+  (let*
+      ((parsed (parse-simple-duration (car rest)))
+       (dir (cadr rest)))
+    (make-note paper props (car parsed) (cadr parsed) dir)
+  ))
+
+(define-public (make-note paper props log dot-count dir)
   "Syntax: \\note #LOG #DOTS #DIR.  By using fractional values
 for DIR, you can obtain longer or shorter stems."
  
   (let*
       (
-       (log (car rest))
-       (dot-count (cadr rest))
-       (dir (caddr rest))
        (font (ly:paper-get-font paper (cons '((font-family .  music)) props)))
        (stemlen (max 3 (- log 1)))
        (headgl
@@ -606,7 +633,7 @@ any sort of property supported by @ref{font-interface} and
    (cons number-markup (list markup?))
    (cons hbracket-markup  (list markup?))
    (cons bracket-markup  (list markup?))
-   (cons note-markup (list integer? integer? ly:dir?))
+   (cons note-markup (list string? number?))
    (cons fraction-markup (list markup? markup?))
    
    (cons column-markup (list markup-list?))
index 9b2f22f0e63052c7f1c4ed6e8fe071be7e2cb917..c09c24a366bcaec0d80119aa63295e9f4fd786d7 100644 (file)
@@ -1661,9 +1661,30 @@ conversions.append (((2,1,10), conv, """\\newaddlyrics -> \\lyricsto"""))
 def conv (str):
        str = re.sub (r'\\include\s*"paper([0-9]+)(-init)?.ly"',
                      r"#(set-staff-size \1)", str)
+
+       def sub_note (match):
+               dur = ''
+               log = string.atoi (match.group (1))
+               dots = string.atoi (match.group (2))
+               
+               if log >= 0:
+                       dur = '%d' % (1 << log)
+               else:
+                       dur = { -1 : 'breve',
+                               -2 : 'longa',
+                               -3 : 'maxima'}[log]
+
+               dur += ('.' * dots)
+               
+               return r'\note #"%s" #%s' % (dur, match.group (3))
+       
+       str = re.sub (r'\\note\s+#([0-9-]+)\s+#([0-9]+)\s+#([0-9.-]+)',
+                     sub_note, str)
        return str
 
-conversions.append (((2,1,11), conv, """\\include "paper16.ly" -> #(set-staff-size 16) """))
+conversions.append (((2,1,11), conv, """\\include "paper16.ly" -> #(set-staff-size 16)
+\note #3 #1 #1 -> \note #"8." #1
+"""))
 
 
 ################################