]> git.donarmstrong.com Git - lilypond.git/commitdiff
* python/midi.c (midi_parse_track): robustness: don't read past
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 1 Sep 2006 02:01:02 +0000 (02:01 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 1 Sep 2006 02:01:02 +0000 (02:01 +0000)
end of string.

* ly/performer-init.ly: add Control_track_performer, move
Tempo_performer and Time_signature_performer to Score.

* lily/score-performer.cc (acknowledge_audio_elements): override
from base class: add to audio-columns

* lily/control-track-performer.cc (add_text): new file: generate
the control track.

* lily/performance.cc: move output_header_track to Control_track_performer()

* lily/midi-walker.cc (Midi_walker): get channel in constructor.

* lily/include/midi-item.hh (class Midi_channel_item): insert
class into hierarchy, for items that can have a channel setting. Dehungarify.

* lily/include/performer.hh (class Performer): remove
play_element();  move functionality into announce/acknowledge.

* lily/audio-staff.cc (output): remove channel_ from Midi_track.

25 files changed:
ChangeLog
lily/audio-staff.cc
lily/drum-note-performer.cc
lily/dynamic-performer.cc
lily/include/midi-item.hh
lily/include/midi-walker.hh
lily/include/performer-group.hh
lily/include/performer.hh
lily/include/score-performer.hh
lily/key-performer.cc
lily/lyric-performer.cc
lily/midi-item.cc
lily/midi-walker.cc
lily/note-performer.cc
lily/performance.cc
lily/performer-group.cc
lily/performer.cc
lily/piano-pedal-performer.cc
lily/score-performer.cc
lily/span-dynamic-performer.cc
lily/staff-performer.cc
lily/tempo-performer.cc
lily/time-signature-performer.cc
ly/performer-init.ly
python/midi.c

index ace0976c3fbc2396b6c4b54c3cbbf1584703515c..bcf5cae3142b8e5ba328eeb1e85f5993d10b5125 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2006-09-01  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
+       * python/midi.c (midi_parse_track): robustness: don't read past
+       end of string.
+
+       * ly/performer-init.ly: add Control_track_performer, move
+       Tempo_performer and Time_signature_performer to Score.        
+
+       * lily/score-performer.cc (acknowledge_audio_elements): override
+       from base class: add to audio-columns
+
+       * lily/control-track-performer.cc (add_text): new file: generate
+       the control track.
+
+       * lily/performance.cc: move output_header_track to Control_track_performer()
+
+       * lily/midi-walker.cc (Midi_walker): get channel in constructor.
+
+       * lily/include/midi-item.hh (class Midi_channel_item): insert
+       class into hierarchy, for items that can have a channel setting. Dehungarify.
+
+       * lily/include/performer.hh (class Performer): remove
+       play_element();  move functionality into announce/acknowledge.
+
+       * lily/audio-staff.cc (output): remove channel_ from Midi_track.
+
        * lily/tie-engraver.cc (stop_translation_timestep): only wipe
        heads_to_tie_ if there are new heads to tie.  Fixes polyphony in ties.
 
index a715cbc1de0ae906711deb7ce5ae1092c2b79860..5d402febf585c279248d46676b2232b7ab95a17f 100644 (file)
@@ -19,14 +19,14 @@ Audio_staff::add_audio_item (Audio_item *l)
 }
 
 void
-Audio_staff::output (Midi_stream &midi_stream, int track)
+Audio_staff::output (Midi_stream &midi_stream, int channel)
 {
   Midi_track midi_track;
-  midi_track.number_ = track;
-  midi_track.channel_ = channel_;
+  midi_track.number_ = channel;
   
-  for (Midi_walker i (this, &midi_track); i.ok (); i++)
+  for (Midi_walker i (this, &midi_track, channel); i.ok (); i++)
     i.process ();
+  
   midi_stream << midi_track;
 }
 
index 112ad6972c8ad872d149268629b0f8945a26cc8d..9a8e7e8e2ad23c9071bf698c743e553dabf0aea7 100644 (file)
@@ -64,11 +64,6 @@ Drum_note_performer::process_music ()
 void
 Drum_note_performer::stop_translation_timestep ()
 {
-  // why don't grace notes show up here?
-  // --> grace notes effectively do not get delayed
-  Moment now = now_mom ();
-  for (vsize i = 0; i < notes_.size (); i++)
-    play_element (notes_[i]);
   notes_.clear ();
   note_evs_.clear ();
 }
