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 SCM self = score->self_scm ();
29 scm_gc_unprotect_object (self);
33 LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
34 2, 1, 0, (SCM score, SCM layout, SCM key),
35 "Run @var{score} through @var{layout}, an output definition, "
36 "scaled to correct outputscale already, "
37 "return a list of layout-lines. "
38 "\nTake optional Object_key argument.")
40 Score *sc = unsmob_score (score);
41 Output_def *od = unsmob_output_def (layout);
46 SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "Score");
47 SCM_ASSERT_TYPE (od, layout, SCM_ARG2, __FUNCTION__, "Output_def");
49 Output_def *score_def = 0;
51 /* UGR, FIXME, these are default \layout blocks once again. They
53 for (int i = 0; !score_def && i < sc->defs_.size (); i++)
54 if (sc->defs_[i]->c_variable ("is-layout") == SCM_BOOL_T)
55 score_def = sc->defs_[i];
60 score_def = score_def->clone ();
61 SCM prot = score_def->self_scm ();
62 scm_gc_unprotect_object (prot);
64 /* TODO: SCORE_DEF should be scaled according to OD->parent_ or OD
66 score_def->parent_ = od;
68 SCM context = ly_run_translator (sc->get_music (), score_def->self_scm (),
70 SCM output = ly_format_output (context);
72 scm_remember_upto_here_1 (prot);
76 LY_DEFINE (ly_score_process, "ly:score-process",
83 "Print score without page-layout: just print the systems.")
85 Score *score = unsmob_score (score_smob);
87 SCM_ASSERT_TYPE (score, score_smob, SCM_ARG1, __FUNCTION__, "score");
89 // allow header to be undefined.
90 SCM_ASSERT_TYPE (unsmob_output_def (default_paper),
91 default_header, SCM_ARG3, __FUNCTION__, "\\paper block");
92 SCM_ASSERT_TYPE (unsmob_output_def (default_layout),
93 default_header, SCM_ARG4, __FUNCTION__, "\\layout block");
94 SCM_ASSERT_TYPE (scm_is_string (basename),
95 default_header, SCM_ARG5, __FUNCTION__, "basename");
97 Object_key *key = new Lilypond_general_key (0, score->user_key_, 0);
99 if (score->error_found_)
100 return SCM_UNSPECIFIED;
102 SCM header = ly_is_module (score->header_)
106 for (int i = 0; i < score->defs_.size (); i++)
107 default_rendering (score->get_music (), score->defs_[i]->self_scm (),
108 default_paper, header, basename, key->self_scm ());
110 if (score->defs_.is_empty ())
112 default_rendering (score->get_music (),
115 header, basename, key->self_scm ());
118 scm_gc_unprotect_object (key->self_scm ());
119 return SCM_UNSPECIFIED;