- Music *m =unsmob_music (s.music_);
- music_ = m ? m->clone ()->self_scm () : SCM_EOL;
- scm_gc_unprotect_object (music_);
-
- for (int i = 0; i < s.defs_.size (); i++)
- defs_.push (s.defs_[i]->clone ());
-
- header_ = ly_make_anonymous_module (false);
- if (ly_c_module_p (s.header_))
- ly_import_module (header_, s.header_);
-}
-
-LY_DEFINE (ly_run_translator, "ly:run-translator",
- 2, 0, 0, (SCM mus, SCM output_def),
- "Process @var{mus} according to @var{output_def}. "
- "An interpretation context is set up, "
- "and @var{mus} is interpreted with it. "
- "The context is returned in its final state.")
-{
- Output_def *odef = unsmob_output_def (output_def);
- Music *music = unsmob_music (mus);
-
- SCM_ASSERT_TYPE (music, mus, SCM_ARG1, __FUNCTION__, "Music");
- SCM_ASSERT_TYPE (odef, output_def, SCM_ARG2, __FUNCTION__, "Output definition");
-
- Cpu_timer timer;
-
- Global_context * trans = new Global_context (odef, music->get_length ());
-
- if (!trans)
- {
- programming_error ("no toplevel translator");
- return SCM_BOOL_F;
- }
- progress_indication (_ ("Interpreting music... "));
-
- SCM protected_iter = Music_iterator::get_static_get_iterator (music);
- Music_iterator * iter = unsmob_iterator (protected_iter);
- iter->init_translator (music, trans);
-
- iter->construct_children ();
-
- if (!iter->ok ())
- {
- warning (_ ("Need music in a score"));
- /* todo: should throw exception. */
- return SCM_BOOL_F;
- }
-
- trans->run_iterator_on_me (iter);
- iter->quit ();
- scm_remember_upto_here_1 (protected_iter);
- trans->finish ();
-
- if (verbose_global_b)
- progress_indication (_f ("elapsed time: %.2f seconds", timer.read ()));
-
- return scm_gc_unprotect_object (trans->self_scm ());
-}
-
-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 (ly_c_string_p (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)