2 score-scheme.cc -- implement Score bindings.
4 source file of the GNU LilyPond music typesetter
6 (c) 2005--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
12 #include "output-def.hh"
13 #include "global-context.hh"
14 #include "lilypond-key.hh"
15 #include "music-output.hh"
16 #include "paper-score.hh"
17 #include "paper-book.hh"
19 LY_DEFINE (ly_make_score, "ly:make-score",
22 "Return score with @var{music} encapsulated in @var{score}.")
24 Music *mus = unsmob_music (music);
25 SCM_ASSERT_TYPE (mus, music, SCM_ARG1, __FUNCTION__, "music");
27 Score *score = new Score;
28 score->set_music (music);
30 return score->unprotect ();
33 LY_DEFINE (ly_score_output_defs, "ly:score-output-defs",
35 "All output defs in a score.")
37 Score *sc = unsmob_score (score);
38 SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
41 for (vsize i = 0; i < sc->defs_.size (); i++)
42 l = scm_cons (sc->defs_[i]->self_scm(), l);
43 return scm_reverse_x (l, SCM_EOL);
48 LY_DEFINE (ly_score_header, "ly:score-header",
50 "return score header.")
52 Score *sc = unsmob_score (score);
53 SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
58 LY_DEFINE (ly_score_music, "ly:score-music",
60 "return score music.")
62 Score *sc = unsmob_score (score);
63 SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
64 return sc->get_music ();
67 LY_DEFINE (ly_score_error_p, "ly:score-error?",
69 "Was there an error in the score?")
71 Score *sc = unsmob_score (score);
72 SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
73 return scm_from_bool (sc->error_found_);
76 LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
77 2, 1, 0, (SCM score, SCM layout, SCM key),
78 "Run @var{score} through @var{layout}, an output definition, "
79 "scaled to correct output-scale already, "
80 "return a list of layout-lines. "
81 "\nTake optional Object_key argument.")
83 Score *sc = unsmob_score (score);
84 Output_def *od = unsmob_output_def (layout);
89 SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "Score");
90 SCM_ASSERT_TYPE (od, layout, SCM_ARG2, __FUNCTION__, "Output_def");
92 Output_def *score_def = 0;
94 /* UGR, FIXME, these are default \layout blocks once again. They
96 for (vsize i = 0; !score_def && i < sc->defs_.size (); i++)
97 if (sc->defs_[i]->c_variable ("is-layout") == SCM_BOOL_T)
98 score_def = sc->defs_[i];
103 score_def = score_def->clone ();
104 SCM prot = score_def->unprotect ();
106 /* TODO: SCORE_DEF should be scaled according to OD->parent_ or OD
108 score_def->parent_ = od;
110 SCM context = ly_run_translator (sc->get_music (), score_def->self_scm (),
112 SCM output = ly_format_output (context);
114 scm_remember_upto_here_1 (prot);