index ad0859e09af90815c74629769b0192dadbd141ac..1e538800b474c6e256b015c1e0873282a9a1cd60 100644 (file)
@@ -105,7 +105,6 @@ Dynamic_performer::stop_translation_timestep ()
 {
   if (audio_)
     {
-      play_element (audio_);
       audio_ = 0;
     }
 }
index ba3f2c0a9a61e0b76bc0dc438626ce0eae82b006..6ec530f68cfd0d1a4dd85ce495618a2f13ade476 100644 (file)
@@ -29,8 +29,16 @@ public:
   static string i2varint_string (int i);
 
   virtual string to_string () const = 0;
+};
 
+class Midi_channel_item : public Midi_item
+{
+public:
   int channel_;
+  DECLARE_CLASSNAME(Midi_channel_item);
+  Midi_channel_item ();
+  virtual const char *name () const { return "Midi_channel_item"; }
+  virtual ~Midi_channel_item ();
 };
 
 /**
@@ -83,7 +91,7 @@ public:
 /**
    Change instrument event
 */
-class Midi_instrument : public Midi_item
+class Midi_instrument : public Midi_channel_item
 {
 public:
   Midi_instrument (Audio_instrument *);
@@ -120,7 +128,7 @@ public:
 /**
    Turn a note on.
 */
-class Midi_note : public Midi_item
+class Midi_note : public Midi_channel_item
 {
 public:
   Midi_note (Audio_note *);
@@ -133,7 +141,8 @@ public:
 
   Audio_note *audio_;
 
-  static int const c0_pitch_i_ = 60;
+  
+  static int const c0_pitch_ = 60;
   Byte dynamic_byte_;
 };
 
@@ -169,7 +178,7 @@ public:
   Audio_text *audio_;
 };
 
-class Midi_dynamic : public Midi_item
+class Midi_dynamic : public Midi_channel_item
 {
 public:
   Midi_dynamic (Audio_dynamic *);
@@ -180,7 +189,7 @@ public:
   Audio_dynamic *audio_;
 };
 
-class Midi_piano_pedal : public Midi_item
+class Midi_piano_pedal : public Midi_channel_item
 {
 public:
   Midi_piano_pedal (Audio_piano_pedal *);
index a01add8f1e1d41daa337111893747abae3adf941..2d17efbc6093290576400cdb7819accec5c213e1 100644 (file)
@@ -26,7 +26,8 @@ int compare (Midi_note_event const &left, Midi_note_event const &right);
 class Midi_walker
 {
 public:
-  Midi_walker (Audio_staff *audio_staff, Midi_track *midi_track);
+  Midi_walker (Audio_staff *audio_staff, Midi_track *midi_track,
+              int channel);
   ~Midi_walker ();
 
   void process ();
@@ -38,6 +39,7 @@ private:
   void do_stop_notes (Moment now_mom);
   void output_event (Moment now_mom, Midi_item *l);
 
+  int channel_;
   Midi_track *track_;
   Audio_staff *staff_;
   vsize index_;
index b12a73c58680d93c22256f7eff2eaf7ffbef702b..94eceaecdef90a245c46d1cfe3736696cf95061a 100644 (file)
@@ -20,13 +20,10 @@ public:
 
   void do_announces ();
   virtual void announce_element (Audio_element_info);
-  virtual void play_element (Audio_element *p);
 
 protected:
   vector<Audio_element_info> announce_infos_;
-
-private:
-  void acknowledge_audio_elements ();
+  virtual void acknowledge_audio_elements ();
 };
 
 void performer_each (SCM list, Performer_method method);
index b97cea1926e4e24e45cdc3d07a2746066506a9cf..4eab36a3323711616e0f7d1a469405daaa2b4281 100644 (file)
@@ -25,7 +25,6 @@ protected:
   virtual void announce_element (Audio_element_info);
   virtual void acknowledge_audio_element (Audio_element_info);
   virtual void create_audio_elements ();
-  virtual void play_element (Audio_element *elem);
 };
 
 #endif /* PERFORMER_HH */
