From 4990a43304a74ffe431951798e9d674101f09278 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 8 Mar 2000 15:35:43 +0100 Subject: [PATCH] patch::: 1.3.30.jcn2 1.3.30.jcn2 =========== * Dynamic_performer: performs absolute dynamic requests. * David's comments on opus47 --- Generated by janneke@gnu.org, From = lilypond-1.3.30.jcn1, To = lilypond-1.3.30.jcn2 usage cd lilypond-source-dir; patch -E -p1 < lilypond-1.3.30.jcn2.diff Patches do not contain automatically generated files or (urg) empty directories, i.e., you should rerun autoconf, configure --- CHANGES | 14 ++++- TODO | 19 ++++++ VERSION | 2 +- input/test/absolute-volume.ly | 19 ++++++ lily/audio-item.cc | 5 ++ lily/dynamic-engraver.cc | 9 +++ lily/dynamic-performer.cc | 112 ++++++++++++++++++++++++++++++++++ lily/include/audio-item.hh | 8 +++ lily/include/lily-proto.hh | 4 ++ lily/include/midi-item.hh | 10 +++ lily/include/slur.hh | 2 +- lily/midi-item.cc | 23 +++++++ ly/midi.ly | 2 + ly/performer.ly | 2 + scm/midi.scm | 31 ++++++++++ 15 files changed, 259 insertions(+), 3 deletions(-) create mode 100644 input/test/absolute-volume.ly create mode 100644 lily/dynamic-performer.cc create mode 100644 scm/midi.scm diff --git a/CHANGES b/CHANGES index 3bba7a6711..e36d3f8b07 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,16 @@ ---- ../lilypond-1.3.30/CHANGES Mon Mar 6 12:10:00 2000 +--- ../lilypond-1.3.30.jcn1/CHANGES Tue Mar 7 23:59:44 2000 +++ b/CHANGES Wed Mar 8 15:35:43 2000 +@@ -1,3 +1,10 @@ +1.3.30.jcn2 +=========== + +* Dynamic_performer: performs absolute dynamic requests. + +* David's comments on opus47 + + 1.3.30.jcn1 + =========== + --- ../lilypond-1.3.30/CHANGES Mon Mar 6 12:10:00 2000 ++ b/CHANGES Tue Mar 7 23:59:44 2000 @@ -1,3 +1,9 @@ 1.3.30.jcn1 diff --git a/TODO b/TODO index 1ef055e129..94b4f38ce5 100644 --- a/TODO +++ b/TODO @@ -16,6 +16,25 @@ Grep -i for TODO, FIXME and ugh/ugr/urg. . * hard constraints for broken slurs to. . * Staff_margin_engraver placement is broken for Staff.instr(ument) . * Bracket/brace placement and stacking is broken +. * Lattermann: + + 2. There dynamic markings of the cello part are set in roman (maybe + because of pizz. and arco in roman?) + + 4. Bar 41/42, violins: the ties should be the same direction, pref. + down in bar 42. + -- dir of broken ties + + 7. This is a bug: there's a colon in the middle of the two harmonium + staves + + 12. bars 82 to 84 and 88: the ties of upper harmonium should all bend down. + -- stemdown ~ stemup and at linebreak + + 15. bar 89, harmonium, the ties coming from the previous line look strangely + asymmetric. + + . * Mondrup: - In some cases I don't get the large textsize within note examples I request. diff --git a/VERSION b/VERSION index 12548aeb77..f1b86883ae 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=30 -MY_PATCH_LEVEL=jcn1 +MY_PATCH_LEVEL=jcn2 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/test/absolute-volume.ly b/input/test/absolute-volume.ly new file mode 100644 index 0000000000..b372e4772d --- /dev/null +++ b/input/test/absolute-volume.ly @@ -0,0 +1,19 @@ +\score{ +\notes\relative c''{ +%segfault in engraver +a1\ppp +a1\pp +a\p +a\mp +a\mf +a\f +a\ff +a\fff +a\sf +} +\paper{ +} +\midi{ +\tempo 1 = 60; +} +} diff --git a/lily/audio-item.cc b/lily/audio-item.cc index 089469ba05..410222f0e5 100644 --- a/lily/audio-item.cc +++ b/lily/audio-item.cc @@ -45,6 +45,11 @@ Audio_key::Audio_key (Key_def const& k) key_ = k; } +Audio_dynamic::Audio_dynamic (int volume) +{ + volume_i_ = volume; +} + Audio_tempo::Audio_tempo (int per_minute_4_i) { per_minute_4_i_ = per_minute_4_i; diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 977053e621..88de9812a2 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -20,6 +20,15 @@ #include "note-head.hh" #include "group-interface.hh" +/* + TODO: + multiple type of span dynamic: + * hairpin + * text: + - `cresc. -- -- --' + - `cresc. poco a poco -- -- --' + */ + /** print text & hairpin dynamics. */ diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc new file mode 100644 index 0000000000..b7472eaf51 --- /dev/null +++ b/lily/dynamic-performer.cc @@ -0,0 +1,112 @@ +/* + dynamic-performer.cc -- implement Dynamic_performer + + source file of the GNU LilyPond music typesetter + + (c) 2000 Jan Nieuwenhuizen +*/ + +#include "performer.hh" +#include "command-request.hh" +#include "musical-request.hh" +#include "audio-item.hh" + +/* + TODO: + handle multiple requests + handle span requests (crescendo/decrescendo) + */ + +/** + perform absolute (text) dynamics + */ +class Dynamic_performer : public Performer +{ +public: + VIRTUAL_COPY_CONS (Translator); + + Dynamic_performer (); + ~Dynamic_performer (); + +protected: + void do_print () const; + virtual bool do_try_music (Music* req_l); + virtual void do_process_requests (); + virtual void do_pre_move_processing (); + +private: + Text_script_req* text_script_req_l_; + Audio_dynamic* audio_p_; +}; + +ADD_THIS_TRANSLATOR (Dynamic_performer); + +Dynamic_performer::Dynamic_performer () +{ + text_script_req_l_ = 0; + audio_p_ = 0; +} + +Dynamic_performer::~Dynamic_performer () +{ +} + +void +Dynamic_performer::do_print () const +{ +#ifndef NPRINT + if (text_script_req_l_) + text_script_req_l_->print (); +#endif +} + +void +Dynamic_performer::do_process_requests () +{ + if (text_script_req_l_) + { + + SCM s = scm_eval + (gh_list + (ly_symbol2scm ("dynamic-absolute-volume"), + ly_quote_scm (ly_str02scm (text_script_req_l_->text_str_.ch_C ())), + SCM_UNDEFINED)); + int volume = gh_scm2int (ly_eval_str ("dynamic-default-volume")); + if (gh_number_p (s)) + volume = gh_scm2int (s); + + audio_p_ = new Audio_dynamic (volume); + Audio_element_info info (audio_p_, text_script_req_l_); + announce_element (info); + text_script_req_l_ = 0; + } +} + +void +Dynamic_performer::do_pre_move_processing () +{ + if (audio_p_) + { + play_element (audio_p_); + audio_p_ = 0; + } +} + +bool +Dynamic_performer::do_try_music (Music* r) +{ + if (!text_script_req_l_) + { + // urg, text script, style `dynamic' is how absolute dynamics appear + if(Text_script_req* t = dynamic_cast (r)) + { + if (t->style_str_ == "dynamic") + { + text_script_req_l_ = t; + return true; + } + } + } + return false; +} + diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh index 08c780fecf..8edd0ef388 100644 --- a/lily/include/audio-item.hh +++ b/lily/include/audio-item.hh @@ -37,6 +37,14 @@ private: Audio_item& operator=( Audio_item const&); }; +class Audio_dynamic : public Audio_item +{ +public: + Audio_dynamic (int volume); + + int volume_i_; +}; + class Audio_key : public Audio_item { public: diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index af8c468994..3a6f324771 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -19,6 +19,7 @@ struct Align_element; struct All_font_metrics; struct Articulation_req; struct Audio_column; +struct Audio_dynamic; struct Audio_element; struct Audio_element_info; struct Audio_instrument; @@ -80,6 +81,7 @@ struct Command_script_req; struct Command_tie_engraver; struct Crescendo ; struct Dimension_cache; +struct Dynamic_performer; struct Spanner; struct Dot_column; struct Dots; @@ -128,6 +130,7 @@ struct Measure_grouping_req; struct Melodic_req; struct Midi_def; struct Midi_duration; +struct Midi_dynamic; struct Midi_header; struct Midi_item; struct Midi_key; @@ -216,6 +219,7 @@ struct Simultaneous_music; struct Single_malt_grouping_item; struct Skip_req; struct Slur; +struct Slur_bezier_bow; struct Slur_engraver; struct Spacing_spanner; struct Span_bar; diff --git a/lily/include/midi-item.hh b/lily/include/midi-item.hh index b10ad8c5f9..c9823dbcf2 100644 --- a/lily/include/midi-item.hh +++ b/lily/include/midi-item.hh @@ -160,6 +160,16 @@ public: Audio_text* audio_l_; }; +class Midi_dynamic : public Midi_item +{ +public: + Midi_dynamic (Audio_dynamic*); + + virtual String str () const; + + Audio_dynamic* audio_l_; +}; + class Midi_tempo : public Midi_item { public: diff --git a/lily/include/slur.hh b/lily/include/slur.hh index 4f14512047..93844719cc 100644 --- a/lily/include/slur.hh +++ b/lily/include/slur.hh @@ -35,7 +35,7 @@ protected: Array get_rods () const; private: - void de_uglyfy (class Slur_bezier_bow* bb, Real default_height); + void de_uglyfy (Slur_bezier_bow* bb, Real default_height); void set_extremities (); void set_control_points (); int cross_staff_count () const; diff --git a/lily/midi-item.cc b/lily/midi-item.cc index aeaa53ffa2..b822a6655e 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -27,6 +27,8 @@ Midi_item::midi_p (Audio_item* a) return i->str_.length_i () ? new Midi_instrument (i) : 0; else if (Audio_note* i = dynamic_cast (a)) return new Midi_note (i); + else if (Audio_dynamic* i = dynamic_cast (a)) + return new Midi_dynamic (i); else if (Audio_tempo* i = dynamic_cast (a)) return new Midi_tempo (i); else if (Audio_time_signature* i = dynamic_cast (a)) @@ -458,6 +460,27 @@ Midi_note_off::str () const return str; } +Midi_dynamic::Midi_dynamic (Audio_dynamic* a) +{ + audio_l_ = a; +} + +String +Midi_dynamic::str () const +{ + Byte status_byte = (char) (0xB0 + channel_i_); + String str = to_str ((char)status_byte); + + /* + Main volume controller (per channel): + 07 MSB + 27 LSB + */ + str += to_str ((char)0x07); + str += to_str ((char)audio_l_->volume_i_); + return str; +} + Midi_tempo::Midi_tempo (Audio_tempo* a) { audio_l_ = a; diff --git a/ly/midi.ly b/ly/midi.ly index d47242bf58..b41614cc2b 100644 --- a/ly/midi.ly +++ b/ly/midi.ly @@ -1,4 +1,6 @@ +#(eval-string (ly-gulp-file "midi.scm")) + \midi { \tempo 4=60; \include "performer.ly" diff --git a/ly/performer.ly b/ly/performer.ly index 44e3272c53..21ec1095f2 100644 --- a/ly/performer.ly +++ b/ly/performer.ly @@ -14,6 +14,7 @@ StaffContext = \translator { \consists "Key_performer"; \consists "Time_signature_performer"; \consists "Tempo_performer"; + dynamicStyle = #"dynamic" }; \translator { \StaffContext } @@ -41,6 +42,7 @@ VoiceContext = \translator { \type "Performer_group_performer"; \name Voice; % All notes fall to Grace if you leave Thread out (huh?) + \consists "Dynamic_performer"; % must come before text_engraver. \consists "Grace_position_performer"; \accepts Thread; \accepts Grace; diff --git a/scm/midi.scm b/scm/midi.scm new file mode 100644 index 0000000000..0e42d834a2 --- /dev/null +++ b/scm/midi.scm @@ -0,0 +1,31 @@ +;;; midi.scm -- scm midi variables and functions +;;; +;;; source file of the GNU LilyPond music typesetter +;;; +;;; (c) 2000 Jan Nieuwenhuizen + + +(define absolute-volume-alist '()) +(set! absolute-volume-alist + (append + '( + ("sf" . 115) + ("fff" . 102) + ("ff" . 90) + ("f" . 77) + ("mf" . 64) + ("mp" . 51) + ("p" . 38) + ("pp" . 26) + ("ppp" . 13) + ) + absolute-volume-alist)) + +(define (dynamic-absolute-volume s) + (let ((entry (assoc s absolute-volume-alist))) + (if entry + (cdr entry)))) + +;; 90 is supposed to be the default value +;; urg: we should set this at start of track +(define dynamic-default-volume 90) -- 2.39.2