* lily/book.cc (process): add -COUNT to midi output.
* lily/score.cc (book_rendering): remove outname argument
(book_rendering): return list of Music_outputs.
* lily/global-context-scheme.cc (LY_DEFINE): remove outname argument.
* lily/book.cc (process): loop over Music_outputs returned from Score::book_rendering().
* lily/include/music-output.hh (class Music_output): smobify class.
* lily/include/paper-score.hh (class Paper_score): make members private.
* lily/performance.cc (process): return #f iso. #<undefined>. This
prevents #<undefined> leaking into GUILE-userspace.
2005-04-18 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/include/paper-score.hh (class Paper_score): remove unused prototypes.
+
+ * lily/book.cc (process): add -COUNT to midi output.
+
+ * lily/score.cc (book_rendering): remove outname argument
+ (book_rendering): return list of Music_outputs.
+
+ * lily/global-context-scheme.cc (LY_DEFINE): remove outname argument.
+
+ * lily/book.cc (process): loop over Music_outputs returned from Score::book_rendering().
+
+ * lily/*.cc (width_callback): remove spurious "unused" warnings
+ for assert (axis==[XY]_AXIS);
+
+ * lily/include/music-output.hh (class Music_output): smobify class.
+
+ * lily/include/paper-score.hh (class Paper_score): make members private.
+
* lily/performance.cc (process): return #f iso. #<undefined>. This
prevents #<undefined> leaking into GUILE-userspace.
Arpeggio::width_callback (SCM smob, SCM axis)
{
Grob *me = unsmob_grob (smob);
- Axis a = (Axis)scm_to_int (axis);
- assert (a == X_AXIS);
+ (void) axis;
+
+ assert (scm_to_int (axis) == X_AXIS);
Stencil arpeggio = Font_interface::get_default_font (me)->find_by_name ("scripts.arpeggio");
return ly_interval2scm (arpeggio.extent (X_AXIS));
Beam::rest_collision_callback (SCM element_smob, SCM axis)
{
Grob *rest = unsmob_grob (element_smob);
- Axis a = (Axis) scm_to_int (axis);
+ (void) axis;
if (scm_is_number (rest->get_property ("staff-position")))
return scm_int2num (0);
- assert (a == Y_AXIS);
+ assert (scm_to_int (axis) == Y_AXIS);
Grob *st = unsmob_grob (rest->get_property ("stem"));
Grob *stem = st;
#include "text-item.hh"
#include "warn.hh"
+#include "performance.hh"
+#include "paper-score.hh"
+
#include "ly-smobs.icc"
Book::Book ()
paper_book->header_ = header_;
/* Render in order of parsing. */
+ int midi_count = 0;
for (SCM s = scm_reverse (scores_); s != SCM_EOL; s = scm_cdr (s))
{
if (Score *score = unsmob_score (scm_car (s)))
{
- SCM systems = score
- ->book_rendering (outname, paper_book->paper_, default_def, key);
+ SCM outputs = score
+ ->book_rendering (paper_book->paper_, default_def, key);
- /* If the score is empty, generate no output. Should we do
- titling? */
- if (scm_is_vector (systems))
+ while (scm_is_pair (outputs))
{
- if (ly_c_module_p (score->header_))
- paper_book->add_score (score->header_);
- paper_book->add_score (systems);
+ Music_output *output = unsmob_music_output (scm_car (outputs));
+
+ if (Performance *perf = dynamic_cast<Performance *> (output))
+ {
+ String fn = outname;
+ if (midi_count)
+ fn += "-" + to_string (midi_count);
+
+ midi_count ++;
+ perf->write_output (fn);
+ }
+ else if (Paper_score *pscore = dynamic_cast<Paper_score *> (output))
+ {
+ SCM systems = pscore->get_systems ();
+ if (ly_c_module_p (score->header_))
+ paper_book->add_score (score->header_);
+ paper_book->add_score (systems);
+ }
+
+ outputs = scm_cdr (outputs);
}
}
else if (Text_interface::markup_p (scm_car (s)))
Array<int>
Break_algorithm::find_break_indices () const
{
- Link_array<Grob> all = pscore_->system_->columns ();
+ Link_array<Grob> all = pscore_->root_system ()->columns ();
Array<int> retval;
for (int i = 0; i < all.size (); i++)
Link_array<Grob>
Break_algorithm::find_breaks () const
{
- Link_array<Grob> all = pscore_->system_->columns ();
+ Link_array<Grob> all = pscore_->root_system ()->columns ();
Link_array<Grob> retval;
for (int i = 0; i < all.size (); i++)
Break_algorithm::set_pscore (Paper_score *s)
{
pscore_ = s;
- linewidth_ = s->layout_->get_dimension (ly_symbol2scm ("linewidth"));
+ linewidth_ = s->layout ()->get_dimension (ly_symbol2scm ("linewidth"));
}
Array<Column_x_positions>
Break_align_interface::self_align_callback (SCM element_smob, SCM axis)
{
Grob *me = unsmob_grob (element_smob);
- Axis a = (Axis) scm_to_int (axis);
- assert (a == X_AXIS);
+ (void) axis;
+ assert (scm_to_int (axis) == X_AXIS);
Item *item = dynamic_cast<Item *> (me);
Direction bsd = item->break_status_dir ();
Dot_column::force_shift_callback (SCM element_smob, SCM axis)
{
Grob *me = unsmob_grob (element_smob);
- Axis a = (Axis) scm_to_int (axis);
- assert (a == Y_AXIS);
+ (void) axis;
+ assert (scm_to_int (axis) == Y_AXIS);
me = me->get_parent (X_AXIS);
if (!to_boolean (me->get_property ("positioning-done")))
Dot_column::side_position (SCM element_smob, SCM axis)
{
Grob *me = unsmob_grob (element_smob);
- Axis a = (Axis) scm_to_int (axis);
- assert (a == X_AXIS);
+ (void) axis;
+ assert (scm_to_int (axis) == X_AXIS);
Grob *stem = unsmob_grob (me->get_property ("stem"));
if (stem
#include "main.hh"
LY_DEFINE (ly_format_output, "ly:format-output",
- 2, 0, 0, (SCM context, SCM outname),
+ 1, 0, 0, (SCM context),
"Given a Global context in its final state, "
- "process it and return the (rendered) result.")
+ "process it and return the @code{Music_output} object in its final state.")
{
Global_context *g = dynamic_cast<Global_context *> (unsmob_context (context));
SCM_ASSERT_TYPE (g, context, SCM_ARG1, __FUNCTION__, "Global context");
- SCM_ASSERT_TYPE (scm_is_string (outname), outname, SCM_ARG2, __FUNCTION__, "output file name");
Music_output *output = g->get_output ();
progress_indication ("\n");
-
- /* ugh, midi still wants outname */
- return output->process (ly_scm2string (outname));
+ output->process ();
+ return output->self_scm ();
}
LY_DEFINE (ly_run_translator, "ly:run-translator",
{
Array<Break_node> optimal_paths;
Link_array<Grob> all
- = pscore_->system_->columns ();
+ = pscore_->root_system ()->columns ();
Array<int> breaks = find_break_indices ();
Break_node first_node;
optimal_paths.push (first_node);
- bool ragged_right = to_boolean (pscore_->layout_->c_variable ("raggedright"));
- bool ragged_last = to_boolean (pscore_->layout_->c_variable ("raggedlast"));
+ bool ragged_right = to_boolean (pscore_->layout ()->c_variable ("raggedright"));
+ bool ragged_last = to_boolean (pscore_->layout ()->c_variable ("raggedlast"));
Real worst_force = 0.0;
for (int break_idx = 1; break_idx < breaks.size (); break_idx++)
cp.cols_ = line;
Interval line_dims
- = line_dimensions_int (pscore_->layout_, optimal_paths[start_idx].line_);
+ = line_dimensions_int (pscore_->layout (), optimal_paths[start_idx].line_);
Simple_spacer_wrapper *sp = generate_spacing_problem (line, line_dims);
bool last_line = break_idx == breaks.size () - 1;
bool ragged = ragged_right
Output_def *
Grob::get_layout () const
{
- return pscore_ ? pscore_->layout_ : 0;
+ return pscore_ ? pscore_->layout () : 0;
}
/* Recursively track all dependencies of this Grob. The status_ field
if (s->original_)
scm_gc_mark (s->original_->self_scm ());
- if (s->pscore_ && s->pscore_->layout_)
- scm_gc_mark (s->pscore_->layout_->self_scm ());
+ if (s->pscore_ && s->pscore_->layout ())
+ scm_gc_mark (s->pscore_->layout ()->self_scm ());
s->do_derived_mark ();
return s->mutable_property_alist_;
Hara_kiri_group_spanner::y_extent (SCM element_smob, SCM scm_axis)
{
Grob *me = unsmob_grob (element_smob);
- Axis a = (Axis) scm_to_int (scm_axis);
+ (void) scm_axis;
- assert (a == Y_AXIS);
+ assert (scm_to_int (scm_axis) == Y_AXIS);
consider_suicide (me);
return Axis_group_interface::group_extent_callback (me->self_scm (), scm_axis);
}
Hara_kiri_group_spanner::force_hara_kiri_callback (SCM element_smob, SCM axis)
{
Grob *me = unsmob_grob (element_smob);
- Axis a = (Axis) scm_to_int (axis);
- assert (a == Y_AXIS);
+ (void) axis;
+
+ assert (scm_to_int (axis) == Y_AXIS);
consider_suicide (me);
return scm_make_real (0.0);
}
Moment now_mom_;
};
-SCM ly_format_output (SCM, SCM);
+SCM ly_format_output (SCM);
#endif // GLOBAL_CONTEXT_HH
#include "string.hh"
#include "lily-proto.hh"
#include "protected-scm.hh"
+#include "smobs.hh"
class Music_output
{
+ DECLARE_SMOBS(Music_output, foo);
+
+protected:
+ Music_output ();
+
public:
- virtual SCM process (String);
- virtual ~Music_output ();
+ virtual void derived_mark () const;
+ virtual void process ();
};
+DECLARE_UNSMOB (Music_output, music_output);
+
#endif /* MUSIC_OUTPUT_HH */
/* LAYOUT output */
class Paper_score : public Music_output
{
-public:
Output_def *layout_;
System *system_;
+ SCM systems_;
- Paper_score ();
+public:
+ Paper_score (Output_def *);
- int find_col_idx (Paper_column const *) const;
- Link_array<Item> broken_col_range (Item const *, Item const *) const;
- void typeset_line (System *);
- void output ();
+ Output_def *layout () const;
+ System *root_system () const;
+
+ void typeset_system (System *);
+ Array<Column_x_positions> calc_breaking ();
+ SCM get_systems () const;
protected:
- virtual SCM process (String);
+ virtual void process ();
+ virtual void derived_mark () const;
private:
- Protected_scm systems_;
-
- void preprocess ();
- void calc_idealspacing ();
- Array<Column_x_positions> calc_breaking ();
- void postprocess ();
Paper_score (Paper_score const &);
};
void output_header_track (Midi_stream &midi_stream_r);
void print () const;
- SCM process (String);
+ void write_output (String filename);
Link_array<Audio_staff> audio_staffs_;
Cons<Audio_element> *audio_element_list_;
SCM get_music () const;
void set_music (SCM music, SCM parser);
- SCM book_rendering (String, Output_def *, Output_def *, Object_key *);
+ SCM book_rendering (Output_def *, Output_def *, Object_key *);
};
DECLARE_UNSMOB (Score, score);
public:
int rank_;
void post_processing ();
- SCM get_line ();
- SCM get_lines ();
+ SCM get_paper_system ();
+ SCM get_paper_systems ();
System (SCM, Object_key const *);
System (System const &, int);
{
Grob *dolly = clone (count++);
Item *item = dynamic_cast<Item *> (dolly);
- pscore_->system_->typeset_grob (item);
+ pscore_->root_system ()->typeset_grob (item);
new_copies[i] = item;
}
while (flip (&i) != LEFT);
*/
#include "music-output.hh"
+#include "ly-smobs.icc"
-/*
- Just stubs.
- */
-SCM
+Music_output::Music_output ()
+{
+ smobify_self ();
+}
+
+void
Music_output::process ()
{
- return SCM_EOL;
}
Music_output::~Music_output ()
}
+void
+Music_output::derived_mark () const
+{
+}
+
+IMPLEMENT_SMOBS (Music_output);
+IMPLEMENT_DEFAULT_EQUAL_P (Music_output);
+IMPLEMENT_TYPE_P (Music_output, "ly:score?");
+
+SCM
+Music_output::mark_smob (SCM s)
+{
+ Music_output *sc = (Music_output *) SCM_CELL_WORD_1 (s);
+
+ sc->derived_mark ();
+ return SCM_EOL;
+}
+
+int
+Music_output::print_smob (SCM, SCM p, scm_print_state*)
+{
+ scm_puts ("#<Music_output>", p);
+
+ return 1;
+}
#include "system.hh"
#include "warn.hh"
-Paper_score::Paper_score ()
+Paper_score::Paper_score (Output_def *layout)
{
- layout_ = 0;
+ layout_ = layout;
system_ = 0;
+ systems_ = SCM_EOL;
}
Paper_score::Paper_score (Paper_score const &s)
assert (false);
}
+
+void
+Paper_score::derived_mark () const
+{
+ scm_gc_mark (systems_);
+}
+
void
-Paper_score::typeset_line (System *system)
+Paper_score::typeset_system (System *system)
{
if (!system_)
system_ = system;
return sol;
}
-SCM
-Paper_score::process (String)
+void
+Paper_score::process ()
{
if (be_verbose_global)
message (_f ("Element count %d (spanners %d) ",
Array<Column_x_positions> breaking = calc_breaking ();
system_->break_into_pieces (breaking);
- SCM lines = system_->get_lines ();
-
- /*
- retain Grobs, since they are pointed to by the point & click data
- structures, and are not marked fully, because child -> parent
- links aren't marked.
- */
- return lines;
+ system_->get_paper_systems ();
+}
+
+System *
+Paper_score::root_system () const
+{
+ return system_;
+}
+
+Output_def *
+Paper_score::layout () const
+{
+ return layout_;
+}
+
+
+SCM
+Paper_score::get_systems () const
+{
+ return root_system ()->get_paper_systems ();
}
audio_element_list_ = new Killing_cons<Audio_element> (p, audio_element_list_);
}
-SCM
-Performance::process (String out)
+
+void
+Performance::write_output (String out)
{
if (out == "-")
out = "lelie.midi";
output (midi_stream);
progress_indication ("\n");
- return SCM_BOOL_F;
}
+ _ ("Aborting"));
}
- pscore_ = new Paper_score;
- pscore_->layout_ = dynamic_cast<Output_def *> (get_output_def ());
+ pscore_ = new Paper_score (dynamic_cast<Output_def *> (get_output_def ()));
SCM props = updated_grob_properties (context (), ly_symbol2scm ("System"));
Object_key const *sys_key = context ()->get_grob_key ("System");
- pscore_->typeset_line (new System (props, sys_key));
+ pscore_->typeset_system (new System (props, sys_key));
- system_ = pscore_->system_;
+ system_ = pscore_->root_system ();
make_columns ();
system_->set_bound (LEFT, command_column_);
command_column_->set_property ("breakable", SCM_BOOL_T);
Score_engraver::announce_grob (Grob_info info)
{
announce_infos_.push (info);
- pscore_->system_->typeset_grob (info.grob_);
+ pscore_->root_system ()->typeset_grob (info.grob_);
elems_.push (info.grob_);
}
SCM context = ly_run_translator (sc->get_music (), score_def->self_scm (),
key);
- SCM lines = ly_format_output (context, scm_makfrom0str ("<embedded>"));
+ SCM lines = ly_format_output (context);
scm_remember_upto_here_1 (prot);
return lines;
if (Global_context *g = dynamic_cast<Global_context *>
(unsmob_context (context)))
{
- SCM systems = ly_format_output (context, outname);
+ SCM systems = ly_format_output (context);
Music_output *output = g->get_output ();
if (systems != SCM_UNDEFINED)
{
paper_book->classic_output (ly_scm2string (outname));
scm_gc_unprotect_object (paper_book->self_scm ());
}
- delete output;
+ scm_gc_unprotect_object (output->self_scm ());
}
scm_remember_upto_here_1 (scaled_def);
}
/*
- Format score, return systems. OUTNAME is still passed to create a midi
- file.
+ Format score, return list of Music_output objects.
LAYOUTBOOK should be scaled already.
*/
SCM
-Score::book_rendering (String outname,
- Output_def *layoutbook,
+Score::book_rendering (Output_def *layoutbook,
Output_def *default_def,
Object_key *book_key)
{
if (layoutbook && layoutbook->c_variable ("is-paper") == SCM_BOOL_T)
scale = scm_to_double (layoutbook->c_variable ("outputscale"));
- SCM out = scm_makfrom0str (outname.to_str0 ());
- SCM systems = SCM_EOL;
+ SCM outputs = SCM_EOL;
+ SCM *tail = &outputs;
+
int outdef_count = defs_.size ();
Object_key *key = new Lilypond_general_key (book_key, user_key_, 0);
{
Output_def *def = outdef_count ? defs_[i] : default_def;
SCM scaled = SCM_EOL;
+
if (def->c_variable ("is-layout") == SCM_BOOL_T)
{
def = scale_output_def (def, scale);
SCM context = ly_run_translator (music_, def->self_scm (), scm_key);
if (dynamic_cast<Global_context *> (unsmob_context (context)))
{
- SCM s = ly_format_output (context, out);
- if (s != SCM_UNDEFINED)
- systems = s;
+ SCM s = ly_format_output (context);
+
+ *tail = scm_cons (s, SCM_EOL);
+ tail = SCM_CDRLOC(*tail);
}
scm_remember_upto_here_1 (scaled);
scm_remember_upto_here_1 (scm_key);
scm_remember_upto_here_1 (scaled_bookdef);
- return systems;
+ return outputs;
}
void
/*
can't use get_system() ? --hwn.
*/
- Link_array<Grob> all (me->pscore_->system_->columns ());
+ Link_array<Grob> all (me->pscore_->root_system ()->columns ());
set_explicit_neighbor_columns (all);
}
else
{
- Link_array<Item> break_points = pscore_->system_->broken_col_range (left, right);
+ Link_array<Item> break_points = pscore_->root_system ()->broken_col_range (left, right);
break_points.insert (left, 0);
break_points.push (right);
}
SCM
-System::get_lines ()
+System::get_paper_systems ()
{
for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s))
{
System *system = dynamic_cast<System *> (broken_intos_[i]);
system->post_processing ();
- scm_vector_set_x (lines, scm_int2num (i), system->get_line ());
+ scm_vector_set_x (lines, scm_int2num (i), system->get_paper_system ());
if (be_verbose_global)
progress_indication (to_string (i) + "]");
system->rank_ = i;
Link_array<Grob> c (breaking[i].cols_);
- pscore_->typeset_line (system);
+ pscore_->typeset_system (system);
system->set_bound (LEFT, c[0]);
system->set_bound (RIGHT, c.top ());
}
SCM
-System::get_line ()
+System::get_paper_system ()
{
static int const LAYER_COUNT = 3;