index 32344aa3a9d701cc5e4a71909cfef607ca86f37b..929853bba0d59baffb51d1d69107c94b5bf5b693 100644 (file)
@@ -18,10 +18,11 @@ class Score_performer : public Performer_group
 {
 public:
   VIRTUAL_COPY_CONSTRUCTOR (Translator_group, Score_performer);
-  ~Score_performer ();
   Performance *performance_;
 
+  ~Score_performer ();
   Score_performer ();
+
 protected:
   DECLARE_LISTENER (finish);
   DECLARE_LISTENER (prepare);
@@ -32,8 +33,8 @@ protected:
   virtual void disconnect_from_context ();
   virtual void initialize ();
   virtual void announce_element (Audio_element_info);
-  virtual void play_element (Audio_element *p);
   virtual void derived_mark () const;
+  virtual void acknowledge_audio_elements ();
 private:
   void header (Midi_stream &);
 
index c2fc6346cc4909b639d26f01addad75cb341bad2..df98520a1ac8bb1acc8d87f014ce113473b821b8 100644 (file)
@@ -83,7 +83,6 @@ Key_performer::stop_translation_timestep ()
 {
   if (audio_)
     {
-      play_element (audio_);
       audio_ = 0;
     }
 }
index 5e3a919b2cf7391b16c7a5408f9149c7611e4e66..fe0638eefc1577e468a0c2e19fe592e588a99636 100644 (file)
@@ -51,7 +51,6 @@ Lyric_performer::stop_translation_timestep ()
 {
   if (audio_)
     {
-      play_element (audio_);
       audio_ = 0;
     }
   events_.clear ();
index 7f8edb041cec4d2fc5d6425efd5ca111c52c95ef..88d303b4e7d80f7952ee4690cf18c245489ab6f7 100644 (file)
@@ -104,25 +104,25 @@ Midi_event::to_string () const
 {
   Rational rat_dt = (delta_mom_.main_part_ * Rational (384)
                     + delta_mom_.grace_part_ * Rational (100)) * Rational (4);
-  int delta_i = rat_dt.to_int ();
+  int delta = rat_dt.to_int ();
 
-  string delta_string = Midi_item::i2varint_string (delta_i);
+  string delta_string = Midi_item::i2varint_string (delta);
   string midi_string = midi_->to_string ();
   assert (midi_string.length ());
   return delta_string + midi_string;
 }
 
-Midi_header::Midi_header (int format_i, int tracks_i, int clocks_per_4_i)
+Midi_header::Midi_header (int format, int tracks, int clocks_per_4)
 {
   string str;
 
-  string format_string = String_convert::int2hex (format_i, 4, '0');
+  string format_string = String_convert::int2hex (format, 4, '0');
   str += String_convert::hex2bin (format_string);
 
-  string tracks_string = String_convert::int2hex (tracks_i, 4, '0');
+  string tracks_string = String_convert::int2hex (tracks, 4, '0');
   str += String_convert::hex2bin (tracks_string);
 
-  string tempo_string = String_convert::int2hex (clocks_per_4_i, 4, '0');
+  string tempo_string = String_convert::int2hex (clocks_per_4, 4, '0');
   str += String_convert::hex2bin (tempo_string);
 
   set ("MThd", str, "");
@@ -157,6 +157,15 @@ Midi_instrument::to_string () const
 }
 
 Midi_item::Midi_item ()
+{
+}
+
+Midi_channel_item::~Midi_channel_item ()
+{
+  channel_ = 0;
+}
+
+Midi_channel_item::Midi_channel_item ()
 {
   channel_ = 0;
 }
@@ -168,20 +177,20 @@ Midi_item::~Midi_item ()
 string
 Midi_item::i2varint_string (int i)
 {
-  int buffer_i = i & 0x7f;
+  int buffer = i & 0x7f;
   while ((i >>= 7) > 0)
     {
-      buffer_i <<= 8;
-      buffer_i |= 0x80;
-      buffer_i += (i & 0x7f);
+      buffer <<= 8;
+      buffer |= 0x80;
+      buffer += (i & 0x7f);
     }
 
   string str;
   while (1)
     {
-      str += ::to_string ((char)buffer_i);
-      if (buffer_i & 0x80)
-       buffer_i >>= 8;
+      str += ::to_string ((char)buffer);
+      if (buffer & 0x80)
+       buffer >>= 8;
       else
        break;
     }
@@ -292,7 +301,7 @@ Midi_note::to_string () const
     }
 
   str += ::to_string ((char)status_byte);
-  str += ::to_string ((char) (get_pitch () + c0_pitch_i_));
+  str += ::to_string ((char) (get_pitch () + c0_pitch_));
   str += ::to_string ((char)dynamic_byte_);
 
   return str;
@@ -317,7 +326,7 @@ Midi_note_off::to_string () const
   Byte status_byte = (char) (0x80 + channel_);
 
   string str = ::to_string ((char)status_byte);
-  str += ::to_string ((char) (get_pitch () + Midi_note::c0_pitch_i_));
+  str += ::to_string ((char) (get_pitch () + Midi_note::c0_pitch_));
   str += ::to_string ((char)aftertouch_byte_);
 
   if (get_fine_tuning () != 0)
@@ -392,9 +401,9 @@ Midi_tempo::Midi_tempo (Audio_tempo *a)
 string
 Midi_tempo::to_string () const
 {
-  int useconds_per_4_i = 60 * (int)1e6 / audio_->per_minute_4_;
+  int useconds_per_4 = 60 * (int)1e6 / audio_->per_minute_4_;
   string str = "ff5103";
-  str += String_convert::int2hex (useconds_per_4_i, 6, '0');
+  str += String_convert::int2hex (useconds_per_4, 6, '0');
   return String_convert::hex2bin (str);
 }
 
index 13bf59db8c2e4be028491e5966c1bf0b1b1e490b..2979c9380ce1127a3d6687180840ca1a70315730 100644 (file)
@@ -33,8 +33,10 @@ compare (Midi_note_event const &left, Midi_note_event const &right)
     return 0;
 }
 
-Midi_walker::Midi_walker (Audio_staff *audio_staff, Midi_track *track)
+Midi_walker::Midi_walker (Audio_staff *audio_staff, Midi_track *track,
+                         int channel)
 {
+  channel_ = channel;
   track_ = track;
   index_ = 0;
   items_ = &audio_staff->audio_items_;
@@ -144,7 +146,9 @@ Midi_walker::process ()
 
   if (Midi_item *midi = Midi_item::get_midi (audio))
     {
-      midi->channel_ = track_->channel_;
+      if (Midi_channel_item *mci = dynamic_cast<Midi_channel_item*> (midi))
+       mci->channel_ = channel_;
+      
       //midi->channel_ = track_->number_;
       if (Midi_note *note = dynamic_cast<Midi_note *> (midi))
        {
index a9acca733a513c64a9e3e7453c04d18403416d27..73a3def1c9a1b960c202da561a94aac00c790396 100644 (file)
@@ -67,9 +67,6 @@ Note_performer::stop_translation_timestep ()
 {
   // why don't grace notes show up here?
   // --> grace notes effectively do not get delayed
-  Moment now = now_mom ();
-  for (vsize i = 0; i < notes_.size (); i++)
-    play_element (notes_[i]);
   notes_.clear ();
   note_evs_.clear ();
 }
index 35d47e2ebc4869a3839771d15905e36430de77ab..0bfe37ee826581ccab7815b50afd71930725740f 100644 (file)
@@ -36,13 +36,12 @@ Performance::~Performance ()
 void
 Performance::output (Midi_stream &midi_stream)
 {
-  int tracks_i = audio_staffs_.size () + 1;
+  int tracks_ = audio_staffs_.size ();
 
   // ugh
-  int clocks_per_4_i = 384;
+  int clocks_per_4 = 384;
 
-  midi_stream << Midi_header (1, tracks_i, clocks_per_4_i);
-  output_header_track (midi_stream);
+  midi_stream << Midi_header (1, tracks_, clocks_per_4);
   message (_ ("Track...") + " ");
   int channel = 0;
   for (vsize i = 0; i < audio_staffs_.size (); i++)
@@ -62,82 +61,22 @@ Performance::output (Midi_stream &midi_stream)
        Huh? Why does each staff also have a separate channel? We
        should map channels to voices, not staves. --hwn.
       */
-      if (s->channel_ < 0)
+      if (channel > 15)
        {
-         s->channel_ = channel % 16;
-         if (channel > 15)
-           {
-             warning (_ ("MIDI channel wrapped around"));
-             warning (_ ("remapping modulo 16"));
-           }
+         warning (_ ("MIDI channel wrapped around"));
+         warning (_ ("remapping modulo 16"));
        }
 
-      s->output (midi_stream, channel++);
+      s->output (midi_stream, channel);
+      channel ++;
       if (be_verbose_global)
        progress_indication ("]");
     }
 }
 
-void
-Performance::output_header_track (Midi_stream &midi_stream)
-{
-  Midi_track midi_track;
-
-  midi_track.channel_ = 9;
-
-  // perhaps multiple text events?
-  string id_string;
-  string str = string (_ ("Creator: "));
-  id_string = String_convert::pad_to (gnu_lilypond_version_string (), 30);
-  str += id_string;
-
-  /*
-    This seems silly, but in fact the audio elements should
-    be generated elsewhere: not midi-specific.
-  */
-  Audio_text creator_a (Audio_text::TEXT, str);
-  Midi_text creator (&creator_a);
-  midi_track.add (Moment (0), &creator);
-
-  /* Better not translate this */
-  str = "Generated automatically by: ";
-  str += id_string;
-
-  Audio_text generate_a (Audio_text::TEXT, str);
-  Midi_text generate (&generate_a);
-  midi_track.add (Moment (0), &generate);
-
-  str = _ ("at ");
-  time_t t (time (0));
-  str += ctime (&t);
-  str = str.substr (0, str.length () - 1);
-  str = String_convert::pad_to (str, 60);
-
-  Audio_text at_a (Audio_text::TEXT, str);
-  Midi_text at (&at_a);
-  midi_track.add (Moment (0), &at);
-
-  // TODO:
-  //  str = _f ("from musical definition: %s", origin_string_);
-
-  Audio_text from_a (Audio_text::TEXT, str);
-  Midi_text from (&from_a);
-  midi_track.add (Moment (0), &from);
-
-  Audio_text track_name_a (Audio_text::TRACK_NAME, "Track "
-                          + String_convert::int2dec (0, 0, '0'));
-  Midi_text track_name (&track_name_a);
-
-  midi_track.add (Moment (0), &track_name);
-  midi_stream << midi_track;
-}
-
 void
 Performance::add_element (Audio_element *p)
 {
-  if (Audio_staff *s = dynamic_cast<Audio_staff *> (p))
-    audio_staffs_.push_back (s);
-
   audio_elements_.push_back (p);
 }
 
@@ -159,3 +98,4 @@ Performance::write_output (string out)
   progress_indication ("\n");
 }
 
+
index 990f478bf823f5395ec2715d90912342d0b228b3..d1696dac748317318eff66cef0731852ad1dd8d0 100644 (file)
@@ -84,15 +84,3 @@ Performer_group::do_announces ()
       announce_infos_.clear ();
     }
 }
