lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Use the Score.skipTypesetting property also for MIDI generation


From: Johannes Schindelin
Subject: [PATCH] Use the Score.skipTypesetting property also for MIDI generation
Date: Thu, 15 Dec 2005 01:59:50 +0100 (CET)

I am actually much better at proof-hearing than proof-reading. So, skipping
music by enclosing it into

        \set Score.skipTypesetting = ##t

        % this music will be skipped
        ...

        \set Score.skipTypesetting = ##f

was not useful enough for me. So I whipped together this patch, which makes
the generated MIDI skip the same parts as the generated PDF.

The only part which was a bit tricky, is that the MIDI takes the timings from
the Audio_column's. I did not find another way than adjusting them from
within the Score_performer.

Signed-off-by: Johannes Schindelin <address@hidden>

---

 lily/audio-column.cc            |    6 ++++++
 lily/include/audio-column.hh    |    4 ++++
 lily/include/score-performer.hh |    3 +++
 lily/score-performer.cc         |   23 +++++++++++++++++++++--
 4 files changed, 34 insertions(+), 2 deletions(-)

0e2003a505f957d7ccb725ca14ca448ad5e7c732
diff --git a/lily/audio-column.cc b/lily/audio-column.cc
index a37704e..0409e38 100644
--- a/lily/audio-column.cc
+++ b/lily/audio-column.cc
@@ -29,3 +29,9 @@ Audio_column::at_mom () const
   return at_mom_;
 }
 
+void
+Audio_column::offset_at_mom(Moment m)
+{
+  at_mom_ += m;
+}
+
diff --git a/lily/include/audio-column.hh b/lily/include/audio-column.hh
index 3f99af9..657b01f 100644
--- a/lily/include/audio-column.hh
+++ b/lily/include/audio-column.hh
@@ -26,6 +26,10 @@ public:
 
   Link_array<Audio_item> audio_items_;
 
+protected:
+  void offset_at_mom(Moment m);
+  friend class Score_performer;
+
 private:
   Audio_column (Audio_column const &);
 
diff --git a/lily/include/score-performer.hh b/lily/include/score-performer.hh
index 895b302..e979d6a 100644
--- a/lily/include/score-performer.hh
+++ b/lily/include/score-performer.hh
@@ -37,6 +37,9 @@ private:
   void header (Midi_stream &);
 
   Audio_column *audio_column_;
+  bool skipping_;
+  Moment skip_start_mom_;
+  Moment offset_mom_;
 };
 
 #endif // SCORE_PERFORMER_HH
diff --git a/lily/score-performer.cc b/lily/score-performer.cc
index b5983bb..af7aba6 100644
--- a/lily/score-performer.cc
+++ b/lily/score-performer.cc
@@ -6,6 +6,7 @@
   (c) 1996--2005 Jan Nieuwenhuizen <address@hidden>
 */
 
+#include "moment.hh"
 #include "score-performer.hh"
 
 #include "audio-column.hh"
@@ -28,6 +29,7 @@ ADD_TRANSLATOR_GROUP (Score_performer,
 Score_performer::Score_performer ()
 {
   performance_ = 0;
+  skipping_ = false;
 }
 
 Score_performer::~Score_performer ()
@@ -68,8 +70,25 @@ Score_performer::finish ()
 void
 Score_performer::one_time_step ()
 {
-  precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP);
-  do_announces ();
+  if (!to_boolean (context ()->get_property ("skipTypesetting")))
+    {
+      if (skipping_)
+        {
+         offset_mom_ -= audio_column_->at_mom() - skip_start_mom_;
+         skipping_ = false;
+       }
+
+      audio_column_->offset_at_mom(offset_mom_);
+      precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP);
+      do_announces ();
+    }
+  else
+    if (!skipping_)
+      {
+       skip_start_mom_ = audio_column_->at_mom();
+       skipping_ = true;
+      }
+
   precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, 
UP);
 }
 
-- 
0.99.9.GIT




reply via email to

[Prev in Thread] Current Thread [Next in Thread]