From 5d576b1299d374ae478cb38075cc05d5cb691046 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 11 Oct 2006 22:17:26 +0000 Subject: [PATCH] * scm/output-lib.scm (string-finger::calc-text): new function * lily/new-fingering-engraver.cc (add_fingering): refactor; make generic for fingering & string number. Use for string-finger. * scm/define-music-types.scm (music-descriptions): add StringFingerEvent * lily/fingering-engraver.cc (listen_string_finger): new function * scm/define-grobs.scm (all-grob-descriptions): add StringFinger * scm/define-context-properties.scm (all-user-translation-properties): add stringFingerOrientations --- ChangeLog | 16 ++++++ lily/engraver.cc | 7 ++- lily/fingering-engraver.cc | 23 +++++++-- lily/new-fingering-engraver.cc | 81 ++++++++++++++++--------------- ly/engraver-init.ly | 2 + ly/music-functions-init.ly | 14 ++++++ ly/script-init.ly | 1 + mf/GNUmakefile | 3 +- scm/define-context-properties.scm | 1 + scm/define-event-classes.scm | 2 +- scm/define-grobs.scm | 21 ++++++++ scm/define-music-types.scm | 9 ++++ scm/output-lib.scm | 6 +++ 13 files changed, 139 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9202d2fa20..92448e5811 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2006-10-12 Han-Wen Nienhuys + + * scm/output-lib.scm (string-finger::calc-text): new function + + * lily/new-fingering-engraver.cc (add_fingering): refactor; make + generic for fingering & string number. Use for string-finger. + + * scm/define-music-types.scm (music-descriptions): add StringFingerEvent + + * lily/fingering-engraver.cc (listen_string_finger): new function + + * scm/define-grobs.scm (all-grob-descriptions): add StringFinger + + * scm/define-context-properties.scm + (all-user-translation-properties): add stringFingerOrientations + 2006-10-11 Jürgen Reuter * mf/parmesan-dots.mf (new), mf/parmesan-generic.mf, diff --git a/lily/engraver.cc b/lily/engraver.cc index 2453188fff..ef13351c2e 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -139,7 +139,9 @@ Engraver::internal_make_grob (SCM symbol, SCM cause, char const *name, char cons } Item * -Engraver::internal_make_item (SCM x, SCM cause, char const *name, char const *file, int line, char const *fun) +Engraver::internal_make_item (SCM x, SCM cause, + char const *name, + char const *file, int line, char const *fun) { Item *it = dynamic_cast (internal_make_grob (x, cause, name, file, line, fun)); assert (it); @@ -147,7 +149,8 @@ Engraver::internal_make_item (SCM x, SCM cause, char const *name, char const *fi } Paper_column * -Engraver::internal_make_column (SCM x, char const *name, char const *file, int line, char const *fun) +Engraver::internal_make_column (SCM x, char const *name, + char const *file, int line, char const *fun) { return dynamic_cast (internal_make_grob (x, SCM_EOL, name, file, line, fun)); } diff --git a/lily/fingering-engraver.cc b/lily/fingering-engraver.cc index f469df8139..c6a6a9b0fb 100644 --- a/lily/fingering-engraver.cc +++ b/lily/fingering-engraver.cc @@ -27,6 +27,7 @@ protected: void stop_translation_timestep (); void process_music (); DECLARE_TRANSLATOR_LISTENER (fingering); + DECLARE_TRANSLATOR_LISTENER (string_finger); DECLARE_ACKNOWLEDGER (rhythmic_head); DECLARE_ACKNOWLEDGER (stem); @@ -41,6 +42,18 @@ Fingering_engraver::listen_fingering (Stream_event *ev) events_.push_back (ev); } +IMPLEMENT_TRANSLATOR_LISTENER (Fingering_engraver, string_finger); +void +Fingering_engraver::listen_string_finger (Stream_event *ev) +{ + /* + FIXME: should do something. + + This function is mainly here to shut up a warning + */ + (void)ev; +} + void Fingering_engraver::acknowledge_stem (Grob_info inf) { @@ -130,9 +143,13 @@ Fingering_engraver::Fingering_engraver () ADD_ACKNOWLEDGER (Fingering_engraver, rhythmic_head); ADD_ACKNOWLEDGER (Fingering_engraver, stem); + ADD_TRANSLATOR (Fingering_engraver, - /* doc */ "Create fingering-scripts", - /* create */ "Fingering", - /* accept */ "fingering-event", + /* doc */ + "Create fingering-scripts", + /* create */ + "Fingering", + /* accept */ + "fingering-event", /* read */ "", /* write */ ""); diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index 03eecc480d..ed69676ec6 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -46,6 +46,7 @@ operator< (Finger_tuple const &a, Finger_tuple const &b) class New_fingering_engraver : public Engraver { vector fingerings_; + vector string_fingerings_; vector articulations_; vector string_numbers_; @@ -59,7 +60,9 @@ protected: void stop_translation_timestep (); DECLARE_ACKNOWLEDGER (rhythmic_head); DECLARE_ACKNOWLEDGER (stem); - void add_fingering (Grob *, Stream_event *, Stream_event *); + void add_fingering (Grob *, SCM, + vector *, + Stream_event *, Stream_event *); void add_script (Grob *, Stream_event *, Stream_event *); void add_string (Grob *, Stream_event *, Stream_event *); void position_scripts (SCM orientations, vector *); @@ -82,13 +85,22 @@ New_fingering_engraver::acknowledge_rhythmic_head (Grob_info inf) continue; if (ev->in_event_class ("fingering-event")) - add_fingering (inf.grob (), ev, note_ev); + add_fingering (inf.grob (), + ly_symbol2scm ("Fingering"), + &fingerings_, + ev, note_ev); else if (ev->in_event_class ("text-script-event")) ev->origin ()->warning (_ ("can't add text scripts to individual note heads")); else if (ev->in_event_class ("script-event")) add_script (inf.grob (), ev, note_ev); else if (ev->in_event_class ("string-number-event")) - add_string (inf.grob (), ev, note_ev); + add_fingering (inf.grob (), + ly_symbol2scm ("StringNumber"), &string_numbers_, + ev, note_ev); + else if (ev->in_event_class ("string-finger-event")) + add_fingering (inf.grob (), + ly_symbol2scm ("StringFinger"), &string_fingerings_, + ev, note_ev); else if (ev->in_event_class ("harmonic-event")) { inf.grob ()->set_property ("style", ly_symbol2scm ("harmonic")); @@ -117,57 +129,35 @@ New_fingering_engraver::add_script (Grob *head, Finger_tuple ft; Grob *g = make_item ("Script", event->self_scm ()); - make_script_from_event (g, context (), event->get_property ("articulation-type"), 0); - if (g) - { - ft.script_ = g; - ft.script_->set_parent (head, X_AXIS); - - articulations_.push_back (ft); - } + make_script_from_event (g, context (), + event->get_property ("articulation-type"), 0); + ft.script_ = g; + ft.script_->set_parent (head, X_AXIS); + + articulations_.push_back (ft); } void New_fingering_engraver::add_fingering (Grob *head, + SCM grob_sym, + vector *tuple_vector, Stream_event *event, Stream_event *hevent) { Finger_tuple ft; - ft.script_ = make_item ("Fingering", event->self_scm ()); + ft.script_ = internal_make_item (grob_sym, event->self_scm (), + ly_symbol2string (grob_sym).c_str (), + __FILE__, __LINE__, __FUNCTION__ + ); Side_position_interface::add_support (ft.script_, head); - /* - TODO: - - Should add support for thumb. It's a little involved, since - the thumb lives in a different font. Maybe it should be moved? - */ - ft.finger_event_ = event; ft.note_event_ = hevent; ft.head_ = head; - fingerings_.push_back (ft); -} - -void -New_fingering_engraver::add_string (Grob *head, - Stream_event *event, - Stream_event *hevent) -{ - Finger_tuple ft; - - ft.script_ = make_item ("StringNumber", event->self_scm ()); - - Side_position_interface::add_support (ft.script_, head); - - ft.finger_event_ = event; - ft.note_event_ = hevent; - ft.head_ = head; - - string_numbers_.push_back (ft); + tuple_vector->push_back (ft); } void @@ -314,6 +304,13 @@ New_fingering_engraver::position_all () string_numbers_.clear (); } + if (string_fingerings_.size ()) + { + position_scripts (get_property ("stringFingerOrientations"), + &string_fingerings_); + string_fingerings_.clear (); + } + for (vsize i = articulations_.size (); i--;) { Grob *script = articulations_[i].script_; @@ -344,11 +341,17 @@ ADD_TRANSLATOR (New_fingering_engraver, "This engraver is ill-named, since it " "also takes care of articulations and harmonic note heads", /* create */ - "Fingering", + "Fingering " + "StringNumber " + "StringFinger " + "Script " + , + /* accept */ "", /* read */ "fingeringOrientations " + "stringFingerOrientations " "stringNumberOrientations " , diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 03e4d54f5a..991cc7f2aa 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -531,6 +531,8 @@ AncientRemoveEmptyStaffContext = \context { harmonicAccidentals = ##t fingeringOrientations = #'(up down) stringNumberOrientations = #'(up down) + stringFingerOrientations = #'(up down) + markFormatter = #format-mark-letters rehearsalMark = #1 subdivideBeams = ##f diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index b910223f68..5f425fc717 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -2,6 +2,11 @@ \version "2.9.12" + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% this file is alphabetically sorted. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %% need SRFI-1 filter #(use-modules (srfi srfi-1)) @@ -532,6 +537,14 @@ includePageLayoutFile = tweak-filename)))))) (make-music 'SequentialMusic 'void #t)) + +rightHandFinger = +#(define-music-function (parser location finger) (string?) + "Define a StringFingerEvent" + (make-music 'StringFingerEvent + 'origin location + 'text finger)) + scoreTweak = #(define-music-function (parser location name) (string?) "Include the score tweak, if exists." @@ -612,3 +625,4 @@ withMusicProperty = (set! (ly:music-property music sym) val) music) + diff --git a/ly/script-init.ly b/ly/script-init.ly index 68d4de9d9a..00e49f1814 100644 --- a/ly/script-init.ly +++ b/ly/script-init.ly @@ -52,3 +52,4 @@ downprall = #(make-articulation "downprall") segno = #(make-articulation "segno") coda = #(make-articulation "coda") varcoda = #(make-articulation "varcoda") + diff --git a/mf/GNUmakefile b/mf/GNUmakefile index 6a8fa110f5..46ea644630 100644 --- a/mf/GNUmakefile +++ b/mf/GNUmakefile @@ -5,7 +5,6 @@ LOCALSTEPMAKE_TEMPLATES=lilypond include $(depth)/make/stepmake.make -AF_FILES = $(call src-wildcard,*.af) # hangs on feta23 MFTRACE_FLAGS= --simplify @@ -106,7 +105,7 @@ ALL_GEN_FILES= $(TFM_FILES) $(TEXTABLES) $(TFM_FILES) $(LOG_FILES) $(ENC_FILES) #PRE_INSTALL=$(MAKE) "$(ALL_GEN_FILES)" INSTALLATION_DIR=$(local_lilypond_datadir)/fonts/source -INSTALLATION_FILES=$(MF_FILES) $(AF_FILES) +INSTALLATION_FILES=$(MF_FILES) INSTALLATION_OUT_SUFFIXES=1 2 3 4 5 6 diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index 85e4ece2ba..81fab19655 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -377,6 +377,7 @@ up the interpretation phase. This speeds up debugging large scores.") squashing for @internalsref{Pitch_squash_engraver}.") (stringNumberOrientations ,list? "See @code{fingeringOrientations}") + (stringFingerOrientations ,list? "See @code{fingeringOrientations}") (stringOneTopmost ,boolean? "Whether the 1st string is printed on the top line of the tablature.") diff --git a/scm/define-event-classes.scm b/scm/define-event-classes.scm index 808fcf716c..7a9bb402a1 100644 --- a/scm/define-event-classes.scm +++ b/scm/define-event-classes.scm @@ -16,7 +16,7 @@ OneTimeStep Finish)) (music-event . (arpeggio-event breathing-event extender-event span-event rhythmic-event dynamic-event break-event percent-event - key-change-event string-number-event tie-event part-combine-event + key-change-event string-number-event string-finger-event tie-event part-combine-event beam-forbid-event script-event tremolo-event bend-after-event fingering-event glissando-event harmonic-event hyphen-event laissez-vibrer-event mark-event diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 7e633bc126..5dc860bd27 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1541,6 +1541,27 @@ self-alignment-interface item-interface)))))) + (StringFinger + . ( + (stencil . ,ly:text-interface::print) + (text . ,string-finger::calc-text) + (padding . 0.5) + (staff-padding . 0.5) + (self-alignment-X . 0) + (self-alignment-Y . 0) + (script-priority . 100) + (font-shape . italic) + (font-size . -5) ; don't overlap when next to heads. + (meta . ((class . Item) + (interfaces . (string-number-interface + font-interface + text-script-interface + text-interface + side-position-interface + self-alignment-interface + item-interface)))))) + + (SustainPedal . ( (no-spacing-rods . #t) diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index fb0cc99d25..61f53d40a7 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -623,6 +623,15 @@ Syntax: @code{\\@var{number}}.") (types . (general-music string-number-event event)) )) + (StringFingerEvent + . ( + (description . "Specify with which finger to pluck a string. + +Syntax: @code{\\rightHandFinger @var{text}}.") + + (types . (general-music string-finger-event event)) + )) + (TextScriptEvent . ( (description . "") diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 9a5bc4d8d8..7c7f64811c 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -424,6 +424,12 @@ centered, X==1 is at the right, X == -1 is at the left." (number->string digit 10) )) +(define-public (string-finger::calc-text grob) + (let* + ((text (ly:event-property (event-cause grob) 'text))) + + text)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; dynamics (define-public (hairpin::calc-grow-direction grob) -- 2.39.2