-
-void
-Performer_group::play_element (Audio_element *e)
-{
-  Context *c = context_->get_parent_context ();
-  if (c)
-    {
-      Performer_group *pgp = dynamic_cast<Performer_group *> (c->implementation ());
-      pgp->play_element (e);
-    }
-}
-
index 28726bc7ef1bfa995ae0d1e6d50607870fbb19ff..9d99873989e8755c5bc3d72c115f0c050327d234 100644 (file)
 #include "performer-group.hh"
 #include "warn.hh"
 
-void
-Performer::play_element (Audio_element *p)
-{
-  get_daddy_performer ()->play_element (p);
-}
 
 Performer_group *
 Performer::get_daddy_performer () const
index 779624cdc4f73bbb260d956b78d130bc72f0ca35..3b51fd83ec86808f538cc105dd38184a91c5e789 100644 (file)
@@ -121,8 +121,6 @@ Piano_pedal_performer::process_music ()
 void
 Piano_pedal_performer::stop_translation_timestep ()
 {
-  for (vsize i = 0; i < audios_.size (); i++)
-    play_element (audios_[i]);
   audios_.clear ();
 }
 
index 7252b0cff7832c11ce56296d51612bc842981a37..2bdfdd54b9101bcb967742b29ca5875b9b999743 100644 (file)
@@ -20,6 +20,8 @@
 #include "output-def.hh"
 #include "string-convert.hh"
 #include "warn.hh"
