music-duration-compress): new functions.
* lily/ : Remove Note_req, Rest_req, Busy_playing_req. Changes
throughout. Warning doesn't work yet.
* lily/translator-group.cc (try_music_on_nongroup_children):
new implementation: store candidate acceptors in a hashTable.
+2002-09-26 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ * lily/musical-request.cc (music-duration-length,
+ music-duration-compress): new functions.
+
+ * lily/ : Remove Note_req, Rest_req, Busy_playing_req. Changes
+ throughout. Warning doesn't work yet.
+
+ * lily/translator-group.cc (try_music_on_nongroup_children):
+ new implementation: store candidate acceptors in a hashTable.
+
2002-09-25 Han-Wen Nienhuys <hanwen@cs.uu.nl>
* scm/music-types.scm (music-descriptions): change name to
struct Accidental_entry {
bool done_;
- Note_req * melodic_;
+ Music * melodic_;
Grob * accidental_;
Translator_group *origin_;
Grob* head_;
*/
static int
-number_accidentals (SCM sig, Note_req * note, Pitch *pitch, SCM curbarnum, SCM lazyness,
+number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazyness,
bool ignore_octave_b)
{
int n = pitch->notename_;
}
static int
-number_accidentals (Note_req * note, Pitch *pitch, Translator_group * origin,
+number_accidentals (Music * note, Pitch *pitch, Translator_group * origin,
SCM accidentals, SCM curbarnum)
{
int number = 0;
continue;
accidentals_[i].done_ = true;
Grob * support = accidentals_[i].head_;
- Note_req * note = accidentals_[i].melodic_;
+ Music * note = accidentals_[i].melodic_;
Translator_group * origin = accidentals_[i].origin_;
Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch"));
void
Accidental_engraver::acknowledge_grob (Grob_info info)
{
- Note_req * note = dynamic_cast <Note_req *> (info.music_cause ());
+ Music * note = info.music_cause ();
- if (note && Rhythmic_head::has_interface (info.grob_))
+ if (note
+ && note->is_mus_type("note-event")
+ && Rhythmic_head::has_interface (info.grob_))
{
Accidental_entry entry ;
entry.head_ = info.grob_;
{
if (Note_head::has_interface (info.grob_))
{
- Note_req *nr = dynamic_cast<Note_req*> (info.music_cause ());
- if (nr)
+ Music *nr = info.music_cause ();
+ if (nr && nr->is_mus_type ("note-event"))
{
Pitch pitch = *unsmob_pitch (nr->get_mus_property ("pitch"));
if (Pitch::compare (pitch_min, pitch_max) > 0) // already init'd?
if (Stem::has_interface (info.grob_))
{
Item* stem = dynamic_cast<Item *> (info.grob_);
-
- Rhythmic_req *rhythmic_req = dynamic_cast <Rhythmic_req *> (info.music_cause ());
- if (!rhythmic_req)
+ Music* m = info.music_cause ();
+ if (!m->is_mus_type ("rhythmic-event"))
{
programming_error ("Stem must have rhythmic structure");
return;
return ;
}
- int durlog = unsmob_duration (rhythmic_req->get_mus_property ("duration"))->duration_log ();
+ int durlog = unsmob_duration (m->get_mus_property ("duration"))->duration_log ();
if (durlog <= 2)
{
return ;
- Moment dur = unsmob_duration (rhythmic_req->get_mus_property ("duration"))->length_mom ();
+ Moment dur = unsmob_duration (m->get_mus_property ("duration"))->length_mom ();
/* FIXME:
This comment has been here since long:
durlog - 2);
stems_->push (stem);
last_add_mom_ = now;
- extend_mom_ = (extend_mom_ >? now) + rhythmic_req->length_mom ();
+ extend_mom_ = (extend_mom_ >? now) + m->length_mom ();
}
}
{
SCM muses = iter->get_pending_events (m);
for (SCM s = muses; gh_pair_p (s); s=ly_cdr (s))
- if (Note_req* nr = dynamic_cast<Note_req*> (unsmob_music (ly_car (s))))
- {
- ps.push (*unsmob_pitch (nr->get_mus_property ("pitch")));
- }
-
+ {
+ Music * m = unsmob_music (ly_car (s));
+ if (m && m->is_mus_type ("note-event"))
+ {
+ ps.push (*unsmob_pitch (m->get_mus_property ("pitch")));
+ }
+ }
+
if (ps.size ())
break;
are at grace points in time.
",
/* creats*/ "Beam",
-/* accepts */ "general-music",
+/* accepts */ "beam-event abort-event",
/* acks */ "stem-interface rest-interface",
/* reads */ "beamMelismaBusy beatLength subdivideBeams",
/* write */ "");
virtual bool try_music (Music *);
private:
- void add_note (Note_req *);
+ void add_note (Music *);
Item* chord_name_;
}
void
-Chord_name_engraver::add_note (Note_req* n)
+Chord_name_engraver::add_note (Music * n)
{
SCM pitches = ly_car (chord_);
SCM modifiers = ly_cdr (chord_);
bool
Chord_name_engraver::try_music (Music* m)
{
- if (Note_req* n = dynamic_cast<Note_req*> (m))
+ /*
+ hmm. Should check?
+ */
+ if (m->is_mus_type ("note-event"))
{
- add_note (n);
+ add_note (m);
return true;
}
return false;
}
ENTER_DESCRIPTION(Chord_name_engraver,
-/* descr */ "Catch Note_req's, Tonic_reqs, Inversion_reqs, Bass_req
+/* descr */ "Catch note-events, Tonic_reqs, Inversion_reqs, Bass_req
and generate the appropriate chordname.",
/* creats*/ "ChordName",
-/* accepts */ "general-music",
+/* accepts */ "note-event busy-playing-event",
/* acks */ "",
/* reads */ "chordChanges",
/* write */ "");
get_mus_property ("label")) == SCM_BOOL_T;
}
-ADD_MUSIC(Bass_figure_req);
ADD_MUSIC (Arpeggio_req);
ADD_MUSIC (Articulation_req);
ADD_MUSIC (Break_req);
ADD_MUSIC (Breathing_sign_req);
-ADD_MUSIC (Busy_playing_req);
ADD_MUSIC (Extender_req);
ADD_MUSIC (Glissando_req);
ADD_MUSIC (Hyphen_req);
ADD_MUSIC (Mark_req);
ADD_MUSIC (Melisma_playing_req);
ADD_MUSIC (Melisma_req);
-ADD_MUSIC (Melodic_req);
-ADD_MUSIC (Note_req);
ADD_MUSIC (Porrectus_req);
-ADD_MUSIC (Rest_req);
ADD_MUSIC (Rhythmic_req);
ADD_MUSIC (Script_req);
ADD_MUSIC (Skip_req);
ADD_MUSIC (Span_req);
ADD_MUSIC (Tempo_req);
ADD_MUSIC (Text_script_req);
-ADD_MUSIC (Tie_req);
ADD_MUSIC (Tremolo_req);
bool
Completion_heads_engraver::try_music (Music *m)
{
- if (Note_req * n =dynamic_cast <Note_req *> (m))
+ if (m->is_mus_type ("note-event"))
{
- note_reqs_.push (n);
+ note_reqs_.push (m);
first_b_ = true;
Moment musiclen = m->length_mom ();
return true;
}
- else if (dynamic_cast<Busy_playing_req*> (m))
+ else if (m->is_mus_type ("busy-playing-event"))
{
return note_reqs_.size ();
}
Item *item = dynamic_cast <Item *> (info.grob_);
if (item)
{
+ Music * m = info.music_cause();
if (Bar_line::has_interface (info.grob_))
custos_permitted = true;
- else if (Note_head::has_interface (info.grob_))
+ else if (Note_head::has_interface (info.grob_)
+ && m
+ && m->is_mus_type ("note-event"))
{
/*
don't look at the staff-position, since we can't be sure
whether Clef_engraver already applied a vertical shift.
*/
- Note_req * nr = dynamic_cast<Note_req*> (info.music_cause ());
- if (nr)
- pitches_.push (*unsmob_pitch (nr->get_mus_property ("pitch")));
+ pitches_.push (*unsmob_pitch (m->get_mus_property ("pitch")));
}
}
}
*/
SCM find_acknowledge_engravers (SCM gravlist, SCM meta);
+SCM find_accept_engravers (SCM gravlist, SCM music_descr);
+
void
Engraver_group_engraver::acknowledge_grobs ()
{
void
Engraver_group_engraver::initialize ()
{
- SCM tab = scm_make_vector (gh_int2scm (61), SCM_BOOL_F); // magic ->
+ /*
+ docme: why bool_f.
+
+ */
+ SCM tab = scm_make_vector (gh_int2scm (61), SCM_BOOL_F);
set_property ("acknowledgeHashTable", tab);
Translator_group::initialize ();
}
+
SCM
find_acknowledge_engravers (SCM gravlist, SCM meta_alist)
{
return l;
}
+
+
TRANSLATOR_DECLARATIONS(Figured_bass_engraver);
protected:
- Link_array<Bass_figure_req> figures_;
- Rest_req * rest_req_;
+ Link_array<Music> figures_;
+ Music * rest_req_;
Grob * figure_;
bool
Figured_bass_engraver::try_music (Music*m)
{
- if (Bass_figure_req* bfr = dynamic_cast<Bass_figure_req*> (m))
+ if (m->is_mus_type ("bass-figure-event"))
{
- figures_.push (bfr);
+ figures_.push (m);
return true;
}
- else if (Rest_req * r = dynamic_cast<Rest_req*> (m))
+ else if (m->is_mus_type ("rest-event"))
{
- rest_req_ = r;
+ rest_req_ = m;
return true;
}
return false;
end_ = 0;
}
-Grob_pitch_tuple::Grob_pitch_tuple (Grob *h, Melodic_req*m, Moment mom)
+Grob_pitch_tuple::Grob_pitch_tuple (Grob *h, Music *m, Moment mom)
{
head_ = h;
pitch_ = *unsmob_pitch (m->get_mus_property ("pitch"));
Moment end_;
Grob_pitch_tuple ();
- Grob_pitch_tuple (Grob*, Melodic_req*, Moment);
+ Grob_pitch_tuple (Grob*, Music*, Moment);
static int pitch_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &);
static int time_compare (Grob_pitch_tuple const &, Grob_pitch_tuple const &);
};
class Musical_req;
class My_lily_lexer;
class Note_performer;
-class Note_req;
class Output_property;
class Paper_column;
class Paper_def;
static void _ ## type ## _adder () {\
add_music_ctor (#type, & _ ## type ## _ctor);\
}\
-ADD_GLOBAL_CTOR (_ ## type ## _adder);
+ADD_SCM_INIT_FUNC( _ ## type ## _adder_prefix, _ ## type ## _adder);
void add_music_ctor (String, Music* (*) ());
Music*make_music (String);
#define get_mus_property(x) internal_get_mus_property(ly_symbol2scm(x))
#define set_mus_property(x,y) internal_set_mus_property(ly_symbol2scm (x), y)
+#define is_mus_type(x) internal_is_music_type(ly_symbol2scm (x))
/** Music is anything that has duration and supports both time compression and
transposition.
SCM internal_get_mus_property (SCM) const;
void internal_set_mus_property (SCM , SCM val);
- void add_music_type (SCM);
- bool is_music_type (SCM) const;
+ SCM get_property_alist (bool mut) const;
+ bool internal_is_music_type (SCM) const;
virtual Pitch to_relative_octave (Pitch);
*/
class Rhythmic_req : public virtual Request {
public:
- bool do_equal_b (Request const*) const;
void compress (Moment);
virtual Moment length_mom () const;
static int compare (Rhythmic_req const&,Rhythmic_req const&);
struct Chord_tremolo_notify_req : public Request
{
-
Rational factor_;
VIRTUAL_COPY_CONS(Chord_tremolo_notify_req);
Chord_tremolo_notify_req();
String get_articulation_string ();
protected:
virtual bool do_equal_b (Request const*) const;
-
VIRTUAL_COPY_CONS (Music);
};
VIRTUAL_COPY_CONS (Music);
};
-/*
- Put a note of specified type, height, and with accidental on the staff.
- /// force/supress printing of accidental.
- bool forceacc_b_;
- /// Cautionary, i.e. parenthesized accidental.
- bool cautionary_b_;
-
- */
-class Note_req : public Rhythmic_req, virtual public Melodic_req {
-public:
-
- Note_req ();
-protected:
-
- bool do_equal_b (Request const*) const;
- VIRTUAL_COPY_CONS (Music);
-};
-
/**
Put a rest on the staff. Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
*/
VIRTUAL_COPY_CONS (Music);
};
-/** is anyone playing a note?
- Used for communication between Music & Lyrics
- */
-class Busy_playing_req : public Request
-{
-public:
- VIRTUAL_COPY_CONS (Music);
-};
-
/**
VIRTUAL_COPY_CONS (Music);
};
-class Bass_figure_req: public Rhythmic_req
-{
-public:
- VIRTUAL_COPY_CONS(Music);
-};
#endif // MUSICALREQUESTS_HH
dirinfo (stderr);
ly_init_guile ();
+ call_constructors ();
progress_indication ("\n");
- call_constructors ();
all_fonts_global = new All_font_metrics (global_path.string ());
init_scheme_code_string += ")";
Grob_info info = primitives_[i];
int duration_log =
Note_head::get_balltype (dynamic_cast<Item*> (info.grob_));
- Note_req *nr = dynamic_cast<Note_req*> (info.music_cause ());
- if (!nr)
+
+ Music * nr = info.music_cause ();
+
+
+ /*
+
+ ugh. why not simply check for pitch?
+ */
+ if (!nr->is_mus_type ("note-event"))
{
info.music_cause ()->origin ()->warning (_f ("can not determine pitch of ligature primitive -> skipping"));
i++;
void set_delta_pitch (Item *primitive, Grob_info info1, Grob_info info2)
{
- Note_req *nr1 = dynamic_cast<Note_req*> (info1.music_cause ());
- Note_req *nr2 = dynamic_cast<Note_req*> (info2.music_cause ());
- Pitch pitch1 = *unsmob_pitch (nr1->get_mus_property ("pitch"));
- Pitch pitch2 = *unsmob_pitch (nr2->get_mus_property ("pitch"));
+ Pitch pitch1 = *unsmob_pitch (info1.music_cause ()->get_mus_property ("pitch"));
+ Pitch pitch2 = *unsmob_pitch (info2.music_cause ()->get_mus_property ("pitch"));
int delta_pitch = (pitch2.steps () - pitch1.steps ());
primitive->set_grob_property ("delta-pitch", gh_int2scm (delta_pitch));
}
for (int i = 0; i < primitives_.size (); i++)
{
Grob_info info = primitives_[i];
- Note_req *nr = dynamic_cast<Note_req*> (info.music_cause ());
- Pitch pitch = *unsmob_pitch (nr->get_mus_property ("pitch"));
+ Pitch pitch = *unsmob_pitch (info.music_cause ()->get_mus_property ("pitch"));
if (i > 0)
{
Item *primitive = dynamic_cast<Item*> (info.grob_);
-void
-Music::add_music_type (SCM sym)
-{
- assert (gh_symbol_p (sym));
- SCM types= get_mus_property ("types");
- types = scm_cons (sym, types);
- set_mus_property ("types", types);
-}
bool
-Music::is_music_type (SCM k)const
+Music::internal_is_music_type (SCM k)const
{
SCM ifs = get_mus_property ("types");
smobify_self ();
mutable_property_alist_ = ly_deep_mus_copy (m.mutable_property_alist_);
set_spot (*m.origin ());
-
- add_music_type (ly_symbol2scm ("general-music"));
}
-
-
Music::Music ()
{
self_scm_ = SCM_EOL;
smobify_self ();
}
+SCM
+Music::get_property_alist (bool m) const
+{
+ return (m) ? mutable_property_alist_ : immutable_property_alist_;
+}
SCM
Music::mark_smob (SCM m)
}
void
-Music::compress (Moment)
+Music::compress (Moment f)
{
+ SCM l = get_mus_property ("compress-procedure");
+ if (gh_procedure_p (l))
+ {
+ SCM res = gh_call2 (l, self_scm (), f.smobbed_copy());
+ }
}
-
Moment
Music::length_mom () const
{
{
}
-bool
-Melodic_req::do_equal_b (Request const* r) const
+LY_DEFINE(music_duration_length, "music-duration-length", 1, 0,0,
+ (SCM mus),
+ "Extract the duration field from @var{mus}, and return the length.")
{
- Melodic_req const* m= dynamic_cast <Melodic_req const*> (r);
- return m; // && !compare (*m, *this);
+ Music* m = unsmob_music(mus);
+ SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "Music");
+
+ Duration *d = unsmob_duration (m->get_mus_property ("duration"));
+
+ Moment l ;
+
+ if (d)
+ {
+ l = d->length_mom ();
+ }
+ else
+ programming_error("Rhythmic_req has no duration");
+ return l.smobbed_copy();
+
}
-bool
-Rhythmic_req::do_equal_b (Request const* r) const
-{
- Rhythmic_req const* rh = dynamic_cast <Rhythmic_req const*> (r);
- return rh; // ; && !compare (*this, *rh);
+LY_DEFINE(music_duration_compress, "music-duration-compress", 2, 0,0,
+ (SCM mus, SCM factor),
+ "Extract the duration field from @var{mus}, and compress it.")
+{
+ Music* m = unsmob_music(mus);
+ Moment * f = unsmob_moment (factor);
+ SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "Music");
+ SCM_ASSERT_TYPE(f, factor, SCM_ARG2, __FUNCTION__, "Moment");
+
+ Duration *d = unsmob_duration (m->get_mus_property ("duration"));
+ if (d)
+ m->set_mus_property ("duration", d->compressed (f->main_part_).smobbed_copy());
+ return SCM_UNSPECIFIED;
}
+
Moment
Rhythmic_req::length_mom () const
{
set_mus_property ("duration", d ->compressed (m.main_part_).smobbed_copy ());
}
-bool
-Note_req::do_equal_b (Request const* r) const
-{
- Note_req const* n = dynamic_cast<Note_req const*> (r);
- return n&& Rhythmic_req::do_equal_b (n) && Melodic_req::do_equal_b (n);
-}
-
-
-Note_req::Note_req ()
-{
-}
bool
int number_accidentals_;
int number_cautionaries_;
bool different_;
- Note_req * melodic_;
+ Music * melodic_;
Grob * accidental_;
Translator_group *origin_;
Grob* head_;
*/
static int
-number_accidentals (SCM sig, Note_req * note, Pitch *pitch, SCM curbarnum, SCM lazyness,
+number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazyness,
bool ignore_octave_b)
{
int n = pitch->notename_;
}
static int
-number_accidentals (Note_req * note, Pitch *pitch, Translator_group * origin,
+number_accidentals (Music * note, Pitch *pitch, Translator_group * origin,
SCM accidentals, SCM curbarnum)
{
int number = 0;
accidentals_[i].pass_done_ = 1;
Grob * support = accidentals_[i].head_;
- Note_req * note = accidentals_[i].melodic_;
+ Music * note = accidentals_[i].melodic_;
Translator_group * origin = accidentals_[i].origin_;
Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch"));
continue;
accidentals_[i].pass_done_ = 2;
Grob * support = accidentals_[i].head_;
- Note_req * note = accidentals_[i].melodic_;
+ Music * note = accidentals_[i].melodic_;
Translator_group * origin = accidentals_[i].origin_;
Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch"));
void
New_accidental_engraver::acknowledge_grob (Grob_info info)
{
- Note_req * note = dynamic_cast <Note_req *> (info.music_cause ());
+ Music * note = info.music_cause ();
- if (note && Rhythmic_head::has_interface (info.grob_))
+ if (note
+ && note->is_mus_type ("note-event")
+ && Rhythmic_head::has_interface (info.grob_))
{
New_accidental_entry entry ;
entry.head_ = info.grob_;
Link_array<Item> notes_;
Link_array<Item> dots_;
- Link_array<Note_req> note_reqs_;
+ Link_array<Music> note_reqs_;
public:
TRANSLATOR_DECLARATIONS(Note_heads_engraver);
bool
Note_heads_engraver::try_music (Music *m)
{
- if (Note_req * n =dynamic_cast <Note_req *> (m))
+ if (m->is_mus_type ("note-event"))
{
- note_reqs_.push (n);
+ note_reqs_.push (m);
return true;
}
- else if (dynamic_cast<Busy_playing_req*> (m))
+ else if (m->is_mus_type ("busy-playing-event"))
+ return note_reqs_.size ();
+ else if (m->is_mus_type ("abort-event"))
{
- return note_reqs_.size ();
+ in_ligature = 0;
}
- else if (Span_req *req_ = dynamic_cast<Span_req*> (m))
+ else if (m->is_mus_type ("ligature-event"))
{
- if (scm_equal_p (req_->get_mus_property ("span-type"),
- scm_makfrom0str ("abort")) == SCM_BOOL_T)
- {
- in_ligature = 0;
- }
- else if (scm_equal_p (req_->get_mus_property ("span-type"),
- scm_makfrom0str ("ligature")) == SCM_BOOL_T)
- {
- in_ligature = (req_->get_span_dir () == START);
- }
+ /*
+ Urg ; this is not protocol. We should accept and return
+ true, or ignore.
+ */
+ in_ligature = (m->get_mus_property("span-direction")
+ == gh_int2scm (START));
}
return false;
typeset_grob (dots_[i]);
}
dots_.clear ();
-
note_reqs_.clear ();
}
ENTER_DESCRIPTION(Note_heads_engraver,
-/* descr */ "Generate one or more noteheads from Music of type Note_req.",
-/* creats*/ "NoteHead Dots",
-/* accepts */ "general-music",
+/* descr */ "Generate noteheads (also serves a double functions: makes ligatures.",
+/* creats*/ "NoteHead LigatureHead Dots",
+/* accepts */ "note-event busy-playing-event ligature-event abort-event",
/* acks */ "",
/* reads */ "centralCPosition",
/* write */ "");
public:
TRANSLATOR_DECLARATIONS(Note_name_engraver);
- Link_array<Note_req> reqs_;
+ Link_array<Music> reqs_;
Link_array<Item> texts_;
virtual bool try_music (Music*m);
virtual void process_acknowledged_grobs ();
bool
Note_name_engraver::try_music (Music *m)
{
- if (Note_req *r = dynamic_cast<Note_req* > (m))
+ if (m->is_mus_type ("note-event"))
{
- reqs_.push (r);
+ reqs_.push (m);
return true;
}
return false;
Global_translator* get_global_translator ();
private:
- Array<Note_req*> note_reqs_;
- Array<Audio_note*> notes_;
- Array<Audio_note*> delayeds_;
+ Link_array<Music> note_reqs_;
+ Link_array<Audio_note> notes_;
+ Link_array<Audio_note> delayeds_;
};
void
while (note_reqs_.size ())
{
- Note_req* n = note_reqs_.pop ();
+ Music* n = note_reqs_.pop ();
Pitch pit = * unsmob_pitch (n->get_mus_property ("pitch"));
Audio_note* p = new Audio_note (pit, n->length_mom (), transposing_i);
Audio_element_info info (p, n);
bool
Note_performer::try_music (Music* req)
{
- if (Note_req *nr = dynamic_cast <Note_req *> (req))
+ if (req->is_mus_type ("note-event"))
{
- note_reqs_.push (nr);
+ note_reqs_.push (req);
return true;
}
return false;
$1-> set_spot (THIS->here_input ());
}
| E_LEFTSQUARE {
- Music *l = MY_MAKE_MUSIC("SpanEvent");
+ Music *l = MY_MAKE_MUSIC("LigatureEvent");
l->set_mus_property ("span-direction", gh_int2scm (START));
- l->set_mus_property ("span-type", scm_makfrom0str ("ligature"));
l->set_spot (THIS->here_input ());
$$ = MY_MAKE_MUSIC("RequestChord");
$$->set_spot (THIS->here_input ());
}
| E_RIGHTSQUARE {
- Music *l = MY_MAKE_MUSIC("SpanEvent");
+ Music *l = MY_MAKE_MUSIC("LigatureEvent");
l->set_mus_property ("span-direction", gh_int2scm (STOP));
- l->set_mus_property ("span-type", scm_makfrom0str ("ligature"));
l->set_spot (THIS->here_input ());
$$ = MY_MAKE_MUSIC("RequestChord");
for (SCM i = iter->get_pending_events (m); gh_pair_p (i); i = ly_cdr (i))
{
Music *m = unsmob_music (ly_car (i));
- if (Melodic_req *r = dynamic_cast<Melodic_req *> (m))
- *pitches = gh_cons (r->get_mus_property ("pitch"), *pitches);
- if (Rhythmic_req *r = dynamic_cast<Rhythmic_req *> (m))
+ if (m->is_mus_type ("melodic-event"))
+ *pitches = gh_cons (m->get_mus_property ("pitch"), *pitches);
+ if (m->is_mus_type ("rhythmic-event"))
{
- SCM d = r->get_mus_property ("duration");
+ SCM d = m->get_mus_property ("duration");
if (d == SCM_EOL)
- r->origin ()->warning ("Rhythmic_req has no duration\n");
- else
- // *durations = gh_cons (r->get_mus_property ("duration"), *durations);
- *durations = gh_cons (d, *durations);
+ m->origin ()->warning ("Rhythmic_req has no duration\n");
+ else
+ *durations = gh_cons (d, *durations);
}
}
}
if (!abort_req)
{
- abort_req = make_music_by_name (ly_symbol2scm ("SpanEvent"));
- abort_req->set_mus_property ("span-type", scm_makfrom0str ("abort"));
+ abort_req = make_music_by_name (ly_symbol2scm ("AbortEvent"));
}
if (combine_b && combine_b != previously_combined_b)
{
if (Rhythmic_head::has_interface (info_.grob_))
{
- Note_req *note_req_ = dynamic_cast <Note_req *> (info_.music_cause ());
- if (!note_req_)
- return;
- right_heads_.push (Grob_pitch_tuple (info_.grob_, note_req_,
- now_mom () +
- note_req_->length_mom ()));
+ Music * m = info_.music_cause ();
+ if (m->is_mus_type ("note-event"))
+ right_heads_.push (Grob_pitch_tuple (info_.grob_, m,
+ now_mom () +
+ m->length_mom ()));
}
}
for (SCM s = music_list (); gh_pair_p (s); s = ly_cdr (s))
{
Music * mus = unsmob_music (ly_car (s));
- Melodic_req *m= dynamic_cast <Melodic_req *> (mus);
- /*
- kLudge: rests have pitches now as well.
- */
- Rest_req *r = dynamic_cast<Rest_req*> (mus);
-
- if (r || m)
+ if (mus->is_mus_type ("melodic-event")
+ || mus->is_mus_type ("rest-event"))
{
Pitch *old_pit = unsmob_pitch (mus->get_mus_property ("pitch"));
if (!old_pit)
class Rest_engraver : public Engraver
{
- Rest_req *rest_req_;
+ Music *rest_req_;
Item * dot_;
Grob* rest_;
protected:
{
rest_ = new Item (get_property ("Rest"));
-
-
int durlog = unsmob_duration (rest_req_->get_mus_property ("duration"))-> duration_log ();
rest_->set_grob_property ("duration-log",
bool
Rest_engraver::try_music (Music *m)
{
- if (Rest_req *r = dynamic_cast <Rest_req *> (m))
+ if (m->is_mus_type ("rest-event"))
{
- rest_req_ = r;
+ rest_req_ = m;
return true;
- }
+ }
return false;
}
-
-
ENTER_DESCRIPTION(Rest_engraver,
/* descr */ "",
/* creats*/ "Rest Dots",
-/* accepts */ "general-music",
+/* accepts */ "rest-event",
/* acks */ "",
/* reads */ "centralCPosition",
/* write */ "");
/* Reverted to the old method so chord tremolos work again. /MB
*/
int duration_log = 0;
- Rhythmic_req *rhythmic_req = dynamic_cast <Rhythmic_req *> (i.music_cause ());
- if (rhythmic_req)
- duration_log = unsmob_duration (rhythmic_req->get_mus_property ("duration"))-> duration_log ();
+
+ Music * m = i.music_cause ();
+ if (m->is_mus_type ("rhythmic-event"))
+ duration_log = unsmob_duration (m->get_mus_property ("duration"))-> duration_log ();
if (!stem_)
{
Link_array<Item> notes_;
Link_array<Item> dots_;
- Link_array<Note_req> note_reqs_;
- Link_array<String_number_req> tabstring_reqs_;
+ Link_array<Music> note_reqs_;
+ Link_array<Music> tabstring_reqs_;
public:
TRANSLATOR_DECLARATIONS(Tab_note_heads_engraver);
bool
Tab_note_heads_engraver::try_music (Music *m)
{
- if (Note_req * n =dynamic_cast <Note_req *> (m))
+ if (m->is_mus_type ("note-event"))
{
- note_reqs_.push (n);
+ note_reqs_.push (m);
return true;
}
- else if (String_number_req * ts = dynamic_cast<String_number_req*> (m))
+ else if (m->is_mus_type ("string-number-event"))
{
while(tabstring_reqs_.size () < note_reqs_.size ()-1)
tabstring_reqs_.push(0);
- tabstring_reqs_.push(ts);
+
+ tabstring_reqs_.push (m);
return true;
}
- else if (dynamic_cast<Busy_playing_req*> (m))
+ else if (m->is_mus_type ("busy-playing-event"))
{
return note_reqs_.size ();
}
ENTER_DESCRIPTION(Tab_note_heads_engraver,
/* descr */ "Generate one or more tablature noteheads from Music of type Note_req.",
/* creats*/ "TabNoteHead Dots",
-/* accepts */ "general-music",
+/* accepts */ "note-event string-number-event busy-playing-event",
/* acks */ "",
/* reads */ "centralCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost",
/* write */ "");
/**
Manufacture ties. Acknowledge noteheads, and put them into a
- priority queue. If we have a Tie_req, connect the notes that finish
+ priority queue. If we have a TieEvent, connect the notes that finish
just at this time, and note that start at this time.
TODO: Remove the dependency on musical info. We should tie on the
Moment end_mom_;
Moment next_end_mom_;
- Tie_req *req_;
+ Music *req_;
Link_array<Grob> now_heads_;
Link_array<Grob> stopped_heads_;
Link_array<Grob> ties_;
bool
-Tie_engraver::try_music (Music *m)
+Tie_engraver::try_music (Music *mus)
{
- if (Tie_req * c = dynamic_cast<Tie_req*> (m))
+ req_ = mus;
+ SCM m = get_property ("automaticMelismata");
+ bool am = gh_boolean_p (m) &&gh_scm2bool (m);
+ if (am)
{
- /* if (end_mom_ > now_mom ())
- return false;
- */
- req_ = c;
- SCM m = get_property ("automaticMelismata");
- bool am = gh_boolean_p (m) &&gh_scm2bool (m);
- if (am)
- {
- set_melisma (true);
- }
- return true;
+ set_melisma (true);
}
- return false;
+ return true;
}
void
ENTER_DESCRIPTION(Tie_engraver,
/* descr */ "Generate ties between noteheads of equal pitch.",
/* creats*/ "Tie TieColumn",
-/* accepts */ "general-music",
+/* accepts */ "tie-event",
/* acks */ "rhythmic-head-interface",
/* reads */ "sparseTies tieMelismaBusy",
/* write */ "");
#include "performer.hh"
struct CNote_melodic_tuple {
- Melodic_req *req_ ;
+ Music *req_ ;
Audio_note *note_;
Moment end_;
CNote_melodic_tuple ();
- CNote_melodic_tuple (Audio_note*, Melodic_req*, Moment);
+ CNote_melodic_tuple (Audio_note*, Music*, Moment);
static int pitch_compare (CNote_melodic_tuple const &, CNote_melodic_tuple const &);
static int time_compare (CNote_melodic_tuple const &, CNote_melodic_tuple const &);
};
/**
Manufacture ties. Acknowledge notes, and put them into a
- priority queue. If we have a Tie_req, connect the notes that finish
+ priority queue. If we have a Music, connect the notes that finish
just at this time, and note that start at this time.
TODO: should share code with Tie_engraver ?
private:
bool done_;
PQueue<CNote_melodic_tuple> past_notes_pq_;
- Tie_req *req_;
+ Music *req_;
Array<CNote_melodic_tuple> now_notes_;
Array<CNote_melodic_tuple> stopped_notes_;
Link_array<Audio_tie> ties_;
}
ENTER_DESCRIPTION (Tie_performer, "", "",
- "general-music",
+ "tie-event",
"", "", "");
{
if (!req_)
{
- if (Tie_req * c = dynamic_cast<Tie_req*> (m))
- {
- req_ = c;
- return true;
- }
+ req_ = m;
+ return true;
}
return false;
}
{
if (Audio_note *nh = dynamic_cast<Audio_note *> (i.elem_))
{
- Note_req * m = dynamic_cast<Note_req *> (i.req_);
- if (!m)
- return;
- now_notes_.push (CNote_melodic_tuple (nh, m, now_mom ()+ m->length_mom ()));
+ Music *m = i.req_;
+ if (m->is_mus_type ("note-event"))
+ now_notes_.push (CNote_melodic_tuple (nh, m, now_mom ()+ m->length_mom ()));
}
}
end_ = 0;
}
-CNote_melodic_tuple::CNote_melodic_tuple (Audio_note *h, Melodic_req*m, Moment mom)
+CNote_melodic_tuple::CNote_melodic_tuple (Audio_note *h, Music*m, Moment mom)
{
note_ = h;
req_ = m;
#include "scm-hash.hh"
#include "translator-def.hh"
#include "main.hh"
+#include "music.hh"
Translator_group::Translator_group (Translator_group const&s)
: Translator (s)
return ret;
}
-bool
-Translator_group::try_music_on_nongroup_children (Music *m)
-{
- bool hebbes_b =false;
-
- for (SCM p = simple_trans_list_; !hebbes_b && gh_pair_p (p); p = ly_cdr (p))
- {
- hebbes_b = unsmob_translator (ly_car (p))->try_music (m);
- }
- return hebbes_b;
-}
-
bool
Translator_group::try_music (Music* m)
{
void
Translator_group::initialize ()
{
+ SCM tab = scm_make_vector (gh_int2scm (19), SCM_BOOL_F);
+ set_property ("acceptHashTable", tab);
each (&Translator::initialize);
}
each (&Translator::removal_processing);
}
-LY_DEFINE(ly_get_context_property,
- "ly-get-context-property", 2, 0, 0,
- (SCM context, SCM name),
- "retrieve the value of @var{sym} from context @var{tr}")
+
+
+bool translator_accepts_any_of (Translator*tr, SCM ifaces)
{
- Translator *t = unsmob_translator (context);
- Translator_group* tr= dynamic_cast<Translator_group*> (t);
- SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Translator group");
- SCM_ASSERT_TYPE(gh_symbol_p (name), name, SCM_ARG2, __FUNCTION__, "symbol");
+ SCM ack_ifs = scm_assoc (ly_symbol2scm ("events-accepted"),
+ tr->translator_description());
+ ack_ifs = gh_cdr (ack_ifs);
+ for (SCM s = ifaces; ly_pair_p (s); s = ly_cdr (s))
+ if (scm_memq (ly_car (s), ack_ifs) != SCM_BOOL_F)
+ return true;
+ return false;
+}
- return tr->internal_get_property (name);
-
+SCM
+find_accept_translators (SCM gravlist, SCM ifaces)
+{
+ SCM l = SCM_EOL;
+ for (SCM s = gravlist; ly_pair_p (s); s = ly_cdr (s))
+ {
+ Translator* tr = unsmob_translator (ly_car (s));
+ if (translator_accepts_any_of (tr, ifaces))
+ l = scm_cons (tr->self_scm (), l);
+ }
+ l = scm_reverse_x (l, SCM_EOL);
+
+ return l;
}
-LY_DEFINE(ly_set_context_property,
- "ly-set-context-property", 3, 0, 0,
- (SCM context, SCM name, SCM val),
- "set value of property @var{sym} in context @var{tr} to @var{val}.
-")
+bool
+Translator_group::try_music_on_nongroup_children (Music *m )
{
- Translator *t = unsmob_translator (context);
- Translator_group* tr= dynamic_cast<Translator_group*> (t);
+ SCM tab = get_property ("acceptHashTable");
+ SCM name = scm_assq ( ly_symbol2scm ("name"), m->get_property_alist (false));
- SCM_ASSERT_TYPE(tr, context, SCM_ARG1, __FUNCTION__, "Context");
- tr->internal_set_property (name, val);
+ if (!gh_pair_p (name))
+ return false;
- return SCM_UNSPECIFIED;
+ name = gh_car (name);
+ SCM accept_list = scm_hashq_ref (tab, name, SCM_UNDEFINED);
+ if (accept_list == SCM_BOOL_F)
+ {
+ accept_list = find_accept_translators (simple_trans_list_,
+ m->get_mus_property ("types"));
+ scm_hashq_set_x (tab, name, accept_list);
+ }
+
+ for (SCM p = accept_list; gh_pair_p (p); p = ly_cdr (p))
+ {
+ Translator * t = unsmob_translator (ly_car (p));
+ if (t && t->try_music (m))
+ return true;
+ }
+ return false;
}
(c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "type-swallow-translator.hh"
+#include "translator.hh"
#include "musical-request.hh"
-
-bool
-Type_swallow_translator::try_music (Music*r)
+class Skip_req_swallow_translator : public virtual Translator
{
- if (classname (r) == swallow_string_)
- return true;
- return false;
-}
+protected:
+ virtual bool try_music (Music*) { return true; }
+
+public:
+ TRANSLATOR_DECLARATIONS(Skip_req_swallow_translator);
+};
+
+
+Skip_req_swallow_translator::Skip_req_swallow_translator(){}
-DECLARE_REQUEST_SWALLOWER(Skip_req);
+ENTER_DESCRIPTION(Skip_req_swallow_translator,
+ "Swallow \\skip.",
+ "",
+ "skip-event",
+ "",
+ "",
+ "");
+
}
}
/* Ugh. Should eat other requests, script etc. too. */
- else if (dynamic_cast<Tie_req*> (m))
+ else if (m->is_mus_type ("tie-event"))
return true;
}
return false;
ENTER_DESCRIPTION(Voice_devnull_engraver,
/* descr */ "Kill off certain items and spanners if we're Voice `two' and unison or unisilence is set.",
/* creats*/ "",
-/* accepts */ "general-music",
+/* accepts */ "general-music tie-event",
/* acks */ "grob-interface",
/* reads */ "",
/* write */ "");
(music-property-description 'cautionary boolean? "If set, this alteration needs cautionary accidental")
(music-property-description 'change-to-id string? "name of the context to change to ")
(music-property-description 'change-to-type string? "type of the context to change to.")
+(music-property-description 'compress-procedure procedure? "compress this music expression. Argument 1: the music, arg 2: factor")
(music-property-description 'context-id string? "name of context")
(music-property-description 'context-type string? "type of context")
(music-property-description 'denominator integer? "denominator in a time signature")
(music-property-description 'last-pitch pitch? "The last pitch after relativization.")
(music-property-description 'length procedure? "How to compute the duration of this music")
(music-property-description 'internal-class-name string? "C++ class to use for this Music object")
+(music-property-description 'name symbol? "Name of this music object")
(music-property-description 'numerator integer? "numerator of a time signature")
(music-property-description 'once boolean? "Apply this operation only during one time step?")
(music-property-description 'origin ly-input-location? "where was this piece of music defined?")
(define-public music-descriptions
`(
+ (AbortEvent
+ . (
+ (internal-class-name . "Span_req")
+ (span-type . "abort")
+ (types . (general-music event abort-event))
+ ))
(ArpeggioEvent
. (
(internal-class-name . "Arpeggio_req")
(BassFigureEvent
. (
(internal-class-name . "Bass_figure_req")
+ (compress-procedure . ,music-duration-compress)
+ (length . ,music-duration-length)
(types . (general-music event rhythmic-event bass-figure-event))
- ))
+ ))
(BreakEvent
. (
(internal-class-name . "Break_req")
. (
(internal-class-name . "Lyric_req")
(types . (general-music rhythmic-event event))
- ))
+ ))
+ (LigatureEvent
+ . (
+ (internal-class-name . "Span_req")
+ (span-type . ligature)
+ (types . (general-music event span-event ligature-event))
+ ))
(MarkEvent
. (
(internal-class-name . "Mark_req")
))
(NoteEvent
. (
- (internal-class-name . "Note_req")
- (types . (general-music event rhythmic-event melodic-event))
+ (internal-class-name . "Request")
+ (length . ,music-duration-length)
+ (compress-procedure . ,music-duration-compress)
+ (types . (general-music event note-event rhythmic-event melodic-event))
))
(PorrectusEvent
. (
))
(RestEvent
. (
- (internal-class-name . "Rest_req")
- (types . (general-music event rhythmic-event ))
+ (internal-class-name . "Request")
+ (length . ,music-duration-length)
+ (compress-procedure . ,music-duration-compress)
+ (types . (general-music event rhythmic-event rest-event))
))
(RhythmicEvent
. (
(internal-class-name . "Rhythmic_req")
+ (length . ,music-duration-length)
+ (compress-procedure . ,music-duration-compress)
(types . (general-music rhythmic-event event))
))
(SequentialMusic
(types . (general-music layout-instruction))
(iterator-ctor . , Push_property_iterator::constructor)
))
-
(RevertProperty
. (
(internal-class-name . "Music")
(iterator-ctor . , Change_iterator::constructor)
(types . (general-music translator-change-instruction))
))
-
-
(TimeScaledMusic
. (
(internal-class-name . "Time_scaled_music")
))
(SkipEvent
. (
- (internal-class-name . "Skip_req")
-
- (types . (general-music event rhythmic-event ))
+ (internal-class-name . "Request")
+ (types . (general-music event rhythmic-event skip-event))
))
(SpanEvent
. (
))
(TieEvent
. (
- (internal-class-name . "Tie_req")
+ (internal-class-name . "Request")
(types . (general-music tie-event event))
))
))
-(define music-name-to-property-table (make-vector 59))
+(define music-name-to-property-table (make-vector 59 '()))
+
(map (lambda (x)
- (hashq-set! music-name-to-property-table (car x) (cdr x))
+ (hashq-set! music-name-to-property-table (car x)
+ (assoc-set! (cdr x) 'name (car x)))
)
music-descriptions)
+
+
(define-public (make-music-by-name x)
(if (not (symbol? x))
(misc-error "Not a symbol: ~s" x))
(let*
(
(props (hashq-ref music-name-to-property-table x '()))
- (name (if (pair? props) (cdr (assoc 'internal-class-name props)) "Music"))
+ (name (if (pair? props)
+ (cdr (assoc 'internal-class-name props))
+ (misc-error "Can not find music object ~s" x)))
)
-,
+
(if (eq? props '())
(ly-warn (format "Could not find music type `~a'" x)))
(ly-make-bare-music name props)
))
+