2 score-scheme.cc -- implement Score bindings.
4 source file of the GNU LilyPond music typesetter
6 (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
12 #include "output-def.hh"
13 #include "global-context.hh"
14 #include "lilypond-key.hh"
17 LY_DEFINE (ly_make_score, "ly:make-score",
20 "Return score with @var{music} encapsulated in @var{score}.")
22 Music *mus = unsmob_music (music);
23 SCM_ASSERT_TYPE (mus, music, SCM_ARG1, __FUNCTION__, "music");
25 Score *score = new Score;
26 score->set_music (music);
28 return score->unprotect ();
31 LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
32 2, 1, 0, (SCM score, SCM layout, SCM key),
33 "Run @var{score} through @var{layout}, an output definition, "
34 "scaled to correct outputscale already, "
35 "return a list of layout-lines. "
36 "\nTake optional Object_key argument.")
38 Score *sc = unsmob_score (score);
39 Output_def *od = unsmob_output_def (layout);
44 SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "Score");
45 SCM_ASSERT_TYPE (od, layout, SCM_ARG2, __FUNCTION__, "Output_def");
47 Output_def *score_def = 0;
49 /* UGR, FIXME, these are default \layout blocks once again. They
51 for (int i = 0; !score_def && i < sc->defs_.size (); i++)
52 if (sc->defs_[i]->c_variable ("is-layout") == SCM_BOOL_T)
53 score_def = sc->defs_[i];
58 score_def = score_def->clone ();
59 SCM prot = score_def->unprotect ();
61 /* TODO: SCORE_DEF should be scaled according to OD->parent_ or OD
63 score_def->parent_ = od;
65 SCM context = ly_run_translator (sc->get_music (), score_def->self_scm (),
67 SCM output = ly_format_output (context);
69 scm_remember_upto_here_1 (prot);
73 LY_DEFINE (ly_score_process, "ly:score-process",
80 "Print score without page-layout: just print the systems.")
82 Score *score = unsmob_score (score_smob);
84 SCM_ASSERT_TYPE (score, score_smob, SCM_ARG1, __FUNCTION__, "score");
86 // allow header to be undefined.
87 SCM_ASSERT_TYPE (unsmob_output_def (default_paper),
88 default_header, SCM_ARG3, __FUNCTION__, "\\paper block");
89 SCM_ASSERT_TYPE (unsmob_output_def (default_layout),
90 default_header, SCM_ARG4, __FUNCTION__, "\\layout block");
92 Object_key *key = new Lilypond_general_key (0, score->user_key_, 0);
94 if (score->error_found_)
95 return SCM_UNSPECIFIED;
97 SCM header = ly_is_module (score->header_)
101 for (int i = 0; i < score->defs_.size (); i++)
102 default_rendering (score->get_music (), score->defs_[i]->self_scm (),
103 default_paper, header, basename, key->self_scm ());
105 if (score->defs_.is_empty ())
107 default_rendering (score->get_music (),
110 header, basename, key->self_scm ());
114 return SCM_UNSPECIFIED;