From 377b3804d27b5f7bd952483d91ba0b0a185f15ff Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 28 Mar 2005 15:33:01 +0000 Subject: [PATCH] * Documentation/user/instrument-notation.itely (String number indications): new node. * input/regression/new-markup-syntax.ly (texidoc): add circle. * lily/new-fingering-engraver.cc (add_string): new function. (acknowledge_grob): accept string-number-event as well. * scm/define-markup-commands.scm (circle): new markup command. * scm/output-lib.scm (print-circled-text-callback): new function. * lily/GNUmakefile: move ifeq after include stepmake.make. --- ChangeLog | 16 ++++++++ Documentation/topdocs/NEWS.tely | 9 +++++ Documentation/user/instrument-notation.itely | 42 ++++++++++++++++---- input/regression/new-markup-syntax.ly | 1 + input/regression/string-number.ly | 16 ++++++++ kpath-guile/GNUmakefile | 2 +- lily/GNUmakefile | 9 +++-- lily/grob-scheme.cc | 8 ++-- lily/new-fingering-engraver.cc | 33 ++++++++++++++- lily/text-item.cc | 8 ++-- make/lilypond.fedora.spec.in | 4 ++ ps/music-drawing-routines.ps | 10 +++++ scm/define-grobs.scm | 15 +++++++ scm/define-markup-commands.scm | 8 ++++ scm/lily.scm | 1 + scm/output-lib.scm | 32 ++++++++------- scm/output-ps.scm | 6 +++ scm/output-tex.scm | 3 ++ 18 files changed, 187 insertions(+), 36 deletions(-) create mode 100644 input/regression/string-number.ly diff --git a/ChangeLog b/ChangeLog index 39615eae01..839a4b0bfc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-03-28 Han-Wen Nienhuys + + * Documentation/user/instrument-notation.itely (String number + indications): new node. + + * input/regression/new-markup-syntax.ly (texidoc): add circle. + + * lily/new-fingering-engraver.cc (add_string): new function. + (acknowledge_grob): accept string-number-event as well. + + * scm/define-markup-commands.scm (circle): new markup command. + + * scm/output-lib.scm (print-circled-text-callback): new function. + + * lily/GNUmakefile: move ifeq after include stepmake.make. + 2005-03-28 Jan Nieuwenhuizen * config.make.in (HAVE_LIBKPATHSEA_SO): diff --git a/Documentation/topdocs/NEWS.tely b/Documentation/topdocs/NEWS.tely index 961498f7d3..a517cbdb3e 100644 --- a/Documentation/topdocs/NEWS.tely +++ b/Documentation/topdocs/NEWS.tely @@ -28,6 +28,15 @@ See user manual, \NAME\ @itemize @bullet +@item +String numbers are now printed on chords as well, + +@lilypond[relative,relative=1,raggedright] + +@end lilypond + +See also @inputfileref{input/regression,string-number.ly}. + @item Notes with ledger lines will be kept at a distance, so they never disappear. diff --git a/Documentation/user/instrument-notation.itely b/Documentation/user/instrument-notation.itely index 0e2f2af152..46c91ab35a 100644 --- a/Documentation/user/instrument-notation.itely +++ b/Documentation/user/instrument-notation.itely @@ -1657,27 +1657,55 @@ for this purpose instead. -@node Tablatures -@section Tablatures +@node Guitar +@section Guitar @cindex tablature @cindex guitar tablature -Tablature notation is used for notating music for plucked string -instruments. Pitches are not denoted with note heads, but by -indicating on which string and fret a note must be played. LilyPond -offers limited support for tablature. - @menu * Tablatures basic:: * Non-guitar tablatures:: * Fret diagrams:: @end menu +@node String number indications +@subsection String number indications + +@cindex String numbers + +String numbers can be added to chords, by indicating the string number +with @code{\}@var{number}, + +@lilypond[relative,relative=1,raggedright] + +@end lilypond + +See also @inputfileref{input/regression,string-number.ly}. + + +@seealso + +Program reference: @internalsref{StringNumber}, +@internalsref{StringNumberEvent} + +@refbugs + +Fingering shares the positioning code with the fingering +(@ref{Fingering instructions}) and articulation on chords. This means +that it is not possible to have string numbers on the right and +fingering instructions on the left of the same chord. + + @node Tablatures basic @subsection Tablatures basic @cindex Tablatures basic +Tablature notation is used for notating music for plucked string +instruments. Pitches are not denoted with note heads, but by +numbers indicating on which string and fret a note must be played. LilyPond +offers limited support for tablature. + The string number associated to a note is given as a backslash followed by a number, e.g., @code{c4\3} for a C quarter on the third string. By default, string 1 is the highest one, and the tuning diff --git a/input/regression/new-markup-syntax.ly b/input/regression/new-markup-syntax.ly index f393603030..d35606a59a 100644 --- a/input/regression/new-markup-syntax.ly +++ b/input/regression/new-markup-syntax.ly @@ -27,6 +27,7 @@ texidoc = "With the new markup syntax, text may be written in various manners." % \char-number #"abc1234abc" \box \column { \line { "string 1" } \line { "string 2" } } "$\\emptyset$" + \circle #4 #0.2 \italic Norsk \super "2" \dynamic sfzp diff --git a/input/regression/string-number.ly b/input/regression/string-number.ly new file mode 100644 index 0000000000..06386fc727 --- /dev/null +++ b/input/regression/string-number.ly @@ -0,0 +1,16 @@ +\header { + texidoc = "String numbers can be added to chords. They use the same +positioning mechanism as finger instructions." + +} + +\version "2.5.17" +\paper { + raggedright = ##t +} + +\relative { + + \set fingeringOrientations = #'(down right up) + +} diff --git a/kpath-guile/GNUmakefile b/kpath-guile/GNUmakefile index b10a6dc6a0..e7e92d6f7e 100644 --- a/kpath-guile/GNUmakefile +++ b/kpath-guile/GNUmakefile @@ -2,7 +2,7 @@ depth = .. NAME = kpath-guile MODULE_NAME = kpath-guile - +MODULE_LDFLAGS= = -lkpathsea SCRIPTS = STEPMAKE_TEMPLATES = library c po diff --git a/lily/GNUmakefile b/lily/GNUmakefile index 9569aa5023..fc3002589e 100644 --- a/lily/GNUmakefile +++ b/lily/GNUmakefile @@ -8,15 +8,16 @@ MODULE_LIBS= $(depth)/flower $(depth)/ttftool $(depth)/kpath-guile MODULE_INCLUDES= $(depth)/flower/include $(depth)/ttftool/include MODULE_CXXFLAGS= -ifeq ($(HAVE_LIBKPATHSEA_SO),no) -MODULE_LDFLAGS= $(KPATHSEA_LIBS) -endif - HELP2MAN_EXECS = lilypond STEPMAKE_TEMPLATES= c++ executable po help2man include $(depth)/make/stepmake.make +ifeq ($(HAVE_LIBKPATHSEA_SO),no) +MODULE_LDFLAGS+= $(KPATHSEA_LIBS) +endif + + # for profiling, link guile statically: # # USER_LDFLAGS += -static -lltdl -ldl diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index d892e6c443..60e5f05fe6 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -65,13 +65,13 @@ LY_DEFINE (ly_grob_layout, "ly:grob-layout", } LY_DEFINE (ly_grob_alist_chain, "ly:grob-alist-chain", - 1, 1, 0, (SCM g, SCM global), - "Get an alist chain for grob @var{g}, with @var{global} as the " + 1, 1, 0, (SCM grob, SCM global), + "Get an alist chain for grob @var{grob}, with @var{global} as the " "global default. If unspecified, @code{font-defaults} " "from the layout block is taken. ") { - Grob *sc = unsmob_grob (g); - SCM_ASSERT_TYPE (sc, g, SCM_ARG1, __FUNCTION__, "grob"); + Grob *sc = unsmob_grob (grob); + SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob"); if (global == SCM_UNDEFINED) global diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index 2a6930bec3..4909ebe88e 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -51,6 +51,7 @@ protected: virtual void acknowledge_grob (Grob_info); void add_fingering (Grob *, Music *, Music *); void add_script (Grob *, Music *, Music *); + void add_string (Grob *, Music *, Music *); void position_scripts (); }; @@ -84,6 +85,10 @@ New_fingering_engraver::acknowledge_grob (Grob_info inf) { add_script (inf.grob_, m, note_ev); } + else if (m->is_mus_type ("string-number-event")) + { + add_string (inf.grob_, m, note_ev); + } else if (m->is_mus_type ("harmonic-event")) { inf.grob_->set_property ("style", ly_symbol2scm ("harmonic")); @@ -104,8 +109,10 @@ New_fingering_engraver::acknowledge_grob (Grob_info inf) void New_fingering_engraver::add_script (Grob *head, Music *event, - Music *) + Music *note) { + (void) note; + Finger_tuple ft; Grob *g = make_item ("Script", event->self_scm ()); @@ -158,6 +165,30 @@ New_fingering_engraver::add_fingering (Grob *head, fingerings_.push (ft); } + +void +New_fingering_engraver::add_string (Grob *head, + Music *event, + Music *hevent) +{ + Finger_tuple ft; + + ft.script_ = make_item ("StringNumber", event->self_scm ()); + + Side_position_interface::add_support (ft.script_, head); + + int d = scm_to_int (event->get_property ("string-number")); + + SCM sstr = scm_number_to_string (scm_int2num (d), scm_int2num (10)); + ft.script_->set_property ("text", sstr); + + ft.finger_event_ = event; + ft.note_event_ = hevent; + ft.head_ = head; + + fingerings_.push (ft); +} + void New_fingering_engraver::position_scripts () { diff --git a/lily/text-item.cc b/lily/text-item.cc index 10500ceba1..a45a3c84b8 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -20,8 +20,8 @@ #include "output-def.hh" #include "modified-font-metric.hh" -MAKE_SCHEME_CALLBACK (Text_interface, interpret_string, 3) - SCM +MAKE_SCHEME_CALLBACK (Text_interface, interpret_string, 3); +SCM Text_interface::interpret_string (SCM layout_smob, SCM props, SCM markup) @@ -39,8 +39,8 @@ Text_interface::interpret_string (SCM layout_smob, return fm->text_stencil (str).smobbed_copy (); } -MAKE_SCHEME_CALLBACK (Text_interface, interpret_markup, 3) - SCM +MAKE_SCHEME_CALLBACK (Text_interface, interpret_markup, 3); +SCM Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup) { if (scm_is_string (markup)) diff --git a/make/lilypond.fedora.spec.in b/make/lilypond.fedora.spec.in index f77d79a2d1..52c9cebd21 100644 --- a/make/lilypond.fedora.spec.in +++ b/make/lilypond.fedora.spec.in @@ -18,9 +18,13 @@ Buildrequires: t1utils bison flex mftrace ImageMagick Buildrequires: texinfo >= 4.7 Buildrequires: guile-devel >= 1.6.4-8 Buildrequires: freetype-devel >= 2.1 + Buildrequires: fontforge #fontforge must be >= 20041211 urg. 0.0.0-fdr.1.20041211 +Buildrequires: pango-devel >= 1.6.0 +Buildrequires: fontconfig-devel + Requires: libstdc++ python Requires: guile >= 1.6.4-8 ghostscript >= 8.15 diff --git a/ps/music-drawing-routines.ps b/ps/music-drawing-routines.ps index 35e8b3bb1f..3bcfa3a45f 100644 --- a/ps/music-drawing-routines.ps +++ b/ps/music-drawing-routines.ps @@ -3,6 +3,8 @@ % Functions for direct and embedded PostScript +%% TODO: use dicts or prefixes to prevent namespace pollution. + /pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse @@ -259,6 +261,14 @@ bind def 0 360 arc closepath fill stroke } bind def +/draw_circle % R T +{ + setlinewidth + dup 0 moveto + 0 exch 0 exch + 0 360 arc closepath stroke +} bind def + /draw_white_dot % x1 y2 R { % 0 360 arc fill stroke diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 724281b723..f568348d6e 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -455,6 +455,21 @@ side-position-interface self-alignment-interface item-interface)))) )) + (StringNumber + . ( + (print-function . ,print-circled-text-callback) + (padding . 0.5) + (staff-padding . 0.5) + (self-alignment-X . 0) + (self-alignment-Y . 0) + (script-priority . 100) + (font-encoding . fetaNumber) + (font-size . -5) ; don't overlap when next to heads. + (meta . ((interfaces . (string-number-interface + font-interface text-script-interface text-interface + side-position-interface self-alignment-interface + item-interface)))) + )) (Glissando . ( diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index e975b35acf..bd8d08c587 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -16,6 +16,14 @@ "Stencil as markup" stil) +(def-markup-command (circle layout props radius thickness) + (number? number?) + "A circle of radius @var{radius} and thickness @var{thickness}" + + (ly:make-stencil + (list 'circle radius thickness) + (cons (- radius) radius) + (cons (- radius) radius))) (def-markup-command (with-url layout props url arg) (string? markup?) "Add a link to URL @var{url} around @var{arg}. This only works in diff --git a/scm/lily.scm b/scm/lily.scm index 0fe8fbfb22..0ce3c55ef3 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -126,6 +126,7 @@ predicates. Print a message at LOCATION if any predicate failed." blank bracket char + circle dashed-line dashed-slur dot diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 6180d86454..759727bb06 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -114,14 +114,23 @@ ((string? arg) (string-append "\"" arg "\"")) ((symbol? arg) (string-append "\"" (symbol->string arg) "\"")))) -(define-public (func name . args) - (string-append - "(" name - (if (null? args) - "" - (apply string-append - (map (lambda (x) (string-append " " (arg->string x))) args))) - ")\n")) +(define-public (print-circled-text-callback grob) + (let* + ((text (ly:grob-property grob 'text)) + (layout (ly:grob-layout grob)) + (defs (ly:output-def-lookup layout 'text-font-defaults)) + (props (ly:grob-alist-chain grob defs)) + (circle (Text_interface::interpret_markup layout props + (make-circle-markup + 1.0 0.1))) + (text-stencil + (Text_interface::interpret_markup layout props text))) + + (ly:stencil-align-to! text-stencil X CENTER) + (ly:stencil-align-to! text-stencil Y CENTER) + (ly:stencil-add text-stencil circle) + )) + ;;(define (mm-to-pt x) ;; (* (/ 72.27 25.40) x)) @@ -148,13 +157,6 @@ (string-append (ly:number->string (car c)) " " (ly:number->string (cdr c)))) -(define (font i) - (string-append - "font" - (make-string 1 (integer->char (+ (char->integer #\A) i))))) - -(define (scm-scm action-name) - 1) ;; silly, use alist? (define-public (find-notehead-symbol duration style) diff --git a/scm/output-ps.scm b/scm/output-ps.scm index defeb0c2cf..1d969d056d 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -21,6 +21,7 @@ ;; JUNK this -- see lily.scm: ly:all-output-backend-commands #:export (unknown blank + circle dot white-dot beam @@ -145,6 +146,11 @@ (ly:number->string off) " ] 0 draw_dashed_slur")) +(define (circle radius thick) + (format + "~a ~a draw_circle" radius thick)) + + (define (dot x y radius) (string-append " " diff --git a/scm/output-tex.scm b/scm/output-tex.scm index 8e77e50ece..d04e83d8d0 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -79,6 +79,9 @@ (define (dot x y radius) (embedded-ps (list 'dot x y radius))) +(define (circle radius thick) + (embedded-ps (list 'circle radius thick))) + (define (embedded-ps string) (embedded-ps (list 'embedded-ps string))) -- 2.39.2