+2006-07-19 Erik Sandberg <mandolaerik@gmail.com>
+
+ * lily/*-performer.cc: Converted try_music to listen_*
+
+ * lily/grob-info.cc, lily/engraver.cc: represent the cause of grob
+ as a stream-event internally. Introduce event_cause (), deprecate
+ music_cause ().
+
+ * scm/define-music-types.scm: Removed BusyPlayingEvent
+
2006-07-19 Mats Bengtsson <mabe@drongo.s3.kth.se>
* Documentation/user/advanced-notation.itely (Font selection):
*/
-
#include "accidental-placement.hh"
-#include "skyline.hh"
+
+#include "accidental-interface.hh"
#include "music.hh"
-#include "pitch.hh"
-#include "warn.hh"
+#include "note-collision.hh"
#include "note-column.hh"
+#include "pitch.hh"
#include "pointer-group-interface.hh"
-#include "note-collision.hh"
-#include "accidental-interface.hh"
+#include "skyline.hh"
+#include "stream-event.hh"
+#include "warn.hh"
void
a->set_property ("X-offset", Grob::x_parent_positioning_proc);
SCM cause = a->get_parent (Y_AXIS)->get_property ("cause");
- Music *mcause = unsmob_music (cause);
+ Stream_event *mcause = unsmob_stream_event (cause);
if (!mcause)
{
- programming_error ("note head has no music cause");
+ programming_error ("note head has no event cause");
return;
}
void Arpeggio_engraver::listen_arpeggio (Stream_event *ev)
{
arpeggio_event_ = ev;
- ev->protect ();
}
void
if (arpeggio_event_)
{
arpeggio_ = make_item ("Arpeggio", arpeggio_event_->self_scm ());
- arpeggio_event_->unprotect ();
}
}
#include "translator-group.hh"
#include "context.hh"
-Audio_element_info::Audio_element_info (Audio_element *s, Music *r)
+Audio_element_info::Audio_element_info (Audio_element *s, Stream_event *r)
{
elem_ = s;
origin_trans_ = 0;
#include "audio-item.hh"
#include "audio-column.hh"
#include "global-context.hh"
+#include "stream-event.hh"
#include "warn.hh"
#include "music.hh"
TRANSLATOR_DECLARATIONS (Beam_performer);
protected:
- virtual bool try_music (Music *ev);
void start_translation_timestep ();
void process_music ();
void set_melisma (bool);
+ DECLARE_TRANSLATOR_LISTENER (beam);
private:
- Music *start_ev_;
- Music *now_stop_ev_;
+ Stream_event *start_ev_;
+ Stream_event *now_stop_ev_;
bool beam_;
};
now_stop_ev_ = 0;
}
-bool
-Beam_performer::try_music (Music *m)
+IMPLEMENT_TRANSLATOR_LISTENER (Beam_performer, beam);
+void
+Beam_performer::listen_beam (Stream_event *ev)
{
- if (m->is_mus_type ("beam-event"))
- {
- Direction d = to_dir (m->get_property ("span-direction"));
+ Direction d = to_dir (ev->get_property ("span-direction"));
- if (d == START)
- start_ev_ = m;
- else if (d == STOP)
- now_stop_ev_ = m;
- return true;
- }
- return false;
+ if (d == START)
+ start_ev_ = ev;
+ else if (d == STOP)
+ now_stop_ev_ = ev;
}
ADD_TRANSLATOR (Beam_performer, "", "",
ADD_TRANSLATOR (Cluster_spanner_engraver,
/* doc */ "Engraves a cluster using Spanner notation ",
/* create */ "ClusterSpanner ClusterSpannerBeacon",
- /* accept */ "cluster-note-event busy-playing-event",
+ /* accept */ "cluster-note-event",
/* read */ "",
/* write */ "");
return true;
}
- else if (m->is_mus_type ("busy-playing-event"))
- return note_events_.size () && is_first_;
return false;
}
"@code{Note_heads_engraver}. It plays some trickery to "
"break long notes and automatically tie them into the next measure.",
/* create */ "NoteHead Dots Tie",
- /* accept */ "busy-playing-event note-event",
+ /* accept */ "note-event",
/* read */ "middleCPosition measurePosition measureLength",
/* write */ "");
events_.push_back (m);
return true;
}
- else if (m->is_mus_type ("busy-playing-event"))
- return events_.size ();
return false;
}
ADD_TRANSLATOR (Drum_notes_engraver,
/* doc */ "Generate noteheads.",
/* create */ "NoteHead Dots Script",
- /* accept */ "note-event busy-playing-event",
+ /* accept */ "note-event",
/* read */ "drumStyleTable",
/* write */ "");
#include "audio-item.hh"
#include "audio-column.hh"
#include "global-context.hh"
-#include "warn.hh"
#include "pitch.hh"
-#include "music.hh"
+#include "stream-event.hh"
+#include "translator.icc"
+#include "warn.hh"
class Drum_note_performer : public Performer
{
TRANSLATOR_DECLARATIONS (Drum_note_performer);
protected:
- virtual bool try_music (Music *ev);
void stop_translation_timestep ();
void process_music ();
-
+ DECLARE_TRANSLATOR_LISTENER (note);
private:
- vector<Music*> note_evs_;
+ vector<Stream_event*> note_evs_;
vector<Audio_note*> notes_;
};
while (note_evs_.size ())
{
- Music *n = note_evs_.back ();
+ Stream_event *n = note_evs_.back ();
note_evs_.pop_back ();
SCM sym = n->get_property ("drum-type");
SCM defn = SCM_EOL;
if (Pitch *pit = unsmob_pitch (defn))
{
- Audio_note *p = new Audio_note (*pit, n->get_length (), 0);
+ Audio_note *p = new Audio_note (*pit, get_event_length (n), 0);
Audio_element_info info (p, n);
announce_element (info);
notes_.push_back (p);
note_evs_.clear ();
}
-bool
-Drum_note_performer::try_music (Music *ev)
+IMPLEMENT_TRANSLATOR_LISTENER (Drum_note_performer, note);
+void
+Drum_note_performer::listen_note (Stream_event *ev)
{
- if (ev->is_mus_type ("note-event"))
- {
- note_evs_.push_back (ev);
- return true;
- }
- else if (ev->is_mus_type ("busy-playing-event"))
- return note_evs_.size ();
-
- return false;
+ note_evs_.push_back (ev);
}
-#include "translator.icc"
-
ADD_TRANSLATOR (Drum_note_performer,
"Play drum notes.", "",
- "note-event busy-playing-event", "", "");
+ "note-event", "", "");
#include "performer.hh"
#include "audio-item.hh"
-#include "music.hh"
+#include "stream-event.hh"
#include "translator.icc"
/*
public:
TRANSLATOR_DECLARATIONS (Dynamic_performer);
protected:
- virtual bool try_music (Music *event);
void stop_translation_timestep ();
void process_music ();
+ DECLARE_TRANSLATOR_LISTENER (absolute_dynamic);
private:
- Music *script_event_;
+ Stream_event *script_event_;
Audio_dynamic *audio_;
};
}
}
-bool
-Dynamic_performer::try_music (Music *r)
+IMPLEMENT_TRANSLATOR_LISTENER (Dynamic_performer, absolute_dynamic);
+void
+Dynamic_performer::listen_absolute_dynamic (Stream_event *r)
{
if (!script_event_)
- {
- if (r->is_mus_type ("absolute-dynamic-event")) // fixme.
- {
- script_event_ = r;
- return true;
- }
- }
- return false;
+ script_event_ = r;
}
ADD_TRANSLATOR (Dynamic_performer,
#include <cctype>
using namespace std;
-#include "text-interface.hh"
+#include "font-interface.hh"
#include "grob.hh"
-#include "output-def.hh"
#include "music.hh"
+#include "output-def.hh"
#include "pitch.hh"
-#include "font-interface.hh"
#include "staff-symbol-referencer.hh"
#include "stem.hh"
+#include "stream-event.hh"
+#include "text-interface.hh"
/*
int log = Note_head::get_balltype (me);
SCM cause = me->get_property ("cause");
- SCM spitch = unsmob_music (cause)->get_property ("pitch");
+ SCM spitch = unsmob_stream_event (cause)->get_property ("pitch");
Pitch *pit = unsmob_pitch (spitch);
SCM idx = scm_from_int (pit->get_notename ());
#include "engraver.hh"
+#include "context.hh"
+#include "item.hh"
+#include "lilypond-key.hh"
#include "music.hh"
#include "score-engraver.hh"
-#include "warn.hh"
#include "spanner.hh"
-#include "item.hh"
-#include "context.hh"
-#include "lilypond-key.hh"
+#include "stream-event.hh"
+#include "warn.hh"
Engraver_group *
Engraver::get_daddy_engraver () const
}
/*
- CAUSE is the object (typically a Music object) that
+ CAUSE is the object (typically a Stream_event object) that
was the reason for making E.
*/
void
Engraver::announce_grob (Grob *e, SCM cause)
{
- if (unsmob_music (cause) || unsmob_grob (cause))
+ /* TODO: Remove Music code when it's no longer needed */
+ if (Music *m = unsmob_music (cause))
+ {
+ cause = m->to_event ()->unprotect ();
+ }
+ if (unsmob_stream_event (cause) || unsmob_grob (cause))
e->set_property ("cause", cause);
Grob_info i (this, e);
void
Engraver::announce_end_grob (Grob *e, SCM cause)
{
- if (unsmob_music (cause) || unsmob_grob (cause))
+ /* TODO: Remove Music code when it's no longer needed */
+ if (Music *m = unsmob_music (cause))
+ {
+ cause = m->to_event ()->unprotect ();
+ }
+ if (unsmob_stream_event (cause) || unsmob_grob (cause))
e->set_property ("cause", cause);
Grob_info i (this, e);
(c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
+#include "context.hh"
#include "grob-info.hh"
#include "grob.hh"
+#include "item.hh"
#include "music.hh"
-#include "translator-group.hh"
-#include "context.hh"
#include "spanner.hh"
-#include "item.hh"
+#include "stream-event.hh"
+#include "translator-group.hh"
Grob_info::Grob_info (Translator *t, Grob *g)
{
origin_trans_ = 0;
}
+/* ES TODO: Junk this when no more engravers use try_music */
Music *
Grob_info::music_cause () const
{
SCM cause = grob_->get_property ("cause");
- return unsmob_music (cause);
+
+ Music *ret = unsmob_music (cause);
+ if (ret)
+ return ret;
+ else
+ {
+ Stream_event *ev = unsmob_stream_event (cause);
+ if (!ev)
+ return 0;
+ return unsmob_music (ev->get_property ("music-cause"));
+ }
+}
+
+Stream_event *
+Grob_info::event_cause () const
+{
+ SCM cause = grob_->get_property ("cause");
+ return unsmob_stream_event (cause);
}
vector<Context*>
return dynamic_cast<Item *> (grob_);
}
+Stream_event *
+Grob_info::ultimate_event_cause () const
+{
+ SCM cause = grob_->self_scm ();
+ while (unsmob_grob (cause))
+ {
+ cause = unsmob_grob (cause)->get_property ("cause");
+ }
+ return unsmob_stream_event (cause);
+}
+
+/*
+ES TODO: Junk this when no more engraver uses try_music
+*/
Music *
Grob_info::ultimate_music_cause () const
{
cause = unsmob_grob (cause)->get_property ("cause");
}
- return unsmob_music (cause);
+ Music *ret = unsmob_music (cause);
+ if (ret)
+ return ret;
+ else
+ {
+ Stream_event *ev = unsmob_stream_event (cause);
+ return unsmob_music (ev->get_property ("music-cause"));
+ }
}
-
while (Grob *g = unsmob_grob (cause))
cause = g->get_property ("cause");
+ /* ES TODO: cause can't be Music*/
if (Music *m = unsmob_music (cause))
m->origin ()->warning (s);
else if (Stream_event *ev = unsmob_stream_event (cause))
s = _f ("programming error: %s", s);
+ /* ES TODO: cause can't be Music*/
if (Music *m = unsmob_music (cause))
m->origin ()->message (s);
else if (Stream_event *ev = unsmob_stream_event (cause))
{
public:
Audio_element *elem_;
- Music *event_;
+ Stream_event *event_;
Translator *origin_trans_;
vector<Context*> origin_contexts (Translator *) const;
- Audio_element_info (Audio_element *, Music *);
+ Audio_element_info (Audio_element *, Stream_event *);
Audio_element_info ();
};
Translator *origin_translator () const { return origin_trans_; }
Context *context () const;
+ Stream_event *event_cause () const;
Music *music_cause () const;
+ Stream_event *ultimate_event_cause () const;
Music *ultimate_music_cause () const;
vector<Context*> origin_contexts (Translator *) const;
Grob_info (Translator *, Grob *);
bool internal_is_music_type (SCM) const;
+ Stream_event *to_event () const;
+
DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM));
Pitch to_relative_octave (Pitch);
Pitch generic_to_relative_octave (Pitch);
void send_to_context (Context *c);
DECLARE_SCHEME_CALLBACK (duration_length_callback, (SCM));
-
+
protected:
virtual SCM copy_mutable_properties () const;
virtual void type_check_assignment (SCM, SCM) const;
Stream_event ();
Input *origin () const;
void set_spot (Input *i);
+ bool internal_in_event_class (SCM class_name);
DECLARE_SCHEME_CALLBACK (undump, (SCM));
DECLARE_SCHEME_CALLBACK (dump, (SCM));
Stream_event (Stream_event *ev);
};
+#define in_event_class(class_name) internal_in_event_class (ly_symbol2scm (class_name))
+
Stream_event *unsmob_stream_event (SCM);
DECLARE_TYPE_P (Stream_event);
void add_translator (Translator *trans);
Translator *get_translator (SCM s);
+Moment get_event_length (Stream_event *s);
DECLARE_UNSMOB (Translator, translator);
#endif // TRANSLATOR_HH
(c) 1997--2006 Jan Nieuwenhuizen <janneke@gnu.org>
*/
-#include "music-sequence.hh"
#include "audio-item.hh"
+#include "music-sequence.hh"
#include "performer.hh"
+#include "stream-event.hh"
#include "warn.hh"
+#include "translator.icc"
+
class Key_performer : public Performer
{
public:
~Key_performer ();
protected:
- virtual bool try_music (Music *ev);
void process_music ();
void stop_translation_timestep ();
+ DECLARE_TRANSLATOR_LISTENER (key_change);
private:
- Music *key_ev_;
+ Stream_event *key_ev_;
Audio_key *audio_;
};
}
}
-bool
-Key_performer::try_music (Music *ev)
+IMPLEMENT_TRANSLATOR_LISTENER (Key_performer, key_change);
+void
+Key_performer::listen_key_change (Stream_event *ev)
{
if (!key_ev_)
key_ev_ = ev;
-
- return true;
}
-#include "translator.icc"
-
ADD_TRANSLATOR (Key_performer,
"", "",
"key-change-event",
#include "audio-item.hh"
#include "performer.hh"
-#include "music.hh"
+#include "stream-event.hh"
+#include "translator.icc"
class Lyric_performer : public Performer
{
TRANSLATOR_DECLARATIONS (Lyric_performer);
protected:
- virtual bool try_music (Music *event);
void stop_translation_timestep ();
- void process_music ();
-
+ void process_music ();
+ DECLARE_TRANSLATOR_LISTENER (lyric);
private:
- vector<Music*> events_;
+ vector<Stream_event *> events_;
Audio_text *audio_;
};
events_.clear ();
}
-bool
-Lyric_performer::try_music (Music *event)
+IMPLEMENT_TRANSLATOR_LISTENER (Lyric_performer, lyric);
+void
+Lyric_performer::listen_lyric (Stream_event *event)
{
- if (event->is_mus_type ("lyric-event"))
- {
- events_.push_back (event);
- return true;
- }
- return false;
+ events_.push_back (event);
}
-#include "translator.icc"
-
ADD_TRANSLATOR (Lyric_performer, "", "", "lyric-event",
"", "");
return ip ? ip : &dummy_input_global;
}
-void
-Music::send_to_context (Context *c)
+/*
+ ES TODO: This method should probably be reworked or junked.
+*/
+Stream_event *
+Music::to_event () const
{
- /*
- TODO: This is a work-in-progress solution. Send the event so it
- can be read both by old-style translators and the new ones.
- */
- send_stream_event (c, "OldMusicEvent", origin (),
- ly_symbol2scm("music"), self_scm (), 0);
-
- /* UGH. This is a temp hack for Music->Stream_event transition */
+ /* UGH. Temp hack */
SCM orig_sym = get_property ("name");
char out[200];
string in = ly_symbol2string (orig_sym);
}
out[outpos] = 0;
SCM class_name = ly_symbol2scm (out);
-
+
Stream_event *e = new Stream_event (class_name, mutable_property_alist_);
- c->event_source ()->broadcast (e);
+ Moment length = get_length ();
+ if (length.to_bool ())
+ e->set_property ("length", length.smobbed_copy ());
+
+ /*
+ ES TODO: This is a temporary fix. Stream_events should not be
+ aware of music.
+ */
+ e->set_property ("music-cause", self_scm ());
+ return e;
+}
+
+void
+Music::send_to_context (Context *c)
+{
+ /*
+ TODO: This is a work-in-progress solution. Send the event so it
+ can be read both by old-style translators and the new ones.
+ */
+ send_stream_event (c, "OldMusicEvent", origin (),
+ ly_symbol2scm("music"), self_scm (), 0);
+
+ Stream_event *ev = to_event ();
+ c->event_source ()->broadcast (ev);
+ ev->unprotect ();
}
Music *
note_evs_.push_back (m);
return true;
}
- else if (m->is_mus_type ("busy-playing-event"))
- return note_evs_.size ();
return false;
}
"NoteHead "
"Dots",
/* accept */
- "note-event "
- "busy-playing-event",
+ "note-event",
/* read */ "middleCPosition",
/* write */ "");
#include "audio-item.hh"
#include "audio-column.hh"
#include "global-context.hh"
+#include "stream-event.hh"
#include "warn.hh"
-#include "music.hh"
+
+#include "translator.icc"
/**
Convert evs to audio notes.
TRANSLATOR_DECLARATIONS (Note_performer);
protected:
- virtual bool try_music (Music *ev);
-
void stop_translation_timestep ();
void process_music ();
+ DECLARE_TRANSLATOR_LISTENER (note);
private:
- vector<Music*> note_evs_;
+ vector<Stream_event*> note_evs_;
vector<Audio_note*> notes_;
};
while (note_evs_.size ())
{
- Music *n = note_evs_.back ();
+ Stream_event *n = note_evs_.back ();
note_evs_.pop_back ();
SCM pit = n->get_property ("pitch");
if (Pitch *pitp = unsmob_pitch (pit))
{
- Audio_note *p = new Audio_note (*pitp, n->get_length (), - transposing);
+ Audio_note *p = new Audio_note (*pitp, get_event_length (n), - transposing);
Audio_element_info info (p, n);
announce_element (info);
notes_.push_back (p);
note_evs_.clear ();
}
-bool
-Note_performer::try_music (Music *ev)
+IMPLEMENT_TRANSLATOR_LISTENER (Note_performer, note)
+void
+Note_performer::listen_note (Stream_event *ev)
{
- if (ev->is_mus_type ("note-event"))
- {
- note_evs_.push_back (ev);
- return true;
- }
- else if (ev->is_mus_type ("busy-playing-event"))
- return note_evs_.size ();
-
- return false;
+ note_evs_.push_back (ev);
}
-#include "translator.icc"
-
ADD_TRANSLATOR (Note_performer, "", "",
- "note-event "
- "busy-playing-event",
+ "note-event ",
"", "");
Note_performer::Note_performer ()
#include "audio-item.hh"
#include "international.hh"
-#include "music.hh"
+#include "stream-event.hh"
+#include "warn.hh"
+
+#include "translator.icc"
+
+#define SOSTENUTO 0
+#define SUSTAIN 1
+#define UNA_CORDA 2
+#define NUM_PEDAL_TYPES 3
/**
perform Piano pedals
{
struct Pedal_info
{
- char const *name_;
- Music *start_event_;
- Drul_array<Music *> event_drul_;
+ Stream_event *start_event_;
+ Drul_array<Stream_event *> event_drul_;
};
public:
TRANSLATOR_DECLARATIONS (Piano_pedal_performer);
- ~Piano_pedal_performer ();
protected:
virtual void initialize ();
- virtual bool try_music (Music *);
+ static const char *pedal_type_str (int t);
void process_music ();
void stop_translation_timestep ();
void start_translation_timestep ();
-
+ DECLARE_TRANSLATOR_LISTENER (sustain);
+ DECLARE_TRANSLATOR_LISTENER (una_corda);
+ DECLARE_TRANSLATOR_LISTENER (sostenuto);
private:
vector<Audio_piano_pedal*> audios_;
- Pedal_info *info_alist_;
+ Pedal_info info_alist_[NUM_PEDAL_TYPES];
};
Piano_pedal_performer::Piano_pedal_performer ()
{
- info_alist_ = 0;
}
-Piano_pedal_performer::~Piano_pedal_performer ()
+const char *
+Piano_pedal_performer::pedal_type_str (int t)
{
- delete[] info_alist_;
+ switch (t)
+ {
+ case SOSTENUTO:
+ return "Sostenuto";
+ case SUSTAIN:
+ return "Sustain";
+ case UNA_CORDA:
+ return "UnaCorda";
+ default:
+ programming_error ("Unknown pedal type");
+ return 0;
+ }
}
void
Piano_pedal_performer::initialize ()
{
- info_alist_ = new Pedal_info[4];
Pedal_info *p = info_alist_;
- char *names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 };
- char **np = names;
- do
+ for (int i = 0; i < NUM_PEDAL_TYPES; i++, p++)
{
- p->name_ = *np;
p->event_drul_[START] = 0;
p->event_drul_[STOP] = 0;
p->start_event_ = 0;
-
- p++;
}
- while (* (np++));
}
void
Piano_pedal_performer::process_music ()
{
- for (Pedal_info *p = info_alist_; p && p->name_; p++)
+ Pedal_info *p = info_alist_;
+ for (int i = 0; i < NUM_PEDAL_TYPES; i++, p++)
{
if (p->event_drul_[STOP])
{
if (!p->start_event_)
- p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", string (p->name_)));
+ p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", pedal_type_str (i)));
else
{
Audio_piano_pedal *a = new Audio_piano_pedal;
- a->type_string_ = string (p->name_);
+ a->type_string_ = string (pedal_type_str (i));
a->dir_ = STOP;
audios_.push_back (a);
Audio_element_info info(a, p->event_drul_[STOP]);
{
p->start_event_ = p->event_drul_[START];
Audio_piano_pedal *a = new Audio_piano_pedal;
- a->type_string_ = string (p->name_);
+ a->type_string_ = string (pedal_type_str (i));
a->dir_ = START;
audios_.push_back (a);
Audio_element_info info(a, p->event_drul_[START]);
void
Piano_pedal_performer::start_translation_timestep ()
{
- for (Pedal_info *p = info_alist_; p && p->name_; p++)
+ Pedal_info *p = info_alist_;
+ for (int i = 0; i < NUM_PEDAL_TYPES; i++, p++)
{
p->event_drul_[STOP] = 0;
p->event_drul_[START] = 0;
}
}
-bool
-Piano_pedal_performer::try_music (Music *r)
+IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_performer, sostenuto);
+void
+Piano_pedal_performer::listen_sostenuto (Stream_event *r)
{
- if (r->is_mus_type ("pedal-event"))
- {
- for (Pedal_info *p = info_alist_; p->name_; p++)
- {
- string nm = p->name_ + string ("Event");
- if (ly_is_equal (r->get_property ("name"),
- scm_str2symbol (nm.c_str ())))
- {
- Direction d = to_dir (r->get_property ("span-direction"));
- p->event_drul_[d] = r;
- return true;
- }
- }
- }
- return false;
+ Direction d = to_dir (r->get_property ("span-direction"));
+ info_alist_[SOSTENUTO].event_drul_[d] = r;
}
-#include "translator.icc"
+IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_performer, sustain);
+void
+Piano_pedal_performer::listen_sustain (Stream_event *r)
+{
+ Direction d = to_dir (r->get_property ("span-direction"));
+ info_alist_[SUSTAIN].event_drul_[d] = r;
+}
+
+IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_performer, una_corda);
+void
+Piano_pedal_performer::listen_una_corda (Stream_event *r)
+{
+ Direction d = to_dir (r->get_property ("span-direction"));
+ info_alist_[UNA_CORDA].event_drul_[d] = r;
+}
ADD_TRANSLATOR (Piano_pedal_performer, "", "",
"pedal-event",
#include "audio-item.hh"
#include "audio-column.hh"
#include "global-context.hh"
+#include "stream-event.hh"
#include "warn.hh"
-#include "music.hh"
+
+#include "translator.icc"
/*
this is C&P from beam_performer.
TRANSLATOR_DECLARATIONS (Slur_performer);
protected:
- virtual bool try_music (Music *ev);
void start_translation_timestep ();
void process_music ();
void set_melisma (bool);
+
+ DECLARE_TRANSLATOR_LISTENER (slur);
private:
- Music *start_ev_;
- Music *now_stop_ev_;
+ Stream_event *start_ev_;
+ Stream_event *now_stop_ev_;
bool slur_;
};
now_stop_ev_ = 0;
}
-bool
-Slur_performer::try_music (Music *m)
+IMPLEMENT_TRANSLATOR_LISTENER (Slur_performer, slur);
+void
+Slur_performer::listen_slur (Stream_event *ev)
{
- if (m->is_mus_type ("slur-event"))
- {
- Direction d = to_dir (m->get_property ("span-direction"));
+ Direction d = to_dir (ev->get_property ("span-direction"));
- if (d == START)
- start_ev_ = m;
- else if (d == STOP)
- now_stop_ev_ = m;
- return true;
- }
- return false;
+ if (d == START)
+ start_ev_ = ev;
+ else if (d == STOP)
+ now_stop_ev_ = ev;
}
-#include "translator.icc"
-
ADD_TRANSLATOR (Slur_performer,
"", "",
"slur-event",
"", "");
-
#include "audio-item.hh"
#include "international.hh"
-#include "music.hh"
+#include "stream-event.hh"
+
+#include "translator.icc"
/*
TODO: fold this into 1 engraver: \< and \> should also stop when
TRANSLATOR_DECLARATIONS (Span_dynamic_performer);
protected:
- virtual bool try_music (Music *);
virtual void acknowledge_audio_element (Audio_element_info);
void process_music ();
void stop_translation_timestep ();
+ DECLARE_TRANSLATOR_LISTENER (decrescendo);
+ DECLARE_TRANSLATOR_LISTENER (crescendo);
private:
Audio_dynamic *audio_;
Real last_volume_;
- Music *span_start_event_;
- Drul_array<Music *> span_events_;
+ Stream_event *span_start_event_;
+ Drul_array<Stream_event *> span_events_;
vector<Audio_dynamic_tuple> dynamic_tuples_;
vector<Audio_dynamic_tuple> finished_dynamic_tuples_;
Direction dir_;
if (span_events_[START])
{
- dir_ = (span_events_[START]->is_mus_type ("crescendo-event"))
+ dir_ = (span_events_[START]->in_event_class ("crescendo-event"))
? RIGHT : LEFT;
span_start_event_ = span_events_[START];
span_events_[START] = 0;
}
-bool
-Span_dynamic_performer::try_music (Music *r)
+IMPLEMENT_TRANSLATOR_LISTENER (Span_dynamic_performer, decrescendo);
+void
+Span_dynamic_performer::listen_decrescendo (Stream_event *r)
{
- if (r->is_mus_type ("crescendo-event")
- || r->is_mus_type ("decrescendo-event"))
- {
- Direction d = to_dir (r->get_property ("span-direction"));
- span_events_[d] = r;
- return true;
- }
- return false;
+ Direction d = to_dir (r->get_property ("span-direction"));
+ span_events_[d] = r;
+}
+
+IMPLEMENT_TRANSLATOR_LISTENER (Span_dynamic_performer, crescendo);
+void
+Span_dynamic_performer::listen_crescendo (Stream_event *r)
+{
+ Direction d = to_dir (r->get_property ("span-direction"));
+ span_events_[d] = r;
}
-#include "translator.icc"
ADD_TRANSLATOR (Span_dynamic_performer,
"", "",
return e->unprotect ();
}
-LY_DEFINE (ly_stream_event_property, "ly:stream-event-property",
+LY_DEFINE (ly_event_property, "ly:event-property",
2, 0, 0, (SCM sev, SCM sym),
"Get the property @var{sym} of stream event @var{mus}.\n"
"If @var{sym} is undefined, return @code{' ()}.\n")
#include "input.hh"
#include "input-smob.hh"
+/* TODO: Rename Stream_event -> Event */
+
Stream_event::Stream_event ()
: Prob (ly_symbol2scm ("Stream_event"), SCM_EOL)
{
return i ? i : &dummy_input_global;
}
-void Stream_event::set_spot (Input *i)
+void
+Stream_event::set_spot (Input *i)
{
set_property ("origin", make_input (*i));
}
+bool
+Stream_event::internal_in_event_class (SCM class_name)
+{
+ SCM cl = get_property ("class");
+ cl = scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), cl);
+ return scm_c_memq (class_name, cl) != SCM_BOOL_F;
+}
+
IMPLEMENT_TYPE_P (Stream_event, "ly:stream-event?");
MAKE_SCHEME_CALLBACK (Stream_event, undump, 1);
bool
Swallow_performer::try_music (Music *m)
{
- if (m->is_mus_type ("busy-playing-event")
- || m->is_mus_type ("melisma-playing-event"))
+ if (m->is_mus_type ("melisma-playing-event"))
return false;
else
return true;
tabstring_events_.push_back (m);
return true;
}
- else if (m->is_mus_type ("busy-playing-event"))
- return note_events_.size ();
return false;
}
ADD_TRANSLATOR (Tab_note_heads_engraver,
/* doc */ "Generate one or more tablature noteheads from Music of type NoteEvent.",
/* create */ "TabNoteHead Dots",
- /* accept */ "note-event string-number-event busy-playing-event",
+ /* accept */ "note-event string-number-event",
/* read */ "middleCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost",
/* write */ "");
#include "performer.hh"
#include "audio-item.hh"
-#include "music.hh"
#include "duration.hh"
+#include "stream-event.hh"
+
+#include "translator.icc"
class Tempo_performer : public Performer
{
protected:
- virtual bool try_music (Music *event);
void stop_translation_timestep ();
void process_music ();
-
+ DECLARE_TRANSLATOR_LISTENER (metronome_change);
private:
- Music *tempo_event_;
+ Stream_event *tempo_event_;
Audio_tempo *audio_;
};
}
}
-bool
-Tempo_performer::try_music (Music *event)
+IMPLEMENT_TRANSLATOR_LISTENER (Tempo_performer, metronome_change);
+void
+Tempo_performer::listen_metronome_change (Stream_event *event)
{
- if (tempo_event_)
- return false;
-
tempo_event_ = event;
- return true;
}
-#include "translator.icc"
-
ADD_TRANSLATOR (Tempo_performer, "", "",
"metronome-change-event",
"", "");
#include "protected-scm.hh"
#include "spanner.hh"
#include "staff-symbol-referencer.hh"
+#include "stream-event.hh"
#include "tie-column.hh"
#include "tie.hh"
#include "warn.hh"
for (vsize i = heads_to_tie_.size (); i--;)
{
Grob *th = heads_to_tie_[i].head_;
- Music *right_mus = unsmob_music (h->get_property ("cause"));
- Music *left_mus = unsmob_music (th->get_property ("cause"));
+ Stream_event *right_ev = unsmob_stream_event (h->get_property ("cause"));
+ Stream_event *left_ev = unsmob_stream_event (th->get_property ("cause"));
/*
maybe should check positions too.
*/
- if (right_mus && left_mus
- && ly_is_equal (right_mus->get_property ("pitch"),
- left_mus->get_property ("pitch")))
+ if (right_ev && left_ev
+ && ly_is_equal (right_ev->get_property ("pitch"),
+ left_ev->get_property ("pitch")))
{
Grob *p = new Spanner (heads_to_tie_[i].tie_definition_,
context ()->get_grob_key ("Tie"));
for (vsize i = 0; i < now_heads_.size (); i++)
{
Grob *head = now_heads_[i];
- Music *left_mus = unsmob_music (head->get_property ("cause"));
- if (left_mus)
+ Stream_event *left_ev = unsmob_stream_event (head->get_property ("cause"));
+ if (left_ev)
{
Head_event_tuple event_tup;
Moment end = now_mom ();
if (end.grace_part_)
{
- end.grace_part_ += left_mus->get_length ().main_part_;
+ end.grace_part_ += get_event_length (left_ev).main_part_;
}
else
{
- end += left_mus->get_length ();
+ end += get_event_length (left_ev);
}
event_tup.end_moment_ = end;
#include "performer.hh"
-#include "music.hh"
-#include "context.hh"
#include "audio-item.hh"
+#include "context.hh"
#include "pqueue.hh"
+#include "stream-event.hh"
+#include "translator.icc"
class Tie_performer : public Performer
{
- Music *event_;
- Music *last_event_;
+ Stream_event *event_;
+ Stream_event *last_event_;
vector<Audio_element_info> now_heads_;
vector<Audio_element_info> heads_to_tie_;
void stop_translation_timestep ();
void start_translation_timestep ();
virtual void acknowledge_audio_element (Audio_element_info);
- virtual bool try_music (Music *);
void process_music ();
+ DECLARE_TRANSLATOR_LISTENER (tie);
public:
TRANSLATOR_DECLARATIONS (Tie_performer);
};
ties_created_ = false;
}
-bool
-Tie_performer::try_music (Music *mus)
+IMPLEMENT_TRANSLATOR_LISTENER (Tie_performer, tie);
+void
+Tie_performer::listen_tie (Stream_event *ev)
{
- if (mus->is_mus_type ("tie-event"))
- event_ = mus;
-
- return true;
+ event_ = ev;
}
void
now_heads_.push_back (inf);
for (vsize i = heads_to_tie_.size (); i--;)
{
- Music *right_mus = inf.event_;
+ Stream_event *right_mus = inf.event_;
Audio_note *th = dynamic_cast<Audio_note *> (heads_to_tie_[i].elem_);
- Music *left_mus = heads_to_tie_[i].event_;
+ Stream_event *left_mus = heads_to_tie_[i].event_;
if (right_mus && left_mus
&& ly_is_equal (right_mus->get_property ("pitch"),
now_heads_.clear ();
}
-#include "translator.icc"
-
ADD_TRANSLATOR (Tie_performer,
/* doc */ "Generate ties between noteheads of equal pitch.",
/* create */ "",
return 0;
}
+Moment
+get_event_length (Stream_event *e)
+{
+ Moment *m = unsmob_moment (e->get_property ("length"));
+ if (m)
+ return *m;
+ else
+ return Moment (0);
+}
+
ADD_TRANSLATOR (Translator,
"Base class. Unused",
"",
((RemoveContext ChangeParent Override Revert UnsetProperty
SetProperty MusicEvent OldMusicEvent CreateContext Prepare
OneTimeStep Finish) . StreamEvent)
- ((arpeggio-event) . MusicEvent)
+ ((arpeggio-event
+ beam-event note-event absolute-dynamic-event
+ key-change-event lyric-event pedal-event slur-event tie-event
+ metronome-change-event span-dynamic-event)
+ . MusicEvent)
+ ((decrescendo-event crescendo-event) . span-dynamic-event)
+ ((sostenuto-event sustain-event una-corda-event) . pedal-event)
((Announcement) . '())
((AnnounceNewContext) . Announcement)
))
(types . (general-music event breathing-event))
))
- (BusyPlayingEvent
- . (
- (description . "Used internally to signal beginning and ending of notes.")
-
- (types . (general-music event busy-playing-event))
- ))
(ContextChange
. (
(description . "Change staffs in Piano staff.
(define location-callback spawn-editor)
(define (get-location grob)
- (and-let* ((p? (procedure? point-and-click))
+ (and-let* ((p (procedure? point-and-click))
(g grob)
(cause (ly:grob-property grob 'cause))
- (music-origin (if (ly:music? cause)
- (ly:music-property cause 'origin)
- ;; How come #<unspecied> [and '()]
+ (music-origin (if (ly:event? cause)
+ (ly:event-property cause 'origin)
+ ;; How come #<unspecified> [and '()]
;; are #t? :-(
#f)))
(if (ly:input-location? music-origin)
(define-public (tuplet-number::calc-denominator-text grob)
(let*
- ((mus (ly:grob-property grob 'cause)))
+ ((ev (ly:grob-property grob 'cause)))
- (number->string (ly:music-property mus 'denominator))))
+ (number->string (ly:event-property ev 'denominator))))
(define-public (tuplet-number::calc-fraction-text grob)
(let*
- ((mus (ly:grob-property grob 'cause)))
+ ((ev (ly:grob-property grob 'cause)))
(format "~a:~a"
- (ly:music-property mus 'denominator)
- (ly:music-property mus 'numerator))))
+ (ly:event-property ev 'denominator)
+ (ly:event-property ev 'numerator))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Color
(define (grob-cause offset grob)
(let* ((cause (ly:grob-property grob 'cause))
- (music-origin (if (ly:music? cause)
- (ly:music-property cause 'origin))))
+ (music-origin (if (ly:stream-event? cause)
+ (ly:event-property cause 'origin))))
(if (not (ly:input-location? music-origin))
""
(let* ((location (ly:input-file-line-char-column music-origin))
breapth width depth height blot-diameter
))
-(define (music-cause grob)
+(define (event-cause grob)
(let*
((cause (ly:grob-property grob 'cause)))
(cond
- ((ly:music? cause) cause)
+ ((ly:stream-event? cause) cause)
; ((ly:grob? cause) (music-cause cause))
(else
#f))))
(define-public (grob-cause offset grob)
(let*
- ((cause (music-cause grob))
- (tag (if (and cause (integer? (ly:music-property cause 'input-tag)))
- (ly:music-property cause 'input-tag)
+ ((cause (event-cause grob))
+ (tag (if (and cause (integer? (ly:event-property cause 'input-tag)))
+ (ly:event-property cause 'input-tag)
-1))
(name (cdr (assoc 'name (ly:grob-property grob 'meta))))
)
(if (procedure? point-and-click)
(let* ((cause (ly:grob-property grob 'cause))
- (music-origin (if (ly:music? cause)
- (ly:music-property cause 'origin)))
+ (music-origin (if (ly:stream-event? cause)
+ (ly:event-property cause 'origin)))
(location (if (ly:input-location? music-origin)
(ly:input-file-line-column music-origin))))
(if (pair? location)
rest))
expr))
- (define (music-cause grob)
+ (define (event-cause grob)
(let*
((cause (ly:grob-property grob 'cause)))
(cond
- ((ly:music? cause) cause)
- ((ly:grob? cause) (music-cause cause))
+ ((ly:stream-event? cause) cause)
+ ((ly:grob? cause) (event-cause cause))
(else #f))))
(define (pythonic-string expr)
((grob (car expr))
(rest (cdr expr))
(collected '())
- (cause (music-cause grob))
- (input (if (ly:music? cause) (ly:music-property cause 'origin) #f))
+ (cause (event-cause grob))
+ (input (if (ly:stream-event? cause) (ly:event-property cause 'origin) #f))
(location (if (ly:input-location? input) (ly:input-file-line-char-column input) '()))
(x-ext (ly:grob-extent grob system-grob X))