2003-09-15 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ * input/regression/clef-oct.ly: new file.
+
+ * scm/clef.scm (make-clef-set): use regexps, support arbitrary
+ transposition.
+
* input/template/*.ly: remove old relative.
* ly/english.ly: add X names for double sharp.
@end table
By adding @code{_8} or @code{^8} to the clef name, the clef is
-transposed one octave down or up, respectively. Argument @var{clefname}
+transposed one octave down or up, respectively, and @code{_15} and
+@code{^15} transposes by two octaves. The argument @var{clefname}
must be enclosed in quotes when it contains underscores or digits. For
example,
--- /dev/null
+
+\version "1.9.5" \header {
+
+ texidoc = "Octavation signs may be added to clefs. These
+octavation signs may be placed below or above (meaning an octave
+higher or lower), and can take any value, including 15 for two octaves."
+
+}
+
+\score { \notes
+
+ \relative c'' {
+
+ \clef "G_8"
+ c4
+ \clef "G_15"
+ c4
+ \clef "G_7"
+ c4
+ \clef "G_6"
+ c4
+ \clef "G^8"
+ c4
+ \clef "G^15"
+ c4
+ \clef "G^9"
+ c4
+}
+ \paper { raggedright = ##t }
+ }
\clef "tenor"c'1^"{tenor}" \bar "||"
\clef "baritone"c'1^"{baritone}" \bar "||"
\clef "varbaritone"c'1^"{varbaritone}" \bar "||"
- \clef "G_8"c'1^"{sub 8?}" c'1 \bar "||"
- \clef "F_8"c'1^"{sub 8?}" c'1 \bar "||"
- \clef "G^8"c'1^"{sup 8?}" c'1 \bar "||"
\clef "bass"c'1^"{bass}" \bar "||"
\clef "subbass"c'1^"{subbass}" \bar "||"
\property Staff.Clef \override #'transparent = ##t
{
Item * g = new Item (get_property ("OctavateEight"));
+ int abs_oct = gh_scm2int (oct) ;
+ int dir = sign (abs_oct);
+ abs_oct = abs (abs_oct) + 1;
+
+ g->set_grob_property ("text",
+ scm_number_to_string (gh_int2scm (abs_oct),
+ SCM_MAKINUM (10)));
Side_position_interface::add_support (g,clef_);
g->set_parent (clef_, Y_AXIS);
g->set_parent (clef_, X_AXIS);
-
- g->set_grob_property ("direction", scm_int2num (sign (gh_scm2int (oct))));
+ g->set_grob_property ("direction", scm_int2num (dir));
octavate_ = g;
announce_grob(octavate_, SCM_EOL);
}
)
)
-(define-public (make-clef-set cl)
+(define-public (make-clef-set clef-name)
"Generate the clef setting commands for a clef with name CL."
(define (make-prop-set props)
(let*
(let ((e '())
(c0 0)
(oct 0)
- (l (string-length cl))
- )
+ (match (string-match "^(.*)([_^])([0-9]+)$" clef-name)))
- ;; ugh. cleanme
- (if (equal? "8" (substring cl (- l 1) l))
+ (if match
(begin
- (if (equal? "^" (substring cl (- l 2) (- l 1)))
- (set! oct -7)
- (set! oct 7))
-
- (set! cl (substring cl 0 (- l 2)))))
-
+ (set! clef-name (match:substring match 1))
+ (set! oct
+ (*
+ (if (equal? (match:substring match 2) "^")
+ -1 1)
+ (- (string->number (match:substring match 3)) 1))
+ )))
+
- (set! e (assoc cl supported-clefs))
+ (set! e (assoc clef-name supported-clefs))
(if (pair? e)
(let*
(context-spec-music seq 'Staff))
(begin
(ly:warn (format "Unknown clef type `~a'
-See scm/lily.scm for supported clefs" cl))
+See scm/lily.scm for supported clefs" clef-name))
(make-music-by-name 'Music)
)
(OctavateEight
. (
(self-alignment-X . 0)
- (text . "8")
(break-visibility . ,begin-of-line-visible)
(X-offset-callbacks . (,Self_alignment_interface::centered_on_parent ,Self_alignment_interface::aligned_on_self))
(Y-offset-callbacks . (,Side_position_interface::aligned_side))