]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add functionality to string numbers
authorValentin Villenave <valentin@villenave.net>
Thu, 9 Oct 2014 11:27:11 +0000 (13:27 +0200)
committerValentin Villenave <valentin@villenave.net>
Thu, 9 Oct 2014 11:37:41 +0000 (13:37 +0200)
This commit adds a number-type property that allows for different
numbering styles, as well as user-exposed predefined commands
to easily switch between default guitar-like string numbers and
roman numerals more suitable for unfretted strings.

Additionally, the number formatting function previously used only
in fret-diagrams is now available for possibly wider use.

Documentation/changes.tely
Documentation/notation/fretted-strings.itely
Documentation/notation/unfretted-strings.itely
ly/property-init.ly
scm/define-grob-interfaces.scm
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/fret-diagrams.scm
scm/lily-library.scm
scm/output-lib.scm

index 9e53285a1c0b7a21b030a0202c6642e6c7f101fd..b714fe5d941628cfc9aa5017160e36627583c85b 100644 (file)
@@ -164,6 +164,17 @@ group, but @emph{not} with @var{violinI}, will be removed.
 The @code{\addlyrics} function now works with arbitrary contexts
 incuding @code{Staff}.
 
+@item
+String numbers can now also be used to print roman numerals
+(e.g. for unfretted string instruments).
+@lilypond[verbatim,quote,relative=2]
+c2\2
+\romanStringNumbers
+c\2
+\arabicStringNumbers
+c1\3
+@end lilypond
+
 @item
 The @code{thin-kern} property of the @code{BarLine} grob has been
 renamed to @code{segno-kern}.
index 76d8f5d37578943e75901c57308a992d709d0a8e..c1257539ec40d21dc779912b3e28adb226e29999 100644 (file)
@@ -119,6 +119,21 @@ g-0\3
 <g-0\3>
 @end lilypond
 
+String numbers may also, as is customary with unfretted strings,
+be printed in Roman numerals and placed below the staff rather
+than above.
+
+@lilypond[verbatim,quote,relative=2]
+c2\2
+a\3
+\romanStringNumbers
+c\2
+\set stringNumberOrientations = #'(down)
+a\3
+\arabicStringNumbers
+g1\4
+@end lilypond
+
 @snippets
 
 @lilypondfile[verbatim,quote,texidoc,doctitle]
@@ -127,6 +142,11 @@ g-0\3
 @lilypondfile[verbatim,quote,texidoc,doctitle]
 {allowing-fingerings-to-be-printed-inside-the-staff.ly}
 
+@predefined
+@code{\arabicStringNumbers},
+@code{\romanStringNumbers}.
+@endpredefined
+
 @seealso
 Notation Reference:
 @ref{Fingering instructions}.
index fcaff9d4dc85acc92e8547ed2c1611b04b556982..4a48d5c97af58529b75adf9581f1552eb8bca659 100644 (file)
@@ -85,12 +85,14 @@ Snippets:
 @funindex \upbow
 @funindex \downbow
 @funindex \open
+@funindex \romanStringNumbers
 
 @cindex bowing indications
 @cindex up bow indication
 @cindex down bow indication
 @cindex open string indication
 @cindex string, indicating open
+@cindex string numbers
 
 Bowing indications are created as articulations, which are
 described in @ref{Articulations and ornamentations}.
@@ -103,12 +105,19 @@ c4(\downbow d) e(\upbow f)
 @end lilypond
 
 @noindent
-and the following example shows three ways in which an open A
-string on a violin might be indicated:
+
+Roman numerals can be added as strings numbers (rather
+than the default circled Arabic numbers), as explained in
+@ref{String number indications}.
+
+Alternatively, string indications may be printed using
+markup commands; articulation scripts may also indicate
+open strings.
 
 @lilypond[verbatim,quote,relative=2]
 a4 \open
-a^\markup { \teeny "II" }
+\romanStringNumbers
+a\2
 a2^\markup { \small "sul A" }
 @end lilypond
 
@@ -116,12 +125,14 @@ a2^\markup { \small "sul A" }
 @predefined
 @code{\downbow},
 @code{\upbow},
-@code{\open}.
+@code{\open},
+@code{\romanStringNumbers}.
 @endpredefined
 
 @seealso
 Notation Reference:
 @ref{Articulations and ornamentations},
+@ref{String number indications},
 @ref{Slurs}.
 
 
index f27311f9a4b8e42a2e6cfd918f0a798319adb79c..8d6d892d17d3d790139c636302266321ebfb7361 100644 (file)
@@ -509,6 +509,22 @@ stemDown    = \override Stem.direction = #DOWN
 stemNeutral = \revert Stem.direction
 
 
