]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.43
authorfred <fred>
Tue, 26 Mar 2002 23:10:37 +0000 (23:10 +0000)
committerfred <fred>
Tue, 26 Mar 2002 23:10:37 +0000 (23:10 +0000)
lily/include/audio-item.hh
lily/include/midi-item.hh
lily/midi-item.cc
lily/piano-pedal-performer.cc [new file with mode: 0644]
ly/performer.ly
ly/spanners.ly

index 9b59283804b7aadf1f175db801a36b611b265f90..9c01181055731e33127fb646eba17dba752d9871 100644 (file)
@@ -76,6 +76,12 @@ public:
   Audio_note* tied_;
 };
 
+class Audio_piano_pedal : public Audio_item
+{
+public:
+  bool type_b_;
+};
+
 class Audio_text : public Audio_item
 {
 public:
index c9823dbcf2b50b1a78b1280fc9733e1ebcae8762..2dac25e853e644727c6ed67b4c79b5118b0cf69a 100644 (file)
@@ -12,6 +12,7 @@
 #include "lily-proto.hh"
 #include "proto.hh"
 #include "moment.hh"
+#include "audio-item.hh"
 
 /**
   Any piece of midi information.
@@ -170,6 +171,16 @@ public:
   Audio_dynamic* audio_l_;
 };
 
+class Midi_piano_pedal : public Midi_item
+{
+public:
+  Midi_piano_pedal (Audio_piano_pedal*);
+  
+  virtual String str () const;
+
+  Audio_piano_pedal* audio_l_;
+};
+
 class Midi_tempo : public Midi_item
 {
 public:
index a5921325e248607c02cadc7192891f4654467412..683269212963467181b66a7acc333b56cc307b29 100644 (file)
@@ -29,6 +29,8 @@ Midi_item::midi_p (Audio_item* a)
     return new Midi_note (i);
   else if (Audio_dynamic* i = dynamic_cast<Audio_dynamic*> (a))
     return new Midi_dynamic (i);
+  else if (Audio_piano_pedal* i = dynamic_cast<Audio_piano_pedal*> (a))
+    return new Midi_piano_pedal (i);
   else if (Audio_tempo* i = dynamic_cast<Audio_tempo*> (a))
     return new Midi_tempo (i);
   else if (Audio_time_signature* i = dynamic_cast<Audio_time_signature*> (a))
@@ -489,6 +491,23 @@ Midi_dynamic::str () const
   return str;
 }
 
+Midi_piano_pedal::Midi_piano_pedal (Audio_piano_pedal* a)
+{
+  audio_l_ = a;
+}
+
+String
+Midi_piano_pedal::str () const
+{
+  Byte status_byte = (char) (0xB0 + channel_i_);
+  String str = to_str ((char)status_byte);
+
+  str += to_str ((char)0x40);
+  int pedal = audio_l_->type_b_ ? 0x7f : 0;
+  str += to_str ((char)pedal);
+  return str;
+}
+
 Midi_tempo::Midi_tempo (Audio_tempo* a)
 {
   audio_l_ = a;
diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc
new file mode 100644 (file)
index 0000000..f5cfd90
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ piano-pedal-performer.cc -- implement Piano_pedal_performer
+
+  source file of the GNU LilyPond music typesetter
+
+  (c)  2000 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "performer.hh"
+#include "command-request.hh"
+#include "musical-request.hh"
+#include "audio-item.hh"
+
+
+/*
+  TODO:
+    sostenuto
+    una-chorda ?
+ */
+
+/**
+   perform Piano pedals
+ */
+class Piano_pedal_performer : public Performer
+{
+public:
+  VIRTUAL_COPY_CONS (Translator);
+  
+  Piano_pedal_performer ();
+
+protected:
+  virtual bool do_try_music (Music*);
+  virtual void do_process_music ();
+  virtual void do_pre_move_processing ();
+  virtual void do_post_move_processing ();
+
+private:
+  Link_array<Audio_piano_pedal> audio_p_arr_;
+  Span_req* span_start_req_l_;
+  Drul_array<Span_req*> span_req_l_drul_;
+};
+
+ADD_THIS_TRANSLATOR (Piano_pedal_performer);
+
+Piano_pedal_performer::Piano_pedal_performer ()
+{
+  span_req_l_drul_[START] = 0;
+  span_req_l_drul_[STOP] = 0;
+  span_start_req_l_ = 0;
+}
+
+void
+Piano_pedal_performer::do_process_music ()
+{
+  if (span_req_l_drul_[STOP])
+    {
+      if (!span_start_req_l_)
+       {
+         span_req_l_drul_[STOP]->warning (_ ("can't find start of piano_pedal"));
+       }
+      else
+       {
+         Audio_piano_pedal* p = new Audio_piano_pedal;
+         p->type_b_ = false;
+         audio_p_arr_.push (p);
+       }
+      span_start_req_l_ = 0;
+    }
+
+  if (span_req_l_drul_[START])
+    {
+      span_start_req_l_ = span_req_l_drul_[START];
+      Audio_piano_pedal* p = new Audio_piano_pedal;
+      p->type_b_ = true;
+      audio_p_arr_.push (p);
+    }
+}
+
+void
+Piano_pedal_performer::do_pre_move_processing ()
+{
+  for (int i=0; i < audio_p_arr_.size (); i++)
+    play_element (audio_p_arr_[i]);
+  audio_p_arr_.clear ();
+}
+
+void
+Piano_pedal_performer::do_post_move_processing ()
+{
+  span_req_l_drul_[STOP] = 0;
+  span_req_l_drul_[START] = 0;
+}
+
+bool
+Piano_pedal_performer::do_try_music (Music* r)
+{
+  if (Span_req * s = dynamic_cast<Span_req*>(r))
+    {
+      if (s-> span_type_str_ == "sustain")
+       {
+         span_req_l_drul_[s->span_dir_] = s;
+         return true;
+       }
+    }
+  return false;
+}
index ff373d52197ac71af5d68ab31cd49f5a28b0d949..3337c51cc821c1ed66703adbce4fcc819e51d4dc 100644 (file)
@@ -24,6 +24,7 @@ VoiceContext = \translator {
 % All notes fall to Grace if you leave Thread out (huh?)
        \consists "Dynamic_performer";
        \consists "Span_dynamic_performer";
+       \consists "Piano_pedal_performer";
        \consists "Grace_position_performer";
        \accepts Thread;
        \accepts Grace;
index 4b3d6bdb138d20297547329ac59378992e11933a..ba9049182142c7328c5c47ad7e7e62c1d6d3b222 100644 (file)
@@ -23,6 +23,10 @@ xendcresc = {
 cresc = \spanrequest \start "crescendo"
 endcresc = \spanrequest \stop "crescendo"
 
+% better name sustainstart/stop? 
+sustaindown = \spanrequest \start "sustain"
+sustainup = \spanrequest \stop "sustain"
+
 %crescpoco = \property Voice.crescendoText = "cresc. poco a poco"
 %decresc = \property Voice.crescendoText = "decr."
 %dim = \property Voice.crescendoText = "dim."