From 43e5c4bcc562a047b095a814fbded3ee0ed052e5 Mon Sep 17 00:00:00 2001 From: hanwen Date: Fri, 8 Jul 2005 22:16:28 +0000 Subject: [PATCH] * lily/include/music.hh (class Music): remove Music::duration_log() * lily/stem-engraver.cc (make_stem): take duration log from event. * lily/chord-tremolo-engraver.cc: don't ack note-head-interface. --- ChangeLog | 10 +++++ Documentation/user/advanced-notation.itely | 2 +- lily/accidental-engraver.cc | 1 - lily/chord-tremolo-engraver.cc | 7 ++-- lily/include/music.hh | 1 - lily/music.cc | 7 ---- lily/stem-engraver.cc | 25 +++++++----- scm/autochange.scm | 46 ++++++++++++++++++++++ scm/define-grobs.scm | 10 ++--- scm/lily.scm | 1 + scm/part-combiner.scm | 45 --------------------- 11 files changed, 82 insertions(+), 73 deletions(-) create mode 100644 scm/autochange.scm diff --git a/ChangeLog b/ChangeLog index cec0355535..95783e573d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ +2005-07-09 Han-Wen Nienhuys + + * lily/include/music.hh (class Music): remove Music::duration_log() + + * lily/stem-engraver.cc (make_stem): take duration log from event. + + * lily/chord-tremolo-engraver.cc: don't ack note-head-interface. + 2005-07-08 Han-Wen Nienhuys + * scm/lily.scm (ly:load): load autochange.scm + * Documentation/user/tutorial.itely (Running LilyPond for the first time): remove reference to DVI/TeX diff --git a/Documentation/user/advanced-notation.itely b/Documentation/user/advanced-notation.itely index fd535ee39f..afd7e54352 100644 --- a/Documentation/user/advanced-notation.itely +++ b/Documentation/user/advanced-notation.itely @@ -1716,7 +1716,7 @@ Program reference: @internalsref{NoteHead}. Trills that should be executed on an explicitly specified pitch can be typeset with the command @code{pitchedTrill}, -@lilypond[raggedright,verbatim] +@lilypond[raggedright,verbatim,fragment] \pitchedTrill c'4\startTrillSpan fis f'\stopTrillSpan @end lilypond diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index 259e340d04..a0f30df239 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -489,7 +489,6 @@ Accidental_engraver::acknowledge_grob (Grob_info info) || !ly_c_equal_p (info.grob ()->get_property ("style"), ly_symbol2scm ("harmonic"))) { - Accidental_entry entry; entry.head_ = info.grob (); entry.origin_trans_ = dynamic_cast (info.origin_translator ()); diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index 363d756537..51140efadf 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -13,7 +13,6 @@ #include "engraver-group-engraver.hh" #include "warn.hh" #include "misc.hh" -#include "note-head.hh" #include "spanner.hh" #include "item.hh" #include "chord-tremolo-iterator.hh" @@ -170,7 +169,9 @@ Chord_tremolo_engraver::acknowledge_grob (Grob_info info) } } else if (repeat_ - && flags_ && !body_is_sequential_ && Stem::has_interface (info.grob ())) + && flags_ + && !body_is_sequential_ + && Stem::has_interface (info.grob ())) { stem_tremolo_ = make_item ("StemTremolo", repeat_->self_scm ()); stem_tremolo_->set_property ("flag-count", @@ -210,6 +211,6 @@ ADD_TRANSLATOR (Chord_tremolo_engraver, /* descr */ "Generates beams for tremolo repeats.", /* creats*/ "Beam", /* accepts */ "repeated-music", - /* acks */ "stem-interface note-head-interface", + /* acks */ "stem-interface", /* reads */ "", /* write */ ""); diff --git a/lily/include/music.hh b/lily/include/music.hh index aeb36a40c7..f0415ff0d0 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -29,7 +29,6 @@ public: void internal_set_property (SCM, SCM val); SCM get_property_alist (bool mutble) const; bool internal_is_music_type (SCM) const; - int duration_log () const; DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM)); Pitch to_relative_octave (Pitch); diff --git a/lily/music.cc b/lily/music.cc index 68525c51a0..2c631d25d1 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -297,13 +297,6 @@ Music::origin () const return ip ? ip : &dummy_input_global; } -int -Music::duration_log () const -{ - if (is_mus_type ("rhythmic-event")) - return unsmob_duration (get_property ("duration"))->duration_log (); - return 0; -} Music * make_music_by_name (SCM sym) diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index a8a7f66815..71ef4b46f8 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -53,11 +53,13 @@ Stem_engraver::make_stem (Grob_info gi) stem_ = make_item ("Stem", gi.music_cause ()->self_scm ()); /* - docme: why do we take duration-log from request, not from note - head? + we take the duration log from the Event, since the duration-log + for a note head is always <= 2. */ - int duration_log = gi.music_cause ()->duration_log (); - stem_->set_property ("duration-log", scm_int2num (duration_log)); + Music *music = gi.music_cause (); + Duration *dur = unsmob_duration (music->get_property ("duration")); + + stem_->set_property ("duration-log", dur ? scm_int2num (dur->duration_log ()) : 0); if (tremolo_ev_) { @@ -82,7 +84,7 @@ Stem_engraver::make_stem (Grob_info gi) context ()->set_property ("tremoloFlags", scm_int2num (requested_type)); int tremolo_flags = intlog2 (requested_type) - 2 - - (duration_log > 2 ? duration_log - 2 : 0); + - (dur->duration_log () > 2 ? dur->duration_log () - 2 : 0); if (tremolo_flags <= 0) { tremolo_ev_->origin ()->warning (_ ("tremolo duration is too long")); @@ -114,15 +116,18 @@ Stem_engraver::acknowledge_grob (Grob_info gi) Music *cause = gi.music_cause (); if (!cause) return; - + Duration *d = unsmob_duration (cause->get_property ("duration")); + if (!d) + return ; + if (!stem_) make_stem (gi); - - int duration_log = cause->duration_log (); - if (Stem::duration_log (stem_) != duration_log) + + if (Stem::duration_log (stem_) != d->duration_log ()) { // FIXME: - gi.music_cause ()->origin ()->warning (_f ("adding note head to incompatible stem (type = %d)", 1 << Stem::duration_log (stem_))); + gi.music_cause ()->origin ()->warning (_f ("adding note head to incompatible stem (type = %d)", + 1 << Stem::duration_log (stem_))); gi.music_cause ()->origin ()->warning (_f ("maybe input should specify polyphonic voices")); } diff --git a/scm/autochange.scm b/scm/autochange.scm new file mode 100644 index 0000000000..b7169c8a99 --- /dev/null +++ b/scm/autochange.scm @@ -0,0 +1,46 @@ + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; autochange - fairly related to part combining. + +(define-public (make-autochange-music music) + (define (generate-split-list change-moment event-list acc) + (if (null? event-list) + acc + (let* ((now-tun (caar event-list)) + (evs (map car (cdar event-list))) + (now (car now-tun)) + (notes (filter (lambda (x) + (equal? (ly:music-property x 'name) 'NoteEvent)) + evs)) + (pitch (if (pair? notes) + (ly:music-property (car notes) 'pitch) + #f))) + ;; tail recursive. + (if (and pitch (not (= (ly:pitch-steps pitch) 0))) + (generate-split-list #f + (cdr event-list) + (cons (cons + + (if change-moment + change-moment + now) + (sign (ly:pitch-steps pitch))) acc)) + (generate-split-list + (if pitch #f now) + (cdr event-list) acc))))) + + (set! noticed '()) + (let* ((m (make-music 'AutoChangeMusic)) + (context (ly:run-translator (make-non-relative-music music) part-combine-listener)) + (evs (last-pair noticed)) + (split (reverse! (generate-split-list + #f + (if (pair? evs) + (reverse! (cdar evs) '()) '()) + '()) + '()))) + (set! (ly:music-property m 'element) music) + (set! (ly:music-property m 'split-list) split) + (set! noticed '()) + m)) diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 8038b9260b..a1d6cb361b 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1299,7 +1299,6 @@ (TimeSignature . ( (print-function . ,Time_signature::print) -; (print-function . ,Text_interface::print) (break-align-symbol . time-signature) (break-visibility . ,all-visible) (space-alist . ( @@ -1309,7 +1308,6 @@ )) (breakable . #t) (style . C) -; (text . (,time-signature-glue-markup)) (meta . ((interfaces . (time-signature-interface break-aligned-interface font-interface item-interface )))) )) @@ -1333,7 +1331,9 @@ (direction . ,LEFT) (font-size . -4) (print-function . ,Accidental_interface::print) - (meta . ((interfaces . (item-interface side-position-interface font-interface)))) + (meta . ((interfaces . (item-interface + accidental-interface + side-position-interface font-interface)))) )) (TrillPitchGroup @@ -1344,6 +1344,7 @@ (direction . ,RIGHT) (padding . 0.3) (meta . ((interfaces . (side-position-interface + note-head-interface rhythmic-head-interface font-interface accidental-interface item-interface axis-group-interface)))) )) @@ -1354,11 +1355,11 @@ (Y-offset-callbacks . (,Staff_symbol_referencer::callback)) (font-size . -4) (meta . ((interfaces . (item-interface + rhythmic-head-interface font-interface pitched-trill-interface ledgered-interface staff-symbol-referencer-interface)))) )) - (TupletBracket . ( (padding . 1.1) @@ -1369,7 +1370,6 @@ (after-line-breaking-callback . ,Tuplet_bracket::after_line_breaking) (print-function . ,Tuplet_bracket::print) (font-shape . italic) -; (font-series . bold) (font-size . -2) (meta . ((interfaces . (text-interface line-interface diff --git a/scm/lily.scm b/scm/lily.scm index ee2caade6a..25165c605d 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -215,6 +215,7 @@ The syntax is the same as `define*-public'." "bass-figure.scm" "music-functions.scm" "part-combiner.scm" + "autochange.scm" "define-music-properties.scm" "auto-beam.scm" "chord-name.scm" diff --git a/scm/part-combiner.scm b/scm/part-combiner.scm index c4ee06a550..294d2bc168 100644 --- a/scm/part-combiner.scm +++ b/scm/part-combiner.scm @@ -451,51 +451,6 @@ the mark when there are no spanners active." (display result)) result)) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; autochange - fairly related to part combining. - -(define-public (make-autochange-music music) - (define (generate-split-list change-moment event-list acc) - (if (null? event-list) - acc - (let* ((now-tun (caar event-list)) - (evs (map car (cdar event-list))) - (now (car now-tun)) - (notes (filter (lambda (x) - (equal? (ly:music-property x 'name) 'NoteEvent)) - evs)) - (pitch (if (pair? notes) - (ly:music-property (car notes) 'pitch) - #f))) - ;; tail recursive. - (if (and pitch (not (= (ly:pitch-steps pitch) 0))) - (generate-split-list #f - (cdr event-list) - (cons (cons - - (if change-moment - change-moment - now) - (sign (ly:pitch-steps pitch))) acc)) - (generate-split-list - (if pitch #f now) - (cdr event-list) acc))))) - - (set! noticed '()) - (let* ((m (make-music 'AutoChangeMusic)) - (context (ly:run-translator (make-non-relative-music music) part-combine-listener)) - (evs (last-pair noticed)) - (split (reverse! (generate-split-list - #f - (if (pair? evs) - (reverse! (cdar evs) '()) '()) - '()) - '()))) - (set! (ly:music-property m 'element) music) - (set! (ly:music-property m 'split-list) split) - (set! noticed '()) - m)) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -- 2.39.5