+++ /dev/null
-/*
- align-note-column-engraver.cc -- implement Align_note_column_engraver
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include "engraver.hh"
-#include "grace-align-item.hh"
-#include "align-interface.hh"
-#include "note-column.hh"
-#include "warn.hh"
-#include "directional-element-interface.hh"
-#include "side-position-interface.hh"
-#include "local-key-item.hh"
-#include "paper-def.hh"
-
-/**
- Catch notes, and put them in a row. Used for aligning grace notes.
- */
-class Align_note_column_engraver: public Engraver
-{
- Item * align_item_p_;
- Grob * now_column_l_;
- Grob * accidental_l_;
-
- virtual void create_grobs ();
- virtual void start_translation_timestep ();
- virtual void initialize ();
- virtual void finalize ();
- virtual void acknowledge_grob (Grob_info);
-public:
- VIRTUAL_COPY_CONS (Translator);
- Align_note_column_engraver ();
-};
-
-Align_note_column_engraver::Align_note_column_engraver ()
-{
- align_item_p_ =0;
- now_column_l_ =0;
- accidental_l_ =0;
-}
-
-void
-Align_note_column_engraver::initialize ()
-{
- align_item_p_ = new Item (get_property ("GraceAlignment"));
- Grace_align_item::set_interface (align_item_p_);
- Side_position_interface::set_axis (align_item_p_, X_AXIS);
- Side_position_interface::set_direction (align_item_p_, LEFT);
-
- // needed for setting font size.
- announce_grob (align_item_p_, 0);
-}
-
-void
-Align_note_column_engraver::finalize ()
-{
- SCM al = get_property ("graceAlignPosition");
- if (isdir_b (al))
- {
- Direction d = to_dir (al);
- Directional_element_interface::set (align_item_p_,d);
- }
-
- typeset_grob (align_item_p_);
- align_item_p_ =0;
-}
-
-void
-Align_note_column_engraver::acknowledge_grob (Grob_info inf)
-{
- if (Note_column::has_interface (inf.elem_l_))
- {
- now_column_l_ =inf.elem_l_;
- }
- else if (Local_key_item::has_interface (inf.elem_l_))
- {
- accidental_l_ = inf.elem_l_;
- }
-}
-void
-Align_note_column_engraver::create_grobs ()
-{
- if (now_column_l_ && accidental_l_)
- {
-
- /* Can't inspect width of Local_key_item, since
-
- A. it may not be fully built
-
- B. it has no pscore_l_ field.
-
-
- UGH UGH: separate note-spacing into separate class, and
- use that to space grace notes.
- */
- SCM grsp = get_property ("graceAccidentalSpace") ;
- if (gh_number_p (grsp))
- {
- /*
- ugh.
- */
- Real extra_space = gh_scm2double (grsp);
- SCM e = gh_cons (gh_double2scm (-extra_space),
- gh_double2scm (0.0));
- now_column_l_->set_grob_property ("extra-space", e);
- }
- }
-
- if (now_column_l_ && !align_item_p_)
- programming_error ("Align_note_column_engraver:: urg\n");
- else
-
- if (now_column_l_)
- {
- Align_interface::add_element (align_item_p_,now_column_l_, Align_interface::alignment_callback_proc);
- now_column_l_ =0;
- }
-}
-
-void
-Align_note_column_engraver::start_translation_timestep ()
-{
- now_column_l_ =0;
- accidental_l_ =0;
-}
-
-ADD_THIS_TRANSLATOR (Align_note_column_engraver);
-
+++ /dev/null
-/*
- grace-align-item.cc -- implement Grace_align_item
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include "grace-align-item.hh"
-#include "align-interface.hh"
-
-#include "paper-column.hh"
-#include "paper-def.hh"
-
-MAKE_SCHEME_CALLBACK (Grace_align_item,before_line_breaking,1);
-SCM
-Grace_align_item::before_line_breaking (SCM smob)
-{
- Grob*me = unsmob_grob (smob);
-
- SCM space = me->get_grob_property ("horizontal-space");
- me->set_grob_property ("threshold",
- gh_cons (space,
- gh_double2scm (infinity_f)));
- dynamic_cast<Item*> (me)->column_l ()->set_grob_property ("contains-grace", SCM_BOOL_T);
-
- return SCM_UNSPECIFIED;
-}
-
-void
-Grace_align_item::set_interface (Grob*me)
-{
- me->set_interface (ly_symbol2scm ("grace-align-interface"));
- me->set_grob_property ("stacking-dir", gh_int2scm (RIGHT));
- Align_interface::set_interface (me);
- Align_interface::set_axis (me,X_AXIS);
-}
-
-
-
-bool
-Grace_align_item::has_interface (Grob*m)
-{
- return m&& m->has_interface (ly_symbol2scm ("grace-align-interface"));
-}
+++ /dev/null
-/*
- grace-engraver-group.cc -- implement Grace_engraver_group
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include "grace-engraver-group.hh"
-#include "lily-guile.hh"
-#include "grob.hh"
-#include "musical-request.hh"
-
-void
-Grace_engraver_group::start ()
-{
-}
-/*
- We're really finished with this context. Get rid of everything.
- */
-void
-Grace_engraver_group::finish ()
-{
- calling_self_b_ = true;
- removal_processing (); // ugr. We'd want to have this done by our parents.
- for (int i=0; i < announce_to_top_.size (); i++)
- {
- Engraver::announce_grob (announce_to_top_[i]);
- }
-
- for (int i=0; i < typeset_us_.size (); i++)
- {
- Engraver::typeset_grob (typeset_us_[i]);
- }
- typeset_us_.clear ();
- calling_self_b_ = false;
-}
-
-void
-Grace_engraver_group::finalize ()
-{
- Engraver_group_engraver::finalize ();
-}
-
-void
-Grace_engraver_group::announce_grob (Grob_info inf)
-{
- announce_info_arr_.push (inf);
- // do not propagate to top
- announce_to_top_.push (inf);
-
- inf.elem_l_->set_grob_property ("grace", SCM_BOOL_T);
-}
-
-void
-Grace_engraver_group::typeset_grob (Grob*e)
-{
- typeset_us_.push (e);
-}
-
-
-Grace_engraver_group::Grace_engraver_group ()
-{
- calling_self_b_ = false;
-}
-
-void
-Grace_engraver_group::one_time_step ()
-{
- calling_self_b_ = true;
-
- if (!to_boolean (get_property (ly_symbol2scm ("skipTypesetting"))))
- {
- process_music ();
- announces ();
- }
- stop_translation_timestep ();
- check_removal ();
- calling_self_b_ = false;
-}
-
-
-void
-Grace_engraver_group::each (Method_pointer method)
-{
- if (calling_self_b_)
- Engraver_group_engraver::each (method);
-}
-
-
-ADD_THIS_TRANSLATOR (Grace_engraver_group);
-
-
-/*
- don't let the commands trickle up.
- */
-bool
-Grace_engraver_group::try_music (Music *m)
-{
- bool hebbes_b = try_music_on_nongroup_children (m);
-
- if (!hebbes_b && pass_to_top_b (m))
- {
- hebbes_b = daddy_trans_l_->try_music (m);
- }
-
- return hebbes_b;
-}
-
-bool
-Grace_engraver_group::pass_to_top_b (Music *m) const
-{
- if (Span_req * sp = dynamic_cast<Span_req*> (m))
- {
- if (scm_equal_p (sp->get_mus_property ("span-type"), ly_str02scm ("slur"))
- == SCM_BOOL_T)
- // return true;
- return false;
- }
- return false;
-}
-
-void
-Grace_engraver_group::initialize ()
-{
- calling_self_b_ = true;
- Engraver_group_engraver::initialize ();
- calling_self_b_ = false;
-}
+++ /dev/null
-/*
- grace-performer-group.cc -- implement Grace_performer_group
-
- source file of the GNU LilyPond music playter
-
- (c) 1999--2001 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
-#include "grace-performer-group.hh"
-#include "lily-guile.hh"
-
-#include "audio-element.hh"
-
-ADD_THIS_TRANSLATOR (Grace_performer_group);
-
-void
-Grace_performer_group::start ()
-{
-}
-/*
- We're really finished with this context. Get rid of everything.
- */
-void
-Grace_performer_group::finish ()
-{
- calling_self_b_ = true;
- removal_processing (); // ugr. We'd want to have this done by our parents.g
- for (int i=0; i < announce_to_top_.size (); i++)
- {
- Performer::announce_element (announce_to_top_[i]);
- }
-
- for (int i=0; i < play_us_.size (); i++)
- {
- Performer::play_element (play_us_[i]);
- }
- play_us_.clear ();
- calling_self_b_ = false;
-}
-
-void
-Grace_performer_group::finalize ()
-{
- Performer_group_performer::finalize ();
-}
-
-void
-Grace_performer_group::announce_element (Audio_element_info info)
-{
- announce_info_arr_.push (info);
- // do not propagate to top
- announce_to_top_.push (info);
-
- //inf.elem_l_->set_grob_property ("grace", SCM_BOOL_T);
- info.elem_l_->grace_b_ = true;
-}
-
-void
-Grace_performer_group::play_element (Audio_element*e)
-{
- play_us_.push (e);
-}
-
-
-Grace_performer_group::Grace_performer_group ()
-{
- calling_self_b_ = false;
-}
-
-void
-Grace_performer_group::one_time_step ()
-{
- calling_self_b_ = true;
- // process_music ();
- announces ();
- stop_translation_timestep ();
- check_removal ();
- calling_self_b_ = false;
-}
-
-
-void
-Grace_performer_group::each (Method_pointer method)
-{
- if (calling_self_b_)
- Performer_group_performer::each (method);
-}
-
-
-
-
-/*
- don't let the commands trickle up.
- */
-bool
-Grace_performer_group::try_music (Music *m)
-{
- return try_music_on_nongroup_children (m);
-}
-
+++ /dev/null
-/*
- grace-position-engraver.cc -- implement Grace_position_engraver
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include "engraver.hh"
-#include "grace-align-item.hh"
-#include "rhythmic-head.hh"
-#include "local-key-item.hh"
-#include "paper-column.hh"
-#include "note-head.hh"
-#include "side-position-interface.hh"
-#include "axis-group-interface.hh"
-
-
-class Grace_position_engraver:public Engraver
-{
- Paper_column *last_musical_col_l_;
-protected:
- VIRTUAL_COPY_CONS (Translator);
- virtual void acknowledge_grob (Grob_info);
- virtual void create_grobs ();
- virtual void start_translation_timestep ();
- virtual void stop_translation_timestep ();
- Item*align_l_;
- Link_array<Item> support_;
-public:
- Grace_position_engraver ();
-};
-
-
-Grace_position_engraver::Grace_position_engraver ()
-{
- align_l_ =0;
- last_musical_col_l_ =0;
-}
-
-void
-Grace_position_engraver::acknowledge_grob (Grob_info i)
-{
- Item *item = dynamic_cast<Item*> (i.elem_l_);
- if (item && Grace_align_item::has_interface (i.elem_l_))
- {
- align_l_ = item;
- }
- else if (item && Note_head::has_interface (i.elem_l_))
- {
- if (!to_boolean (item->get_grob_property ("grace")))
- support_.push (item);
- }
- else if (item && Local_key_item::has_interface (i.elem_l_))
- {
- if (!to_boolean (item->get_grob_property ("grace")))
- support_.push (item);
- else if (align_l_)
- item->add_dependency (align_l_);
- }
-}
-
-void
-Grace_position_engraver::create_grobs ()
-{
- if (align_l_)
- {
- for (int i=0; i < support_.size (); i++)
- Side_position_interface::add_support (align_l_,support_[i]);
- support_.clear ();
- }
-}
-
-void
-Grace_position_engraver::stop_translation_timestep ()
-{
- if (align_l_ && !Side_position_interface::supported_b (align_l_))
- {
- /*
- We don't have support. Either some moron tried attaching us to a rest,
- or we're at the end of the piece. In the latter case, we have a
- problem if there are spanners in the grace section,
- they will want to be broken into pieces (their line_l () field is nil).
-
- Solution: attach ourselves to the last musical column known. A little intricate.
-
- */
-
- Grob * elt = align_l_->parent_l (X_AXIS);
- if (elt)
- return;
-
- if (last_musical_col_l_)
- {
- warning (_ ("Unattached grace notes. Attaching to last musical column."));
-
- align_l_->set_parent (0, X_AXIS);
- Axis_group_interface::add_element (last_musical_col_l_, align_l_);
- }
- else
- {
- // tja.
- }
- }
- last_musical_col_l_ = dynamic_cast<Paper_column*> (unsmob_grob (get_property ("currentMusicalColumn")));
-}
-
-void
-Grace_position_engraver::start_translation_timestep ()
-{
- support_.clear ();
- align_l_ =0;
-}
-
-ADD_THIS_TRANSLATOR (Grace_position_engraver);
-
+++ /dev/null
-/*
- grace-position-performer.cc -- implement Grace_position_performer
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
-
-#include "performer.hh"
-#include "audio-item.hh"
-#include "global-translator.hh"
-
-class Grace_position_performer : public Performer
-{
-public:
- Grace_position_performer ();
-
-protected:
- Link_array<Audio_note> graces_;
- Link_array<Audio_note> notes_;
-
- VIRTUAL_COPY_CONS (Translator);
- virtual void acknowledge_audio_element (Audio_element_info);
- virtual void create_audio_elements ();
- virtual void start_translation_timestep ();
- Global_translator* global_translator_l ();
-};
-
-ADD_THIS_TRANSLATOR (Grace_position_performer);
-
-Grace_position_performer::Grace_position_performer ()
-{
-}
-
-void
-Grace_position_performer::acknowledge_audio_element (Audio_element_info i)
-{
- if (Audio_note * n = dynamic_cast <Audio_note*> (i.elem_l_))
- {
- if (i.elem_l_->grace_b_)
- graces_.push (n);
- else
- notes_.push (n);
- }
-}
-
-void
-Grace_position_performer::create_audio_elements ()
-{
- if (graces_.size ())
- {
- // we're above grace-engraver-group, so we cannot tell
- // grace-iterator. note-performer should add moments.
- //Global_translator* global_l = global_translator_l ();
- Moment delay_mom = Moment (1, 8);
- if (notes_.size ())
- {
- Moment shortest_mom = notes_[0]->length_mom_;
- for (int i=1; i < notes_.size (); i++)
- shortest_mom = shortest_mom <? notes_[i]->length_mom_;
-
- Moment grace_fraction_rat (1, 2);
- SCM prop = get_property ("graceFraction");
- if (unsmob_moment (prop))
- grace_fraction_rat = *unsmob_moment (prop);
-
- delay_mom = shortest_mom * grace_fraction_rat;
- for (int i=0; i < notes_.size (); i++)
- {
- Audio_note* n = notes_[i];
- n->length_mom_ -= delay_mom;
- n->delayed_mom_ = delay_mom;
- n->delayed_until_mom_ = now_mom () + delay_mom;
- //global_l->add_moment_to_process (n->delayed_until_mom_);
- }
- notes_.clear ();
- }
-
- Moment grace_length_mom;
- for (int i=0; i < graces_.size (); i++)
- grace_length_mom += graces_[i]->length_mom_;
-
- Moment grace_factor_rat = delay_mom / grace_length_mom;
-
- for (int i=0; i < graces_.size (); i++)
- {
- Audio_note* n = graces_[i];
- n->length_mom_ *= grace_factor_rat;
- if (i)
- {
- Audio_note* p = graces_[i-1];
- n->delayed_mom_ = p->delayed_mom_ + p->length_mom_;
- n->delayed_until_mom_ = now_mom () + n->delayed_mom_;
- //global_l->add_moment_to_process (n->delayed_until_mom_);
- }
- }
- graces_.clear ();
- }
-}
-
-Global_translator*
-Grace_position_performer::global_translator_l ()
-{
- Translator *t = this;
- Global_translator *global_l =0;
- do
- {
- t = t->daddy_trans_l_ ;
- global_l = dynamic_cast<Global_translator*> (t);
- }
- while (!global_l);
-
- return global_l;
-}
-
-
-void
-Grace_position_performer::start_translation_timestep ()
-{
- graces_.clear ();
- notes_.clear ();
-}
-
+++ /dev/null
-/*
- grace-align-item.hh -- declare Grace_align_item
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef GRACE_ALIGN_ITEM_HH
-#define GRACE_ALIGN_ITEM_HH
-
-
-#include "lily-guile.hh"
-#include "lily-proto.hh"
-
-class Grace_align_item
-{
-public:
- static void set_interface (Grob*);
- static bool has_interface (Grob*);
- DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM ));
-};
-#endif /* GRACE_ALIGN_ITEM_HH */
-
+++ /dev/null
-/*
- grace-engraver-group.hh -- declare Grace_engraver_group
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef GRACE_ENGRAVER_GROUP_HH
-#define GRACE_ENGRAVER_GROUP_HH
-
-#include "engraver-group-engraver.hh"
-#include "global-translator.hh"
-
-class Grace_engraver_group : public Engraver_group_engraver, public Global_translator
-{
- Link_array<Grob> typeset_us_;
- Array<Grob_info> announce_to_top_;
- bool calling_self_b_;
- bool pass_to_top_b (Music *) const;
-public:
- VIRTUAL_COPY_CONS (Translator);
- Grace_engraver_group ();
-protected:
- virtual void initialize ();
- virtual void announce_grob (Grob_info);
- virtual void start ();
- virtual void finish ();
- virtual void one_time_step ();
- virtual void each (Method_pointer);
- virtual void finalize () ;
- virtual void typeset_grob (Grob*);
- virtual bool try_music (Music *m);
-};
-
-
-#endif /* GRACE_ENGRAVER_GROUP_HH */
+++ /dev/null
-/*
- grace-performer-group.hh -- declare Grace_performer_group
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Jan Nieuwenhuizen <janneke@gnu.org>
-
- */
-
-#ifndef GRACE_PERFORMER_GROUP_HH
-#define GRACE_PERFORMER_GROUP_HH
-
-#include "performer-group-performer.hh"
-#include "global-translator.hh"
-
-class Grace_performer_group : public Performer_group_performer, public Global_translator
-{
- Link_array<Audio_element> play_us_;
- Array<Audio_element_info> announce_to_top_;
- bool calling_self_b_;
-public:
- VIRTUAL_COPY_CONS (Translator);
- Grace_performer_group ();
-protected:
- virtual void announce_element (Audio_element_info);
- virtual void start ();
- virtual void finish ();
- virtual void one_time_step ();
- virtual void each (Method_pointer);
- virtual void finalize () ;
- virtual void play_element (Audio_element*);
- virtual bool try_music (Music *m);
-};
-
-
-#endif /* GRACE_PERFORMER_GROUP_HH */
+++ /dev/null
-/*
- new-grace-iterator.hh -- declare New-Grace_iterator
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef NEWGRACE_ITERATOR_HH
-#define NEWGRACE_ITERATOR_HH
-
-#include "music-wrapper-iterator.hh"
-
-class New_grace_iterator : public Music_wrapper_iterator
-{
-public:
- VIRTUAL_COPY_CONS (Music_iterator);
- ~New_grace_iterator ();
- virtual void construct_children () ;
- virtual void process (Moment);
- static SCM constructor_cxx_function;
- Moment pending_moment () const;
-};
-
-
-
-#endif /* GRACE_ITERATOR_HH */
-
-
+++ /dev/null
-/*
- grace-music.hh -- declare Grace_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#ifndef NGRACE_MUSIC_HH
-#define NGRACE_MUSIC_HH
-
-#include "music-wrapper.hh"
-
-class New_grace_music : public Music_wrapper
-{
-public:
- VIRTUAL_COPY_CONS (Music);
- New_grace_music (SCM);
- New_grace_music ();
-protected:
- virtual void compress (Moment);
- virtual Moment length_mom () const;
- virtual Moment start_mom () const;
-};
-
-#endif /* GRACE_MUSIC_HH */
-
+++ /dev/null
-/*
- new-grace-music.cc -- implement New-Grace_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include "new-grace-music.hh"
-#include "new-grace-iterator.hh"
-
-#include "grace-iterator.hh"
-#include "global-translator.hh"
-#include "warn.hh"
-
-
-New_grace_iterator::~New_grace_iterator ()
-{
- // child_iter_p_ = 0;
-}
-
-
-void
-New_grace_iterator::process (Moment m )
-{
- Moment main ;
- main.main_part_ = m.grace_mom_;
- Music_wrapper_iterator::process (main);
-}
-
-void
-New_grace_iterator::construct_children ()
-{
- Music_wrapper_iterator::construct_children ();
-}
-
-
-
-Moment
-New_grace_iterator::pending_moment () const
-{
- Moment cp =Music_wrapper_iterator::pending_moment();
-
- Moment pending;
- pending.grace_mom_ = - music_length_.main_part_ + cp.main_part_;
-
- return pending;
-}
-
-
-IMPLEMENT_CTOR_CALLBACK (New_grace_iterator);
+++ /dev/null
-/*
- grace-music.cc -- implement New_grace_music
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include "new-grace-music.hh"
-#include "new-grace-iterator.hh"
-
-void
-New_grace_music::compress (Moment m)
-{
- Music_wrapper::compress (m);
-}
-
-Moment
-New_grace_music::length_mom () const
-{
- Moment l = Music_wrapper::length_mom ();
- Moment gl;
- gl.grace_mom_ = l.main_part_ + l.grace_mom_ ;
- return gl;
-}
-
-
-Moment
-New_grace_music::start_mom () const
-{
- return Music::start_mom ();
-}
-
-New_grace_music::New_grace_music ()
-{
- set_mus_property ("iterator-ctor",
- New_grace_iterator::constructor_cxx_function);
-}
-
-New_grace_music::New_grace_music (SCM p)
- : Music_wrapper (p)
-{
- set_mus_property ("iterator-ctor",
- New_grace_iterator::constructor_cxx_function);
-}
-
-ADD_MUSIC (New_grace_music);