+%% string numbers
+
+romanStringNumbers  = {
+  \override StringNumber.number-type = #'roman-upper
+  \override StringNumber.stencil = #ly:text-interface::print
+  \override StringNumber.font-encoding = #'latin1
+  \override StringNumber.font-shape = #'italic
+}
+arabicStringNumbers = {
+  \revert StringNumber.number-type
+  \revert StringNumber.stencil
+  \revert StringNumber.font-encoding
+  \revert StringNumber.font-shape
+}
+
+
 %% tablature
 
 % switch to full notation
index e07006e35048c3aca50207c2516492ceb708f955..2321e1c903d4c4b0f50ab87054d38b634b7d8303 100644 (file)
@@ -216,6 +216,11 @@ accidentals)."
  "Note names."
  '())
 
+(ly:add-interface
+ 'number-interface
+ "Numbers."
+ '(number-type))
+
 (ly:add-interface
  'only-prebreak-interface
  "Kill this grob after the line breaking process."
index a81eed50092532ff51f15dac177a062e2edc8386..d6deaec30faa9eee517df088e4c18f72704b9112 100644 (file)
@@ -698,6 +698,8 @@ over the total spanner, where the width of the spanner is normalized
 between 0 and 1.")
      (note-names ,vector? "Vector of strings containing names for
 easy-notation note heads.")
+     (number-type ,symbol? "Numbering style. Choices include
+@code{roman-lower}, @code{roman-upper} and @code{arabic}.")
 
 
 ;;;
index 7baaf000cb233c4fb7e7541466ac2249c31e99f9..65063d7af5deeb8ef8482bbef01fa3c72b2fb1ac 100644 (file)
         (cross-staff . ,script-or-side-position-cross-staff)
         (font-encoding . fetaText)
         (font-size . -5)                ; don't overlap when next to heads.
+        (number-type . arabic)
         (padding . 0.5)
         (parent-alignment-X . ,CENTER)
         (script-priority . 100)
                                 self-alignment-interface
                                 outside-staff-interface
                                 side-position-interface
+                                number-interface
                                 string-number-interface
                                 text-interface
                                 text-script-interface))))))
index e60c0dca359cf782697afa6ca5ffc1524a255e4e..a1daae33213f724d8ecd087a4218c349b6279fc7 100644 (file)
@@ -801,19 +801,9 @@ at @var{fret}."
              (number-type
               (assoc-get 'number-type details 'roman-lower))
              (label-text
-              (cond
-               ((equal? number-type 'roman-lower)
-                (fancy-format #f "~(~@r~)" base-fret))
-               ((equal? number-type 'roman-upper)
-                (fancy-format #f "~@r" base-fret))
-               ((equal? 'arabic number-type)
-                (fancy-format #f "~d" base-fret))
-               ((equal? 'custom number-type)
-                (fancy-format #f
-                              (assoc-get 'fret-label-custom-format
-                                         details "~a")
-                              base-fret))
-               (else (fancy-format #f "~(~@r~)" base-fret))))
+              (number-format number-type base-fret
+                             (assoc-get 'fret-label-custom-format
+                                         details "~a")))
              (label-stencil
               (centered-stencil
                (sans-serif-stencil
index 472a82da24c4a785a5ef6c267f48f25327773d8c..9008831c722316ad8b45ed8835c0457548d66a69 100644 (file)
@@ -889,6 +889,26 @@ Handy for debugging, possibly turned off."
 
   (reverse matches))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; numbering styles
+
+(define-public (number-format number-type num . custom-format)
+  "Print NUM accordingly to the requested NUMBER-TYPE.
+Choices include @code{roman-lower} (by default),
+@code{roman-upper}, @code{arabic} and @code{custom}.
+In the latter case, CUSTOM-FORMAT must be supplied
+and will be applied to NUM."
+ (cond
+   ((equal? number-type 'roman-lower)
+    (fancy-format #f "~(~@r~)" num))
+   ((equal? number-type 'roman-upper)
+    (fancy-format #f "~@r" num))
+   ((equal? number-type 'arabic)
+    (fancy-format #f "~d" num))
+   ((equal? number-type 'custom)
+    (fancy-format #f (car custom-format) num))
+   (else (fancy-format #f "~(~@r~)" num))))
+
 ;;;;;;;;;;;;;;;;
 ;; other
 
index 59f93e2e7ea3111cf4048409901273858ffed974..6a385fd72abf232474853e0a9bc25ae712cb9f95 100644 (file)
@@ -995,7 +995,9 @@ and duration-log @var{log}."
 (define-public (string-number::calc-text grob)
   (let ((event (event-cause grob)))
     (or (ly:event-property event 'text #f)
-        (number->string (ly:event-property event 'string-number) 10))))
+        (number-format
+         (ly:grob-property grob 'number-type)
+         (ly:event-property event 'string-number)))))
 
 (define-public (stroke-finger::calc-text grob)
   (let ((event (event-cause grob)))