+#include "audio-staff.hh"
+#include "audio-item.hh"
 
 ADD_TRANSLATOR_GROUP (Score_performer,
                      /* doc */ "",
@@ -32,6 +34,7 @@ Score_performer::Score_performer ()
 {
   performance_ = 0;
   skipping_ = false;
+  audio_column_ = 0;
 }
 
 Score_performer::~Score_performer ()
@@ -39,19 +42,29 @@ Score_performer::~Score_performer ()
 }
 
 void
-Score_performer::play_element (Audio_element *p)
+Score_performer::announce_element (Audio_element_info info)
 {
-  if (Audio_item *i = dynamic_cast<Audio_item *> (p))
-    audio_column_->add_audio_item (i);
-  performance_->add_element (p);
+  announce_infos_.push_back (info);
+  if (Audio_staff *s = dynamic_cast<Audio_staff*> (info.elem_))
+    {
+      performance_->audio_staffs_.push_back (s);
+    }
+
+  performance_->add_element (info.elem_);
 }
 
 void
-Score_performer::announce_element (Audio_element_info info)
+Score_performer::acknowledge_audio_elements ()
 {
-  announce_infos_.push_back (info);
+  for (vsize i = 0; i < announce_infos_.size (); i++)
+    {
+      if (Audio_item *ai = dynamic_cast<Audio_item *> (announce_infos_[i].elem_))
+       audio_column_->add_audio_item (ai);
+    }
+  Performer_group::acknowledge_audio_elements ();
 }
 
