-LY_DEFINE (ly_format_output, "ly:format-output",
- 2, 0, 0, (SCM context, SCM outname),
- "Given a Score context in its final state,"
- "process it and return the (rendered) result.")
-{
- 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 filename");
-
- Music_output *output = g->get_output ();
- progress_indication ("\n");
- /* ugh, midi still wants outname */
- return output->process (ly_scm2string (outname));
-}
-
-void
-default_rendering (SCM music, SCM outdef,
- SCM book_outputdef,
- SCM header, SCM outname)
-{
- SCM scaled_def = outdef;
- SCM scaled_bookdef = book_outputdef;
-
- Output_def *bpd = unsmob_output_def (book_outputdef);
-
- /* ugh. */
- if (bpd->c_variable ("is-bookpaper") == SCM_BOOL_T)
- {
- Real scale = scm_to_double (bpd->c_variable ("outputscale"));
-
- Output_def *def = scale_output_def (unsmob_output_def (outdef), scale);
- scaled_def = def->self_scm ();
-
- scaled_bookdef = scale_output_def (bpd, scale)->self_scm ();
- unsmob_output_def (scaled_def)->parent_
- = unsmob_output_def (scaled_bookdef);
-
- scm_gc_unprotect_object (scaled_bookdef);
- scm_gc_unprotect_object (scaled_def);
- }
-
- SCM context = ly_run_translator (music, scaled_def);
- if (Global_context *g = dynamic_cast<Global_context*>
- (unsmob_context (context)))
- {
- SCM systems = ly_format_output (context, outname);
- Music_output *output = g->get_output ();
- if (systems != SCM_UNDEFINED)
- {
- /* ugh, this is strange, Paper_book without a Book object. */
- Paper_book *paper_book = new Paper_book ();
- paper_book->header_ = header;
- paper_book->bookpaper_ = unsmob_output_def (scaled_bookdef);
-
- Score_systems sc;
- sc.systems_ = systems;
- sc.header_ = header;
-
- paper_book->score_systems_.push (sc);
-
- paper_book->classic_output (ly_scm2string (outname));
- scm_gc_unprotect_object (paper_book->self_scm ());
- }
- delete output;
- }
-
- scm_remember_upto_here_1 (scaled_def);
- scm_remember_upto_here_1 (scaled_bookdef);
-}