]> git.donarmstrong.com Git - lilypond.git/commitdiff
partial: 1.1.54.jcn
authorJan Nieuwenhuizen <janneke@gnu.org>
Thu, 8 Jul 1999 10:03:06 +0000 (12:03 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Thu, 8 Jul 1999 10:03:06 +0000 (12:03 +0200)
lily/grace-position-performer.cc [new file with mode: 0644]
lily/include/re-rhythmed-music.hh [new file with mode: 0644]
lily/re-rhythmed-music.cc [new file with mode: 0644]

diff --git a/lily/grace-position-performer.cc b/lily/grace-position-performer.cc
new file mode 100644 (file)
index 0000000..41cee80
--- /dev/null
@@ -0,0 +1,124 @@
+/*   
+  grace-position-performer.cc --  implement Grace_position_performer
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ */
+
+#include "performer.hh"
+#include "audio-item.hh"
+#include "global-translator.hh"
+
+class Grace_position_performer : public Performer
+{
+public:
+  Grace_position_performer ();
+
+protected:
+  Link_array<Audio_note> graces_;
+  Link_array<Audio_note> 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 <Audio_note*> (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 <? notes_[i]->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<Global_translator*> (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 (file)
index 0000000..4c258a7
--- /dev/null
@@ -0,0 +1,27 @@
+/*   
+  re-rhythmed-music.hh -- declare Re_rhythmed_music
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
+  
+ */
+
+#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 (file)
index 0000000..e2ba452
--- /dev/null
@@ -0,0 +1,41 @@
+/*   
+  re-rhythmed-music.cc --  implement Re_rhythmed_music
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ */
+
+#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 ();
+}
+
+