+
 void
 Score_performer::connect_to_context (Context *c)
 {
@@ -82,7 +95,6 @@ Score_performer::prepare (SCM sev)
   SCM sm = ev->get_property ("moment");
   Moment *m = unsmob_moment (sm);
   audio_column_ = new Audio_column (*m);
-  play_element (audio_column_);
   precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, UP);
 }
 
@@ -141,5 +153,8 @@ Score_performer::initialize ()
   context ()->set_property ("output", performance_->self_scm ()); 
   performance_->midi_ = context ()->get_output_def ();
 
+
   Translator_group::initialize ();
 }
+
+
index 755dd86925c4c37a298507fc441447ab791c80ef..4da025d57d6d96eb0396f400fb8c6b80cb5f2bf2 100644 (file)
@@ -158,7 +158,6 @@ Span_dynamic_performer::stop_translation_timestep ()
 
   if (audio_)
     {
-      play_element (audio_);
       audio_ = 0;
     }
 
index 54a57b94515fa72d5be2ce7d7e51fcdba307e478..c73ab6eb81e322bb6a3747b1f97bb69399c8be3c 100644 (file)
@@ -65,19 +65,10 @@ Staff_performer::initialize ()
   audio_staff_ = new Audio_staff;
   name_ = new Audio_text (Audio_text::TRACK_NAME, context ()->id_string ());
 
-  Rational r = robust_scm2moment (get_property ("tempoWholesPerMinute"),
-                                 Moment (15,1)).main_part_;
-
-  r *= Rational (4,1);
-  
-  tempo_ = new Audio_tempo (r.to_int ());
-
   audio_staff_->add_audio_item (name_);
-  audio_staff_->add_audio_item (tempo_);
   
   announce_element (Audio_element_info (audio_staff_, 0));
   announce_element (Audio_element_info (name_, 0));
-  announce_element (Audio_element_info (tempo_, 0));
 }
 
 void
@@ -97,8 +88,6 @@ Staff_performer::process_music ()
       /*
        Have to be here before notes arrive into the staff.
       */
-      play_element (instrument_);
-      play_element (instrument_name_);
     }
 }
 
