2 score-scheme.cc -- implement Score bindings.
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
12 #include "output-def.hh"
13 #include "global-context.hh"
14 #include "lilypond-key.hh"
16 LY_DEFINE (ly_make_score, "ly:make-score",
19 "Return score with @var{music} encapsulated in @var{score}.")
21 Music *mus = unsmob_music (music);
22 SCM_ASSERT_TYPE (mus, music, SCM_ARG1, __FUNCTION__, "music");
24 Score *score = new Score;
25 score->set_music (music);
27 return score->unprotect ();
30 LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
31 2, 1, 0, (SCM score, SCM layout, SCM key),
32 "Run @var{score} through @var{layout}, an output definition, "
33 "scaled to correct output-scale already, "
34 "return a list of layout-lines. "
35 "\nTake optional Object_key argument.")
37 Score *sc = unsmob_score (score);
38 Output_def *od = unsmob_output_def (layout);
43 SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "Score");
44 SCM_ASSERT_TYPE (od, layout, SCM_ARG2, __FUNCTION__, "Output_def");
46 Output_def *score_def = 0;
48 /* UGR, FIXME, these are default \layout blocks once again. They
50 for (vsize i = 0; !score_def && i < sc->defs_.size (); i++)
51 if (sc->defs_[i]->c_variable ("is-layout") == SCM_BOOL_T)
52 score_def = sc->defs_[i];
57 score_def = score_def->clone ();
58 SCM prot = score_def->unprotect ();
60 /* TODO: SCORE_DEF should be scaled according to OD->parent_ or OD
62 score_def->parent_ = od;
64 SCM context = ly_run_translator (sc->get_music (), score_def->self_scm (),
66 SCM output = ly_format_output (context);
68 scm_remember_upto_here_1 (prot);
72 LY_DEFINE (ly_score_process, "ly:score-process",
79 "Print score without page-layout: just print the systems.")
81 Score *score = unsmob_score (score_smob);
83 SCM_ASSERT_TYPE (score, score_smob, SCM_ARG1, __FUNCTION__, "score");
85 // allow header to be undefined.
86 SCM_ASSERT_TYPE (unsmob_output_def (default_paper),
87 default_header, SCM_ARG3, __FUNCTION__, "\\paper block");
88 SCM_ASSERT_TYPE (unsmob_output_def (default_layout),
89 default_header, SCM_ARG4, __FUNCTION__, "\\layout block");
91 Object_key *key = new Lilypond_general_key (0, score->user_key_, 0);
93 if (score->error_found_)
94 return SCM_UNSPECIFIED;
96 SCM header = ly_is_module (score->header_)
100 for (vsize i = 0; i < score->defs_.size (); i++)
101 default_rendering (score->get_music (), score->defs_[i]->self_scm (),
102 default_paper, header, basename, key->self_scm ());
104 if (score->defs_.empty ())
106 default_rendering (score->get_music (),
109 header, basename, key->self_scm ());
113 return SCM_UNSPECIFIED;