From 715153c6137c0a16a1e08ffe03e6937f03c1bf3f Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 22 Aug 2006 10:23:28 +0000 Subject: [PATCH] * python/convertrules.py (conv): warning on \tempo{} * ly/performer-init.ly: set tempoWholesPerMinute. * ly/midi-init.ly: remove \midi * lily/tempo-performer.cc: look at tempoWholesPerMinute to set MIDI tempo. * lily/metronome-engraver.cc (process_music): use tempoUnitCount tempoUnitDuration for determining what to print. * lily/lyric-extender.cc: typo. * lily/parser.yy (output_def_body): disallow \tempo in \midi{} * lily/duration-scheme.cc (LY_DEFINE): ly:duration-length: new function. * THANKS: update sponsors. * ly/english.ly: quarter tone naming (thanks, Trevor Baca) --- ChangeLog | 18 +++++++++ VERSION | 2 +- lily/duration-scheme.cc | 8 ++++ lily/lyric-extender.cc | 3 +- lily/metronome-engraver.cc | 65 ++++++++++++++++++------------- lily/parser.yy | 16 +------- lily/tempo-performer.cc | 39 ++++++++++--------- ly/midi-init.ly | 1 - ly/performer-init.ly | 4 ++ python/convertrules.py | 33 ++++++++++++++++ scm/define-context-properties.scm | 4 ++ scm/define-event-classes.scm | 2 +- scm/define-music-types.scm | 6 --- scm/ly-syntax-constructors.scm | 11 ++++++ scm/translation-functions.scm | 12 +++--- 15 files changed, 147 insertions(+), 77 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f067a5be6..fa82ee28f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ 2006-08-22 Han-Wen Nienhuys + * python/convertrules.py (conv): warning on \tempo{} + + * ly/performer-init.ly: set tempoWholesPerMinute. + + * ly/midi-init.ly: remove \midi + + * lily/tempo-performer.cc: look at tempoWholesPerMinute to set + MIDI tempo. + + * lily/metronome-engraver.cc (process_music): use tempoUnitCount + tempoUnitDuration for determining what to print. + + * lily/lyric-extender.cc: typo. + + * lily/parser.yy (output_def_body): disallow \tempo in \midi{} + + * lily/duration-scheme.cc (LY_DEFINE): ly:duration-length: new function. + * scm/lily.scm (define-scheme-options): alphabetize, add eps-pad-boxes. * scm/framework-ps.scm (dump-stencil-as-EPS): only pad boxes if diff --git a/VERSION b/VERSION index 6839e1d0aa..3f435dd781 100644 --- a/VERSION +++ b/VERSION @@ -1,6 +1,6 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=2 MINOR_VERSION=9 -PATCH_LEVEL=15 +PATCH_LEVEL=16 MY_PATCH_LEVEL= diff --git a/lily/duration-scheme.cc b/lily/duration-scheme.cc index 6f1ea4ef90..fb4bb10263 100644 --- a/lily/duration-scheme.cc +++ b/lily/duration-scheme.cc @@ -113,6 +113,14 @@ LY_DEFINE (ly_intlog2, "ly:intlog2", return scm_from_int (log); } +LY_DEFINE (ly_duration_length, "ly:duration-length", + 1, 0, 0, (SCM dur), + "The length of the duration as a Moment.") +{ + SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration"); + return Moment (unsmob_duration (dur)->get_length ()).smobbed_copy (); +} + LY_DEFINE (ly_duration_factor, "ly:duration-factor", 1, 0, 0, (SCM dur), "Extract the compression factor from @var{dur}. Return as a pair.") diff --git a/lily/lyric-extender.cc b/lily/lyric-extender.cc index f507ddddaf..867a6d83d3 100644 --- a/lily/lyric-extender.cc +++ b/lily/lyric-extender.cc @@ -87,7 +87,8 @@ Lyric_extender::print (SCM smob) ADD_INTERFACE (Lyric_extender, "lyric-extender-interface", "The extender is a simple line at the baseline of the lyric " "that helps show the length of a melissima (tied/slurred note).", - "heads" + + "heads " "left-padding " "next " "right-padding " diff --git a/lily/metronome-engraver.cc b/lily/metronome-engraver.cc index 21eb711a24..40be81e221 100644 --- a/lily/metronome-engraver.cc +++ b/lily/metronome-engraver.cc @@ -11,9 +11,10 @@ using namespace std; #include "engraver.hh" -#include "note-column.hh" +#include "item.hh" #include "context.hh" #include "grob-array.hh" +#include "duration.hh" /** put stuff over or next to bars. Examples: bar numbers, marginal notes, @@ -26,19 +27,28 @@ public: protected: Item *text_; Grob *bar_line_; - Music *mark_ev_; - void create_items (Music *); + SCM last_duration_; + SCM last_count_; + protected: + virtual void derived_mark () const; void stop_translation_timestep (); - virtual bool try_music (Music *ev); void process_music (); }; Metronome_mark_engraver::Metronome_mark_engraver () { text_ = 0; - mark_ev_ = 0; + last_duration_ = SCM_EOL; + last_count_ = SCM_EOL; +} + +void +Metronome_mark_engraver::derived_mark () const +{ + scm_gc_mark (last_count_); + scm_gc_mark (last_duration_); } void @@ -53,37 +63,31 @@ Metronome_mark_engraver::stop_translation_timestep () text_ = 0; } - mark_ev_ = 0; -} - -void -Metronome_mark_engraver::create_items (Music *rq) -{ - if (text_) - return; - - text_ = make_item ("MetronomeMark", rq->self_scm ()); -} - -bool -Metronome_mark_engraver::try_music (Music *r) -{ - mark_ev_ = r; - return true; } void Metronome_mark_engraver::process_music () { - if (mark_ev_) + SCM count = get_property ("tempoUnitCount"); + SCM duration = get_property ("tempoUnitDuration"); + + if (unsmob_duration (duration) + && scm_is_number (count) + && !(ly_is_equal (count, last_count_) + && ly_is_equal (duration, last_duration_))) { - create_items (mark_ev_); + text_ = make_item ("MetronomeMark", SCM_EOL); SCM proc = get_property ("metronomeMarkFormatter"); - SCM result = scm_call_2 (proc, mark_ev_->self_scm (), + SCM result = scm_call_3 (proc, + duration, + count, context ()->self_scm ()); text_->set_property ("text", result); + + last_duration_ = duration; + last_count_ = count; } } @@ -96,6 +100,13 @@ ADD_TRANSLATOR (Metronome_mark_engraver, "The staves are taken from the @code{stavesFound} property, " "which is maintained by @code{@ref{Staff_collecting_engraver}}. ", /* create */ "MetronomeMark", - /* accept */ "metronome-change-event", - /* read */ "stavesFound metronomeMarkFormatter", + /* accept */ "", + + /* read */ + "stavesFound " + "metronomeMarkFormatter " + "tempoUnitDuration " + "tempoUnitCount " + , + /* write */ ""); diff --git a/lily/parser.yy b/lily/parser.yy index 1d54ba9760..7c04cb0c26 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -800,15 +800,6 @@ output_def_body: | output_def_body context_def_spec_block { assign_context_def ($$, $2); } - | output_def_body tempo_event { - /* - junk this ? there already is tempo stuff in - music. - */ - int m = scm_to_int (unsmob_music($2)->get_property ("metronome-count")); - Duration *d = unsmob_duration (unsmob_music($2)->get_property ("tempo-unit")); - set_tempo ($$, d->get_length (), m); - } | output_def_body error { } @@ -816,11 +807,8 @@ output_def_body: tempo_event: TEMPO steno_duration '=' bare_unsigned { - Music *m = MY_MAKE_MUSIC ("MetronomeChangeEvent"); - m->set_property ("tempo-unit", $2); - m->set_property ("metronome-count", scm_from_int ( $4)); - $$ = m->unprotect (); - } + $$ = MAKE_SYNTAX ("tempo", @$, $2, scm_int2num ($4)); + } ; /* diff --git a/lily/tempo-performer.cc b/lily/tempo-performer.cc index e21f617b60..52796a8947 100644 --- a/lily/tempo-performer.cc +++ b/lily/tempo-performer.cc @@ -22,17 +22,23 @@ public: protected: + virtual void derived_mark () const; void stop_translation_timestep (); void process_music (); - DECLARE_TRANSLATOR_LISTENER (metronome_change); private: - Stream_event *tempo_event_; Audio_tempo *audio_; + SCM last_tempo_; }; +void +Tempo_performer::derived_mark () const +{ + scm_gc_mark (last_tempo_); +} + Tempo_performer::Tempo_performer () { - tempo_event_ = 0; + last_tempo_ = SCM_EOL; audio_ = 0; } @@ -43,18 +49,19 @@ Tempo_performer::~Tempo_performer () void Tempo_performer::process_music () { - if (tempo_event_) + SCM w = get_property ("tempoWholesPerMinute"); + if (unsmob_moment (w) + && !ly_is_equal (w, last_tempo_)) { - SCM met = tempo_event_->get_property ("metronome-count"); - Duration *d = unsmob_duration (tempo_event_->get_property ("tempo-unit")); - - Rational r = (d->get_length () / Moment (Rational (1, 4)) * Moment (scm_to_int (met))).main_part_; + Rational r = unsmob_moment (w)->main_part_; + r *= Rational (4, 1); audio_ = new Audio_tempo (r.to_int ()); - Audio_element_info info (audio_, tempo_event_); + Audio_element_info info (audio_, 0); announce_element (info); - tempo_event_ = 0; + + last_tempo_ = w; } } @@ -68,13 +75,7 @@ Tempo_performer::stop_translation_timestep () } } -IMPLEMENT_TRANSLATOR_LISTENER (Tempo_performer, metronome_change); -void -Tempo_performer::listen_metronome_change (Stream_event *event) -{ - tempo_event_ = event; -} - ADD_TRANSLATOR (Tempo_performer, "", "", - "metronome-change-event", - "", ""); + "", + "tempoWholesPerMinute ", + ""); diff --git a/ly/midi-init.ly b/ly/midi-init.ly index a2a65b51cd..f4e50d89ec 100644 --- a/ly/midi-init.ly +++ b/ly/midi-init.ly @@ -1,6 +1,5 @@ \version "2.7.39" \midi { - \tempo 4=60 \include "performer-init.ly" } diff --git a/ly/performer-init.ly b/ly/performer-init.ly index 76ea46221d..d74ea2651f 100644 --- a/ly/performer-init.ly +++ b/ly/performer-init.ly @@ -117,6 +117,10 @@ melismaBusyProperties = #default-melisma-properties instrumentName = #"bright acoustic" + + %% quarter = 60 + tempoWholesPerMinute = #(ly:make-moment 15 1) + \accepts Staff \accepts DrumStaff \accepts GrandStaff diff --git a/python/convertrules.py b/python/convertrules.py index c4f2bb18f5..3f10e386fb 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -2832,3 +2832,36 @@ def conv (str): conversions.append (((2, 9, 13), conv, """instrument -> instrumentName, instr -> shortInstrumentName, vocNam -> shortVocalName""")) + +def conv (str): + m = re.search (r'\\tempo ([0-9]+)\s*([.]*)\s*=\s*([0-9]+)', str) + if m and re.search (r'\\midi', str): + dur = int (m.group (1)) + dots = len (m.group (2)) + count = int (m.group (3)) + + log2 = 0 + while dur > 1 : + dur /= 2 + log2 += 1 + + den = (1 << dots) * (1 << log2) + num = ((1 << (dots+1)) - 1) + + error_file.write (r""" + +\tempo in \midi is no longer supported. Use + + \midi { + \context { + \Score + tempoWholesPerMinute = #(ly:make-moment %d %d) + } + } + +""" % (num*count, den)) + + return str + +conversions.append (((2, 9, 16), conv, """deprecate \\tempo in \\midi""")) + diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index af87ed9220..caaa39c704 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -472,6 +472,10 @@ Example: This will create a start-repeat bar in this staff only. Valid values are described in @internalsref{bar-line-interface}. ") + (tempoWholesPerMinute 'ly:moment? "The tempo in whole notes per minute.") + (tempoUnitDuration 'ly:duration? "Unit for specifying tempo.") + (tempoUnitCount 'number? "Count for specifying tempo.") + ))) (define-public all-internal-translation-properties diff --git a/scm/define-event-classes.scm b/scm/define-event-classes.scm index b0fe109e2f..30f48999ad 100644 --- a/scm/define-event-classes.scm +++ b/scm/define-event-classes.scm @@ -17,7 +17,7 @@ (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 - metronome-change-event beam-forbid-event script-event + beam-forbid-event script-event tremolo-event bend-after-event fingering-event glissando-event harmonic-event hyphen-event laissez-vibrer-event mark-event multi-measure-text-event note-grouping-event diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index 7a06764063..cf9ea3505d 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -631,12 +631,6 @@ Syntax: @code{\\@var{number}}.") (types . (general-music string-number-event event)) )) - (MetronomeChangeEvent - . ( - (description . "Change tempo setting (in beats per minute).") - (types . (general-music metronome-change-event tempo-event event)) - )) - (TextScriptEvent . ( (description . "") diff --git a/scm/ly-syntax-constructors.scm b/scm/ly-syntax-constructors.scm index f4d23debdb..23befc939e 100644 --- a/scm/ly-syntax-constructors.scm +++ b/scm/ly-syntax-constructors.scm @@ -78,6 +78,17 @@ (make-music 'TransposedMusic 'element (ly:music-transpose music pitch))) +(define-ly-syntax-simple (tempo duration tempo) + (context-spec-music + (make-sequential-music + (list + (make-property-set 'tempoWholesPerMinute + (ly:moment-mul (ly:make-moment tempo 1) + (ly:duration-length duration))) + (make-property-set 'tempoUnitDuration duration) + (make-property-set 'tempoUnitCount tempo))) + 'Score)) + (define-ly-syntax-simple (skip-music dur) (make-music 'SkipMusic 'duration dur)) diff --git a/scm/translation-functions.scm b/scm/translation-functions.scm index 2767a7b212..998d05e836 100644 --- a/scm/translation-functions.scm +++ b/scm/translation-functions.scm @@ -6,13 +6,11 @@ ;;;; Jan Nieuwenhuizen ;; metronome marks -(define-public (format-metronome-markup event context) - (let* ((dur (ly:music-property event 'tempo-unit)) - (count (ly:music-property event 'metronome-count)) - (note-mark (make-smaller-markup - (make-note-by-number-markup (ly:duration-log dur) - (ly:duration-dot-count dur) - 1)))) +(define-public (format-metronome-markup dur count context) + (let* ((note-mark (make-smaller-markup + (make-note-by-number-markup (ly:duration-log dur) + (ly:duration-dot-count dur) + 1)))) (make-line-markup (list (make-general-align-markup Y DOWN note-mark) -- 2.39.5