+2004-02-17 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * input/test/piano-staff-distance.ly: new file.
+
+ * lily/translator-group.cc (recurse_down_translators): use
+ Direction for bottom-up/top-down.
+
+ * lily/include/translator.hh (class Translator): add
+ process_music() and do_announces(). This obviates
+ recurse_down_{engravers,performers}.
+
+ * ly/declarations-init.ly (melismaEnd): use ManualMelismaEvent for
+ \melisma and \melismaEnd
+
+ * lily/melisma-engraver.cc (process_music): change to
+ Melisma_translator, unify with performer. Accept
+ ManualMelismaEvent.
+
+ * ly/engraver-init.ly: add Font_size_engraver.
+
2004-02-16 Heikki Junes <hjunes@cc.hut.fi>
* lily/align-interface.cc, lily/axis-group-engraver.cc: spell
--- /dev/null
+
+\header
+{
+
+ texidoc = "It is possible to have different staff distances across
+piano systems, but it requires some advanced magic. Kids don't try this at home.
+
+"
+
+}
+
+\version "2.1.24"
+
+#(define ((futz-alignment-callback distance count) grob axis)
+
+ "Check if we're the system number COUNT, and if yes, set fixed distance to
+DISTANCE; then call the original callback. "
+ (let*
+ ((a (ly:get-parent grob axis))
+ (o (ly:get-original a))
+ (bs (if (ly:grob? o)
+ (ly:get-broken-into o)
+ #f))
+ )
+
+
+ (if (and (list? bs)
+ (< count (length bs))
+ (equal? (list-ref bs count) a)
+ )
+ (ly:set-grob-property! a 'forced-distance distance))
+
+ (Align_interface::fixed_distance_alignment_callback grob axis)) )
+
+\score {
+ \notes \relative c'' \context PianoStaff
+ \with {
+ verticalAlignmentChildCallback = #(futz-alignment-callback 20 1)
+
+ %% Every cross staff beam will trigger
+ %% alignment unless autokneeing is switched off
+ \override Beam #'auto-knee-gap = #'()
+ } <<
+
+ \context Staff = up {
+
+ \time 2/4
+ c8[
+ \change Staff = down
+ \once \override Stem #'direction = #UP
+ c8
+ \change Staff = up
+ c c ](
+ |
+ \break
+
+ c8[)
+ \change Staff = down
+ \once \override Stem #'direction = #UP
+ c8
+ \change Staff = up
+ c c ](
+ }
+ \context Staff = down {
+ \skip 1 }
+
+ >>
+ \paper { raggedright = ##T }
+}
for (int i = scratch_note_reqs_.size(); i--;)
{
scm_gc_unprotect_object (scratch_note_reqs_[i]->self_scm () );
-
}
scratch_note_reqs_.clear();
Context_def::clone_scm () const
{
Context_def * t = new Context_def (*this);
- scm_gc_unprotect_object (t->self_scm());
- return t->self_scm();
+
+ SCM x = t->self_scm();
+ scm_gc_unprotect_object (x);
+ return x;
}
SCM
Context_def::make_scm ()
{
Context_def* t = new Context_def;
- scm_gc_unprotect_object (t->self_scm());
- return t->self_scm();
+
+ SCM x =t->self_scm();
+ scm_gc_unprotect_object (x);
+ return x;
}
void
trg->check_removal ();
if (trg->is_removable ())
{
- recurse_down_translators (trg, &Translator::finalize, false);
+ recurse_down_translators (trg, &Translator::finalize, DOWN);
remove_context (trg);
}
}
*/
td->apply_default_property_operations (t);
- recurse_down_translators (t, &Translator::initialize, true);
+ recurse_down_translators (t, &Translator::initialize, DOWN);
}
}
smobify_self ();
- Scheme_hash_table *tab = new Scheme_hash_table ;
- properties_scm_ = tab->self_scm ();
- scm_gc_unprotect_object (tab->self_scm ());
+ properties_scm_ = (new Scheme_hash_table)->self_scm ();
+ scm_gc_unprotect_object (properties_scm_);
}
Context *
-void
-Engraver::process_music ()
-{
-
-}
Engraver::Engraver()
{
}
}
-void
-Engraver::do_announces ()
-{
-}
-
ENTER_DESCRIPTION(Engraver,
"", "",
"",
typedef void (Engraver::*Engraver_method) (void);
-void recurse_down_engravers (Context * c, Engraver_method ptr, bool context_first);
void engraver_each (SCM list, Engraver_method method);
#endif // ENGRAVERGROUP_HH
*/
virtual void announce_grob (Grob*, SCM cause);
virtual void announce_grob (Grob_info);
- virtual void process_music ();
- virtual void do_announces ();
Engraver_group_engraver*get_daddy_engraver () const;
public:
void acknowledge_audio_elements ();
};
-void recurse_down_performers (Context * c, Performer_method ptr,
- bool context_first);
void performer_each (SCM list, Performer_method method);
#endif // PERFORMER_GROUP_PERFORMER_HH
virtual void create_audio_elements ();
virtual int get_tempo () const;
virtual void play_element (Audio_element * elem );
- virtual void process_music ();
- virtual void do_announces ();
};
SCM names_to_translators (SCM namelist, Context*tg);
-void recurse_down_translators (Context * c, Translator_method ptr, bool context_first);
+void recurse_down_translators (Context * c, Translator_method ptr, Direction);
void translator_each (SCM list, Translator_method method);
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
virtual void initialize () ;
+ virtual void process_music ();
+ virtual void do_announces ();
virtual void finalize ();
};
Lyric_phrasing_engraver::get_voice_name_for_lyric (Context *tr)
{
SCM voice_context = tr->get_property ("associatedVoiceContext");
- if (Translator *vc = unsmob_translator (voice_context))
+ if (Context *vc = unsmob_context (voice_context))
{
- return dynamic_cast<Context *> (vc)->id_string_;
+ return vc->id_string_;
}
SCM voice = tr->get_property ("associatedVoice");
+++ /dev/null
-/*
- melisma-engraver.cc -- implement Melisma_engraver
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-/*
- duplicated in melisma-performer
- */
-#include "engraver.hh"
-#include "event.hh"
-#include "grob.hh"
-#include "context.hh"
-
-
-/**
- Signal existence of melismas.
- */
-class Melisma_engraver : public Engraver
-{
-public:
- TRANSLATOR_DECLARATIONS(Melisma_engraver);
- bool try_music (Music *);
-};
-
-
-bool
-Melisma_engraver::try_music (Music *)
-{
- /*
- This can only be melisma-playing-event.
- */
- return melisma_busy (this);
-}
-
-Melisma_engraver::Melisma_engraver()
-{
-}
-
-ENTER_DESCRIPTION(Melisma_engraver,
-/* descr */ "This engraver collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code. ",
-/* creats*/ "",
-/* accepts */ "melisma-playing-event",
-/* acks */ "",
-/* reads */ "melismaBusy melismaBusyProperties slurMelismaBusy tieMelismaBusy beamMelismaBusy",
-/* write */ "");
+++ /dev/null
-
-/*
- melisma-performer.cc -- implement Melisma_performer
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-/*
- copy of melisma-engraver - see there.
- */
-#include "performer.hh"
-#include "event.hh"
-#include "grob.hh"
-#include "translator-group.hh"
-
-/**
- Signal existence of melismas.
- */
-class Melisma_performer : public Performer
-{
-public:
- TRANSLATOR_DECLARATIONS(Melisma_performer);
- bool try_music (Music *);
-};
-
-
-bool
-Melisma_performer::try_music (Music *)
-{
- /*
- This can only be melisma-playing-event.
- */
- return melisma_busy (this);
-}
-
-Melisma_performer::Melisma_performer()
-{
-}
-
-ENTER_DESCRIPTION(Melisma_performer,
-/* descr */ "This performer collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code. ",
-/* creats*/ "",
-/* accepts */ "melisma-playing-event",
-/* acks */ "",
-/* reads */ "melismaBusy melismaBusyProperties slurMelismaBusy tieMelismaBusy beamMelismaBusy",
-/* write */ "");
--- /dev/null
+/*
+ melisma-engraver.cc -- implement Melisma_engraver
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+/*
+ duplicated in melisma-performer
+ */
+#include "engraver.hh"
+#include "event.hh"
+#include "grob.hh"
+#include "context.hh"
+
+
+/**
+ Signal existence of melismas.
+ */
+class Melisma_translator : public Translator
+{
+public:
+ TRANSLATOR_DECLARATIONS(Melisma_translator);
+protected:
+ virtual bool try_music (Music *);
+ virtual void process_music ();
+ virtual void start_translation_timestep ();
+ Music * event_;
+};
+
+
+bool
+Melisma_translator::try_music (Music *m)
+{
+ if (m->is_mus_type ("melisma-playing-event"))
+ {
+ return melisma_busy (this);
+ }
+ else if (m->is_mus_type ("melisma-span-event"))
+ {
+ event_ = m;
+ return true;
+ }
+
+ return false;
+}
+
+void
+Melisma_translator::process_music ()
+{
+ if (event_)
+ {
+ SCM sd = event_->get_mus_property ("span-direction");
+ Direction d = to_dir (sd);
+ if (d == START)
+ daddy_context_->set_property ("melismaBusy", SCM_BOOL_T);
+ else
+ daddy_context_->unset_property (ly_symbol2scm ("melismaBusy"));
+ }
+
+}
+
+void
+Melisma_translator::start_translation_timestep ()
+{
+ event_ =0;
+}
+
+Melisma_translator::Melisma_translator()
+{
+}
+
+ENTER_DESCRIPTION(Melisma_translator,
+/* descr */ "This translator collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code. ",
+/* creats*/ "",
+/* accepts */ "melisma-playing-event melisma-span-event",
+/* acks */ "",
+/* reads */ "melismaBusy melismaBusyProperties slurMelismaBusy tieMelismaBusy beamMelismaBusy",
+/* write */ "");
translator_tab_ = new Scheme_hash_table;
scope_ = SCM_EOL;
smobify_self ();
- scm_gc_unprotect_object (translator_tab_->self_scm ());
- scope_ = ly_make_anonymous_module();
+ scm_gc_unprotect_object (translator_tab_->self_scm ());
+ scope_ = ly_make_anonymous_module();
}
Music_output_def::~Music_output_def ()
Music_output_def::Music_output_def (Music_output_def const &s)
{
scope_ = SCM_EOL;
- translator_tab_ = new Scheme_hash_table (*s.translator_tab_);
-
+ translator_tab_ = 0;
scaled_fonts_ = SCM_EOL;
-
smobify_self ();
+
+ translator_tab_ = new Scheme_hash_table (*s.translator_tab_);
scm_gc_unprotect_object (translator_tab_->self_scm ());
scaled_fonts_ = scm_list_copy (s.scaled_fonts_);
Music_output_def::mark_smob (SCM m)
{
Music_output_def * mo = (Music_output_def*) SCM_CELL_WORD_1 (m);
- scm_gc_mark (mo->translator_tab_->self_scm ());
+ if (mo->translator_tab_)
+ scm_gc_mark (mo->translator_tab_->self_scm ());
scm_gc_mark (mo->scope_);
return mo->scaled_fonts_;
f = all_fonts_global->find_font (ly_scm2string (fn));
SCM val = Scaled_font_metric::make_scaled_font_metric (f, m);
scaled_fonts_ = scm_acons (key, val, scaled_fonts_);
- f = unsmob_metrics (val);
scm_gc_unprotect_object (val);
+
+ f = unsmob_metrics (val);
}
return f;
{
}
-/* c&p engraver-group.cc */
-void
-recurse_down_performers (Context * c, Performer_method ptr, bool context_first)
-{
- Performer_group_performer * tg
- = dynamic_cast<Performer_group_performer*> (unsmob_translator (c->implementation_));
-
-
- if (!context_first)
- {
- performer_each (tg->get_simple_trans_list (),
- ptr);
-
- (tg->*ptr) ();
- }
-
- for (SCM s = c->context_list_ ; gh_pair_p (s);
- s =gh_cdr (s))
- {
- recurse_down_performers (unsmob_context (gh_car (s)), ptr, context_first);
- }
-
- if (context_first)
- {
- performer_each (tg->get_simple_trans_list (),
- ptr);
- (tg->*ptr) ();
- }
-}
-
void
performer_each (SCM list, Performer_method method)
#include "performer-group-performer.hh"
#include "warn.hh"
-void
-Performer::do_announces ()
-{
-}
-
void
Performer::play_element (Audio_element* p)
{
i.origin_trans_= this;
get_daddy_performer ()->announce_element (i);
}
-
-void
-Performer::process_music ()
-{
-
-}
command_column_->set_grob_property ("when", w);
musical_column_->set_grob_property ("when", w);
- recurse_down_translators (daddy_context_, &Translator::start_translation_timestep, false);
+ recurse_down_translators (daddy_context_, &Translator::start_translation_timestep, DOWN);
}
void
if ((breaks_%8))
progress_indication ("[" + to_string (breaks_) + "]");
- recurse_down_translators (daddy_context_, &Translator::finalize, true);
+ recurse_down_translators (daddy_context_, &Translator::finalize, UP);
}
/*
{
if (!to_boolean (get_property ("skipTypesetting")))
{
- recurse_down_engravers (daddy_context_, &Engraver::process_music, true);
- recurse_down_engravers (daddy_context_, &Engraver::do_announces, true);
+ recurse_down_translators (daddy_context_, &Engraver::process_music, UP);
+ recurse_down_translators (daddy_context_, &Engraver::do_announces, UP);
}
- recurse_down_translators (daddy_context_, &Translator::stop_translation_timestep, true);
+ recurse_down_translators (daddy_context_, &Translator::stop_translation_timestep, UP);
}
void
{
audio_column_ = new Audio_column (m);
play_element (audio_column_);
- recurse_down_translators (daddy_context_, &Translator::start_translation_timestep, true);
+ recurse_down_translators (daddy_context_, &Translator::start_translation_timestep, UP);
}
void
Score_performer::one_time_step ()
{
- recurse_down_performers (daddy_context_, &Performer::process_music, false);
- recurse_down_performers (daddy_context_, &Performer::do_announces, true);
- recurse_down_translators (daddy_context_, &Translator::stop_translation_timestep, false);
+ recurse_down_translators (daddy_context_, &Performer::process_music, UP);
+ recurse_down_translators (daddy_context_, &Performer::do_announces, UP);
+ recurse_down_translators (daddy_context_, &Translator::stop_translation_timestep, UP);
}
int
void
-recurse_down_translators (Context * c, Translator_method ptr, bool context_first)
+recurse_down_translators (Context * c, Translator_method ptr, Direction dir)
{
Translator_group * tg
= dynamic_cast<Translator_group*> (unsmob_translator (c->implementation_));
- if (!context_first)
+ /*
+ Top down:
+ */
+ if (dir == DOWN)
{
translator_each (tg->get_simple_trans_list (),
ptr);
for (SCM s = c->context_list_ ; gh_pair_p (s);
s =gh_cdr (s))
{
- recurse_down_translators (unsmob_context (gh_car (s)), ptr, context_first);
+ recurse_down_translators (unsmob_context (gh_car (s)), ptr, dir);
}
- if (context_first)
+ if (dir == UP)
{
translator_each (tg->get_simple_trans_list (),
ptr);
smobify_self ();
}
+void
+Translator::do_announces ()
+{
+}
+
+void
+Translator::process_music ()
+{
+
+}
+
Translator::Translator ()
{
init ();
\include "scale-definitions-init.ly"
-melisma = \set Staff.melismaBusy = ##t
-melismaEnd = \set Staff.melismaBusy = ##f
-
+melisma = #(make-span-event 'ManualMelismaEvent START)
+melismaEnd = #(make-span-event 'ManualMelismaEvent STOP)
\include "grace-init.ly"
\consists "Chord_tremolo_engraver"
\consists "Percent_repeat_engraver"
\consists "Slash_repeat_engraver"
- \consists "Melisma_engraver"
+ \consists "Melisma_translator"
\consists "Part_combine_engraver"
%{
\consists "Stanza_number_engraver"
\consists "Vocal_name_engraver"
\consists "Skip_event_swallow_translator"
+ \consists "Font_size_engraver"
\override SeparationItem #'padding = #0.2
}
\consists "Note_performer"
\consists "Beam_performer"
\consists "Slur_performer"
- \consists "Melisma_performer"
+ \consists "Melisma_translator"
}
\translator {
))
(MelismaPlayingEvent
. (
- (description . "Used internally to signal melismas")
+ (description . "Used internally to signal melismas.")
(internal-class-name . "Event")
(types . (general-music melisma-playing-event event))
))
+ (ManualMelismaEvent
+ . (
+ (description . "Start or stop a melisma.
+
+Syntax:@code{c4\\melisma d\\melismaEnd}.")
+ (internal-class-name . "Event")
+ (types . (general-music melisma-span-event event))
+ ))
(MultiMeasureRestEvent
. (