From: Jan Nieuwenhuizen Date: Thu, 8 Jul 1999 10:03:06 +0000 (+0200) Subject: partial: 1.1.54.jcn X-Git-Tag: release/1.1.54~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fa3658f6c5e9fc51f6ae9286c65486975077c05c;p=lilypond.git partial: 1.1.54.jcn --- diff --git a/lily/grace-position-performer.cc b/lily/grace-position-performer.cc new file mode 100644 index 0000000000..41cee8065e --- /dev/null +++ b/lily/grace-position-performer.cc @@ -0,0 +1,124 @@ +/* + grace-position-performer.cc -- implement Grace_position_performer + + source file of the GNU LilyPond music typesetter + + (c) 1999 Jan Nieuwenhuizen + + */ + +#include "performer.hh" +#include "audio-item.hh" +#include "global-translator.hh" + +class Grace_position_performer : public Performer +{ +public: + Grace_position_performer (); + +protected: + Link_array graces_; + Link_array notes_; + + VIRTUAL_COPY_CONS (Translator); + virtual void acknowledge_element (Audio_element_info); + virtual void process_acknowledged (); + virtual void do_post_move_processing (); + Global_translator* global_translator_l (); +}; + +ADD_THIS_TRANSLATOR (Grace_position_performer); + +Grace_position_performer::Grace_position_performer () +{ +} + +void +Grace_position_performer::acknowledge_element (Audio_element_info i) +{ + if (Audio_note * n = dynamic_cast (i.elem_l_)) + { + if (i.elem_l_->grace_b_) + graces_.push (n); + else + notes_.push (n); + } +} + +void +Grace_position_performer::process_acknowledged () +{ + if (graces_.size ()) + { + // we're above grace-engraver-group, so we cannot tell + // grace-iterator. note-performer should add moments. + //Global_translator* global_l = global_translator_l (); + Moment delay_mom = Moment (1, 8); + if (notes_.size ()) + { + Moment shortest_mom = notes_[0]->length_mom_; + for (int i=1; i < notes_.size (); i++) + shortest_mom = shortest_mom length_mom_; + + Rational grace_fraction_rat (1, 2); + Scalar prop = get_property ("graceFraction", 0); + if (prop.length_i ()) + grace_fraction_rat = prop.to_rat (); + + delay_mom = shortest_mom * grace_fraction_rat; + for (int i=0; i < notes_.size (); i++) + { + Audio_note* n = notes_[i]; + n->length_mom_ -= delay_mom; + n->delayed_mom_ = delay_mom; + n->delayed_until_mom_ = now_mom () + delay_mom; + //global_l->add_moment_to_process (n->delayed_until_mom_); + } + notes_.clear (); + } + + Moment grace_length_mom; + for (int i=0; i < graces_.size (); i++) + grace_length_mom += graces_[i]->length_mom_; + + Rational grace_factor_rat = delay_mom / grace_length_mom; + + for (int i=0; i < graces_.size (); i++) + { + Audio_note* n = graces_[i]; + n->length_mom_ *= grace_factor_rat; + if (i) + { + Audio_note* p = graces_[i-1]; + n->delayed_mom_ = p->delayed_mom_ + p->length_mom_; + n->delayed_until_mom_ = now_mom () + n->delayed_mom_; + //global_l->add_moment_to_process (n->delayed_until_mom_); + } + } + graces_.clear (); + } +} + +Global_translator* +Grace_position_performer::global_translator_l () +{ + Translator *t = this; + Global_translator *global_l =0; + do + { + t = t->daddy_trans_l_ ; + global_l = dynamic_cast (t); + } + while (!global_l); + + return global_l; +} + + +void +Grace_position_performer::do_post_move_processing () +{ + graces_.clear (); + notes_.clear (); +} + diff --git a/lily/include/re-rhythmed-music.hh b/lily/include/re-rhythmed-music.hh new file mode 100644 index 0000000000..4c258a7be9 --- /dev/null +++ b/lily/include/re-rhythmed-music.hh @@ -0,0 +1,27 @@ +/* + re-rhythmed-music.hh -- declare Re_rhythmed_music + + source file of the GNU LilyPond music typesetter + + (c) 1999 Jan Nieuwenhuizen + + */ + +#ifndef RE_RHYTHMED_MUSIC_HH +#define RE_RHYTHMED_MUSIC_HH + +#include "music-wrapper.hh" + +class Re_rhythmed_music : public Music_wrapper +{ +public: + void do_print () const; + Re_rhythmed_music (Music*, Music*); + + VIRTUAL_COPY_CONS(Music); + virtual Music_iterator* to_rhythm (Music_iterator*); +}; + + +#endif /* RE_RHYTHMED_MUSIC_HH */ + diff --git a/lily/re-rhythmed-music.cc b/lily/re-rhythmed-music.cc new file mode 100644 index 0000000000..e2ba452819 --- /dev/null +++ b/lily/re-rhythmed-music.cc @@ -0,0 +1,41 @@ +/* + re-rhythmed-music.cc -- implement Re_rhythmed_music + + source file of the GNU LilyPond music typesetter + + (c) 1999 Jan Nieuwenhuizen + + */ + +#include "re-rhythmed-music.hh" +#include "music-iterator.hh" +#include "global-translator.hh" + +// urg +class Foo_translator : public Global_translator +{ +}; + +Music_iterator* +Re_rhythmed_music::to_rhythm (Music_iterator* r) +{ + return r; +} + +Re_rhythmed_music::Re_rhythmed_music (Music* m, Music* r) + : Music_wrapper (m) +{ + Music_iterator* i = Music_iterator::static_get_iterator_p (r); + Global_translator*t = new Foo_translator (); + i->init_translator (r, t); + i->construct_children (); + element_l ()->to_rhythm (i); +} + +void +Re_rhythmed_music::do_print () const +{ + Music_wrapper::do_print (); +} + +