@@ -111,12 +100,10 @@ Staff_performer::stop_translation_timestep ()
   audio_staff_->channel_ = (drums == SCM_BOOL_T ? 9 : -1);
   if (name_)
     {
-      play_element (name_);
       name_ = 0;
     }
   if (tempo_)
     {
-      play_element (tempo_);
       tempo_ = 0;
     }
   instrument_name_ = 0;
@@ -126,7 +113,6 @@ Staff_performer::stop_translation_timestep ()
 void
 Staff_performer::finalize ()
 {
-  Performer::play_element (audio_staff_);
   audio_staff_ = 0;
 }
 
index 52796a8947c46c4b57e786934abd9e5a204fa974..19a453f01bbb8cf6240ec196c563320bec19e3c8 100644 (file)
@@ -38,7 +38,6 @@ Tempo_performer::derived_mark () const
 
 Tempo_performer::Tempo_performer ()
 {
-  last_tempo_ = SCM_EOL;
   audio_ = 0;
 }
 
@@ -70,7 +69,6 @@ Tempo_performer::stop_translation_timestep ()
 {
   if (audio_)
     {
-      play_element (audio_);
       audio_ = 0;
     }
 }
index b6c6b8af11ff61034d6dadf60e681fc43ba1bb89..cef302c49caa8d27871cd26833523c5636519b28 100644 (file)
@@ -64,7 +64,6 @@ Time_signature_performer::stop_translation_timestep ()
 {
   if (audio_)
     {
-      play_element (audio_);
       audio_ = 0;
     }
 }
index d74ea2651f3074100cd8016d38007fe1f47de947..726ffaa6613e926bfd88ae08413b9e94c470a7d7 100644 (file)
@@ -12,8 +12,6 @@
     
     \consists "Staff_performer"
     \consists "Key_performer"
-    \consists "Tempo_performer"
-    \consists "Time_signature_performer"
 }
 \context {
     \name Global
     \accepts FiguredBass
     \accepts Lyrics
     \accepts VaticanaStaff
-    
+
+    \consists "Time_signature_performer"
+    \consists "Control_track_performer"
+    \consists "Tempo_performer"
     \consists "Timing_translator"
     \consists "Swallow_performer"
-
+    
     \defaultchild "Staff"
     
     dynamicAbsoluteVolumeFunction = #default-dynamic-absolute-volume
     \consists "Staff_performer" % Performer_group ?
     \consists "Lyric_performer"
     \name Lyrics
-    \consists "Time_signature_performer"
-    \consists "Tempo_performer"
 }
 
 \context{
index b5e2f5bf57b1b6a14ca920b124732091abd46b24..8ccbaf975857160f10bde37b2cfc2c56f3469a1e 100644 (file)
@@ -135,7 +135,8 @@ get_number (unsigned char ** str, unsigned char * end_str, int length)
   long sum = 0;
   int i = 0;
   
-  for (; i < length; i++)
+  for (; i < length &&
+        ((*str) + i < end_str); i++)
     sum = (sum << 8) + (unsigned char) (*str)[i];
 
   *str += length;
@@ -204,8 +205,8 @@ read_string (unsigned char **track, unsigned char *end)
 }
 
 typedef PyObject* (*Read_midi_event)
-     (unsigned char **track, unsigned char *end, 
-      unsigned char x);
+  (unsigned char **track, unsigned char *end, 
+   unsigned char x);
 
 
 static PyObject *
@@ -299,7 +300,8 @@ midi_parse_track (unsigned char **track, unsigned char *track_end)
 
   pytrack = PyList_New (0);
 
-  track_end = *track + track_len;
+  if (*track + track_len < track_end)
+    track_end = *track + track_len;
 
   {  
     PyObject *pytime = PyInt_FromLong (0L);
@@ -357,7 +359,6 @@ midi_parse (unsigned char **midi,unsigned  char *midi_end)
 
   /* Header */
   header_len = get_number (midi, *midi + 4, 4);
-
   
   if (header_len < 6)
     return midi_error (__FUNCTION__,  ": header too short");
@@ -400,7 +401,7 @@ pymidi_parse (PyObject *self, PyObject *args)
     return 0;
 
   if (memcmp (midi, "MThd", 4))
-      return midi_error (__FUNCTION__,  ": MThd expected");
+    return midi_error (__FUNCTION__,  ": MThd expected");
   
   midi += 4;