return SCM.
* lily/paper-book.cc (classic_output, get_title, get_scopes): New
method.
* lily/paper-score.cc (process): Return stencils rather than
outputting directly. Remove paper-book kludge. Delete grobs.
(output): Remove.
* lily/include/paper-score.hh (class Paper_score): Remove outputter_.
* lily/score-engraver.cc (get_output): Do not reset pscore_.
* lily/score.cc (default_rendering)
(ly_render_output): Move adding paper-score two levels up.
+2004-03-09 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * lily/include/music-output.hh (process): Change signature to
+ return SCM.
+
+ * lily/paper-book.cc (classic_output, get_title, get_scopes): New
+ method.
+
+ * lily/paper-score.cc (process): Return stencils rather than
+ outputting directly. Remove paper-book kludge. Delete grobs.
+ (output): Remove.
+
+ * lily/include/paper-score.hh (class Paper_score): Remove outputter_.
+
+ * lily/score-engraver.cc (get_output): Do not reset pscore_.
+
+ * lily/score.cc (default_rendering)
+ (ly_render_output): Move adding paper-score two levels up.
+
+ * lily/system.cc (get_line):
+ * lily/paper-outputter.cc (output_line): Fix `between-system-string'.
+
2004-03-09 Han-Wen Nienhuys <hanwen@xs4all.nl>
* scm/font.scm (paper20-font-vector): add more design sizes for
* scm/font.scm (paper20-font-vector): bugfix: use din12, not 10
for 12pt design size.
-2004-03-09 Jan Nieuwenhuizen <janneke@gnu.org>
-
- * lily/system.cc (get_line):
- * lily/paper-outputter.cc (output_line): Fix `between-system-string'.
-
2004-03-09 Han-Wen Nienhuys <hanwen@xs4all.nl>
* ly/engraver-init.ly: don't remove slur engraver from DrumVoice.
class Music_sequence;
class Music_wrapper;
class Music_wrapper_iterator;
+class Page;
class Pitch;
class My_lily_lexer;
class Note_performer;
*/
-#ifndef Music_output_HH
-#define Music_output_HH
+#ifndef MUSIC_OUTPUT_HH
+#define MUSIC_OUTPUT_HH
#include "string.hh"
#include "lily-proto.hh"
#include "protected-scm.hh"
-/**
- Output something that was defined in a lilypond file.
- */
class Music_output
{
public:
- Protected_scm header_;
-
- virtual void process (String) {}
- virtual ~Music_output (){}
- Music_output ()
- {
- }
-
+ virtual SCM process (String) {return SCM_EOL;}
+ virtual ~Music_output () {}
};
-#endif // Music_output_HH
+
+#endif /* MUSIC_OUTPUT_HH */
#ifndef PAPER_BOOK_HH
#define PAPER_BOOK_HH
-//#define PAGE_LAYOUT 1
+// #define PAGE_LAYOUT 1
+#include "lily-guile.hh"
#include "parray.hh"
-class Page;
+#include "protected-scm.hh"
class Paper_book
{
public:
- Link_array<Paper_score> paper_scores_;
- Paper_book ();
+ Array<SCM> headers_;
+ Link_array<Paper_def> papers_;
+ Array<SCM> scores_;
+ Paper_book ();
Link_array<Page> *get_pages ();
- void output ();
+ SCM get_scopes (int);
+ Stencil* get_title (int);
+ void output (String);
+ void classic_output (String);
};
#endif /* PAPER_BOOK_HH */
(c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
-#ifndef P_SCORE_HH
-#define P_SCORE_HH
+#ifndef PAPER_SCORE_HH
+#define PAPER_SCORE_HH
#include "column-x-positions.hh"
#include "parray.hh"
#include "lily-guile.hh"
#include "protected-scm.hh"
-/** all stuff which goes onto paper. notes, signs, symbols in a score
- #Paper_score# contains the items, the columns.
-
- */
+/* PAPER output */
class Paper_score : public Music_output
{
- Protected_scm main_smob_;
public:
Paper_def *paper_;
-
- /* Vector with lines of stencils. */
- Protected_scm lines_;
- Stencil *book_title_;
- Stencil *score_title_;
-
- Paper_outputter *outputter_;
System *system_;
Paper_score ();
- /**
- @return index of argument.
- */
int find_col_idx (Paper_column const *) const;
-
- Link_array<Item> broken_col_range (Item const*,Item const*) const;
+ Link_array<Item> broken_col_range (Item const*, Item const*) const;
void typeset_line (System*);
void output ();
protected:
- /* MAIN ROUTINES */
- virtual void process (String);
+ virtual SCM process (String);
+
private:
- /// before calc_breaking
+ Protected_scm score_;
+
void preprocess ();
void calc_idealspacing ();
- /// calculate where the lines are to be broken, and use results
Array<Column_x_positions> calc_breaking ();
-
- /// after calc_breaking
void postprocess ();
Paper_score (Paper_score const &);
};
-#endif
+#endif /* PAPER_SCORE_HH */
#include "cons.hh"
#include "music-output.hh"
-/** all stuff which goes onto midi. notes, signs, symbols in a score
- #Performance# contains the items, the columns.
- */
-
-class Performance : public Music_output {
+/* MIDI output. */
+class Performance : public Music_output
+{
public:
Performance ();
~Performance ();
void output_header_track (Midi_stream& midi_stream_r);
void print () const;
- void process (String);
+ SCM process (String);
Link_array<Audio_staff> audio_staffs_;
Cons<Audio_element> *audio_elem_p_list_;
- Midi_def * midi_;
+ Midi_def *midi_;
};
-#endif // PERFORMANCE_HH
+#endif /* PERFORMANCE_HH */
(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
#ifndef SCORE_HH
#define SCORE_HH
Score ();
Score (Score const&);
DECLARE_SMOBS (Score,foo);
-private:
};
-DECLARE_UNSMOB(Score,score);
+DECLARE_UNSMOB (Score,score);
SCM ly_run_translator (SCM, SCM);
-SCM ly_render_output (SCM, SCM, SCM);
+SCM ly_render_output (SCM, SCM);
void default_rendering (SCM,SCM,SCM,SCM);
-#endif
+
+#endif /* SCORE_HH */
return;
}
- static SCM proc;
+ static SCM proc;
if (!proc)
proc = scm_c_eval_string ("dump-gc-protects");
-#ifdef PAGE_LAYOUT
Paper_book book;
paper_book = &book;
-#endif
Input_file_results inp_file (init, in_file, out_file);
#ifdef PAGE_LAYOUT
- book.output ();
+ book.output (out_file);
#endif
}
#include <stdio.h>
+#include "input-file-results.hh"
+#include "ly-module.hh"
#include "main.hh"
#include "paper-book.hh"
-#include "paper-score.hh"
#include "paper-def.hh"
-#include "stencil.hh"
#include "paper-outputter.hh"
+#include "paper-score.hh"
+#include "stencil.hh"
-// -- this simply adds one Page per \score
-// #define ONE_SCORE_PER_PAGE
-
// WIP -- simplistic page interface
// Do we need this at all? SCM, smob?
class Page
void
Page::output (Paper_outputter *out, bool is_last)
{
-#if ONE_SCORE_PER_PAGE
- int line_count = SCM_VECTOR_LENGTH ((SCM) lines_);
- for (int i = 0; i < line_count; i++)
- out->output_line (scm_vector_ref (lines_, scm_int2num (i)),
- is_last && i == line_count - 1);
-#else
// TODO: header/footer etc
out->output_scheme (scm_list_1 (ly_symbol2scm ("start-page")));
for (SCM s = lines_; gh_pair_p (s); s = ly_cdr (s))
out->output_line (ly_car (s), is_last && gh_pair_p (ly_cdr (s)));
out->output_scheme (scm_list_2 (ly_symbol2scm ("stop-page"),
gh_bool2scm (is_last)));
-#endif
}
Real
}
void
-Paper_book::output ()
+Paper_book::output (String outname)
{
- Paper_outputter *out = paper_scores_[0]->outputter_;
-
- Paper_def *paper = paper_scores_[0]->paper_;
- out->output_header (paper);
-
- if (paper_scores_[0]->book_title_)
- out->output_expr (paper_scores_[0]->book_title_->get_expr (),
- Offset (0, 0));
+ Paper_outputter *out = papers_.top ()->get_paper_outputter (outname);
+
+ out->output_metadata (get_scopes (0), papers_.top ());
+ out->output_header (papers_.top ());
Link_array<Page> *pages = get_pages ();
int page_count = pages->size ();
progress_indication ("\n");
}
+SCM
+Paper_book::get_scopes (int i)
+{
+ SCM scopes = SCM_EOL;
+ if (headers_[i])
+ scopes = scm_cons (headers_[i], scopes);
+ if (global_input_file->header_ && global_input_file->header_ != headers_[i])
+ scopes = scm_cons (global_input_file->header_, scopes);
+ return scopes;
+}
+
+Stencil*
+Paper_book::get_title (int i)
+{
+ SCM make_title = scm_primitive_eval (ly_symbol2scm ("make-title"));
+ SCM field = (i == 0 ? ly_symbol2scm ("bookTitle")
+ : ly_symbol2scm ("scoreTitle"));
+
+ SCM s = ly_modules_lookup (get_scopes (i), field);
+ if (s != SCM_UNDEFINED && scm_variable_bound_p (s) == SCM_BOOL_T)
+ return unsmob_stencil (gh_call2 (make_title,
+ papers_[i]->self_scm (),
+ scm_variable_ref (s)));
+ return 0;
+}
+
/*
WIP
Paper_book::get_pages ()
{
Link_array<Page> *pages = new Link_array<Page>;
- Paper_def *paper = paper_scores_[0]->paper_;
- int score_count = paper_scores_.size ();
+ int score_count = scores_.size ();
/* Calculate the full book height. Hmm, can't we cache system
heights while making stencils? */
Real book_height = 0;
for (int i = 0; i < score_count; i++)
{
- Paper_score *pscore = paper_scores_[i];
- Stencil *title = (i == 0 ? pscore->book_title_ : pscore->score_title_);
+ //SCM lines = scores_[i];
+ Stencil *title = get_title (i);
if (title)
book_height += title->extent (Y_AXIS).length ();
- int line_count = SCM_VECTOR_LENGTH ((SCM) pscore->lines_);
+ int line_count = SCM_VECTOR_LENGTH ((SCM) scores_[i]);
for (int j = 0; j < line_count; j++)
{
- SCM line = scm_vector_ref (pscore->lines_, scm_int2num (j));
+ SCM line = scm_vector_ref ((SCM) scores_[i], scm_int2num (j));
book_height += ly_scm2offset (ly_car (line))[Y_AXIS];
}
}
- Page *page = new Page (paper);
+ Page *page = new Page (papers_.top ());
fprintf (stderr, "book_height: %f\n", book_height);
fprintf (stderr, "vsize: %f\n", page->vsize_);
fprintf (stderr, "pages: %f\n", book_height / page->text_height ());
-#if ONE_SCORE_PER_PAGE
- for (int i = 0; i < score_count; i++)
- {
- page->lines_ = paper_scores_[i]->lines_;
- pages->push (page);
- }
-#else
/* Simplistic page breaking. */
Real text_height = page->text_height ();
for (int i = 0; i < score_count; i++)
{
- Paper_score *pscore = paper_scores_[i];
- Stencil *title = (i == 0 ? pscore->book_title_ : pscore->score_title_);
+ Stencil *title = get_title (i);
+ if (title)
+ book_height += title->extent (Y_AXIS).length ();
Real h = 0;
if (title)
h = title->extent (Y_AXIS).length ();
- int line_count = SCM_VECTOR_LENGTH ((SCM) pscore->lines_);
+ int line_count = SCM_VECTOR_LENGTH ((SCM) scores_[i]);
for (int j = 0; j < line_count; j++)
{
- SCM line = scm_vector_ref (pscore->lines_, scm_int2num (j));
+ SCM line = scm_vector_ref ((SCM) scores_[i], scm_int2num (j));
h += ly_scm2offset (ly_car (line))[Y_AXIS];
if (page->height_ + h > text_height)
{
pages->push (page);
- page = new Page (paper);
+ page = new Page (papers_.top ());
}
if (page->height_ + h <= text_height || page->height_ == 0)
{
}
}
}
-#endif
pages->push (page);
return pages;
}
+
+void
+Paper_book::classic_output (String outname)
+{
+ Paper_outputter *out = papers_.top ()->get_paper_outputter (outname);
+ int count = scores_.size ();
+
+ out->output_metadata (get_scopes (count - 1), papers_.top ());
+ out->output_header (papers_.top ());
+
+ int line_count = SCM_VECTOR_LENGTH ((SCM) scores_.top ());
+ for (int i = 0; i < line_count; i++)
+ out->output_line (scm_vector_ref ((SCM) scores_.top (), scm_int2num (i)),
+ i == line_count - 1);
+
+ out->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
+ progress_indication ("\n");
+}
#include "paper-column.hh"
#include "scm-hash.hh"
#include "gourlay-breaking.hh"
-#include "paper-outputter.hh"
+//#include "paper-outputter.hh"
#include "input-file-results.hh"
#include "misc.hh"
#include "all-font-metrics.hh"
Paper_score::Paper_score ()
{
paper_ = 0;
- outputter_ = 0;
system_ = 0;
- main_smob_ = SCM_EOL;
- lines_ = SCM_EOL;
- book_title_ = 0;
- score_title_ = 0;
+ score_ = SCM_EOL;
}
Paper_score::Paper_score (Paper_score const &s)
assert (false);
}
-
void
-Paper_score::typeset_line (System *line)
+Paper_score::typeset_line (System *system)
{
if (!system_)
- /* ugh. */
- system_ = line;
+ system_ = system;
- main_smob_ = gh_cons (line->self_scm (), main_smob_);
- line->pscore_ = this;
+ score_ = gh_cons (system->self_scm (), score_);
+ system->pscore_ = this;
- scm_gc_unprotect_object (line->self_scm ());
+ scm_gc_unprotect_object (system->self_scm ());
}
Array<Column_x_positions>
return sol;
}
-void
-Paper_score::process (String outname)
+SCM
+Paper_score::process (String)
{
if (verbose_global_b)
progress_indication (_f ("Element count %d (spanners %d) ",
Array<Column_x_positions> breaking = calc_breaking ();
system_->break_into_pieces (breaking);
- lines_ = system_->get_lines ();
-
- // FIXME: ...
- outputter_ = paper_->get_paper_outputter (outname);
-
+ SCM lines = system_->get_lines ();
progress_indication ("\n");
- SCM scopes = SCM_EOL;
- if (header_)
- scopes = scm_cons (header_, scopes);
- if (global_input_file->header_ && global_input_file->header_ != header_)
- scopes = scm_cons (global_input_file->header_, scopes);
-
- outputter_->output_metadata (scopes, paper_);
-
-#ifdef PAGE_LAYOUT
- SCM make_title = scm_primitive_eval (ly_symbol2scm ("make-title"));
- SCM b = ly_modules_lookup (scopes, ly_symbol2scm ("bookTitle"));
- if (b != SCM_UNDEFINED && scm_variable_bound_p (b) == SCM_BOOL_T)
- book_title_
- = unsmob_stencil (gh_call2 (make_title, paper_->self_scm (),
- scm_variable_ref (b)));
-
- SCM s = ly_modules_lookup (scopes, ly_symbol2scm ("scoreTitle"));
- if (s != SCM_UNDEFINED && scm_variable_bound_p (s) == SCM_BOOL_T)
- score_title_
- = unsmob_stencil (gh_call2 (make_title, paper_->self_scm (),
- scm_variable_ref (s)));
-
-#if 0
- // FIXME:
- delete system_;
- system_ = 0;
-#endif
-
- /* Ugh: caller (Score) should do this, but does not know our flavor
- (paper or midi). */
- paper_book->paper_scores_.push (this);
-#else
- output ();
-#endif
-}
-
-void
-Paper_score::output ()
-{
- outputter_->output_header (paper_);
-
- int line_count = SCM_VECTOR_LENGTH ((SCM) lines_);
- for (int i = 0; i < line_count; i++)
- outputter_->output_line (scm_vector_ref (lines_, scm_int2num (i)),
- i == line_count - 1);
+ /* Only keep result stencils in lines_, *title_; delete all grobs. */
+ score_ = SCM_EOL;
- outputter_->output_scheme (scm_list_1 (ly_symbol2scm ("end-output")));
- progress_indication ("\n");
-
-#if 0
- // huh?
- delete outputter_;
- outputter_ = 0;
-#endif
+ return lines;
}
audio_elem_p_list_ = new Killing_cons<Audio_element> (p, audio_elem_p_list_);
}
-
-void
+SCM
Performance::process (String out)
{
if (out == "-")
output (midi_stream);
progress_indication ("\n");
+ return SCM_UNDEFINED;
}
s->one_time_step ();
}
-
Music_output*
Score_context::get_output ()
{
- Translator* t = unsmob_translator (implementation_);
- Score_translator * s = dynamic_cast<Score_translator *> (t);
+ Translator *t = unsmob_translator (implementation_);
+ Score_translator *s = dynamic_cast<Score_translator *> (t);
return s->get_output ();
}
Music_output*
Score_engraver::get_output ()
{
- Music_output * o = pscore_;
- pscore_=0;
+ Music_output *o = pscore_;
+ ///FIXME WTF? pscore_ = 0;
return o;
}
-
bool
Score_engraver::try_music (Music*r)
{
#include "main.hh"
#include "paper-def.hh"
#include "ly-module.hh"
-
#include "paper-book.hh"
+#include "paper-score.hh"
/*
return scm_gc_unprotect_object (trans->self_scm ());
}
-
+// FIXME: silly name, score/music is rendered, not the output -- render midi?
LY_DEFINE (ly_render_output, "ly:render-output",
- 3, 0, 0, (SCM context, SCM header, SCM out_filename),
- "Given a Score context in its final state, calculate the output, "
- "and dump the result to @var{out-filename}, using "
- "@var{header} for the bibliographic information.")
+ 2, 0, 0, (SCM context, SCM outname),
+ "Given a Score context in its final state,"
+ "process it and return the (rendered) result.")
{
- Global_context * gt = dynamic_cast<Global_context *> (unsmob_context (context));
-
- SCM_ASSERT_TYPE (gt, context, SCM_ARG1, __FUNCTION__, "Global context");
- SCM_ASSERT_TYPE (ly_module_p (header), header, SCM_ARG2, __FUNCTION__, "module");
- SCM_ASSERT_TYPE (gh_string_p (out_filename), out_filename, SCM_ARG3, __FUNCTION__, "output filename");
+ Global_context *g = dynamic_cast<Global_context*> (unsmob_context (context));
+ SCM_ASSERT_TYPE (g, context, SCM_ARG1, __FUNCTION__, "Global context");
+ SCM_ASSERT_TYPE (gh_string_p (outname), outname, SCM_ARG2, __FUNCTION__, "output filename");
- Music_output *output = gt->get_output ();
- output->header_ = header;
+ Music_output *output = g->get_output ();
progress_indication ("\n");
- output->process (ly_scm2string (out_filename));
-
-#ifndef PAGE_LAYOUT
- delete output;
-#endif
-
- return SCM_UNDEFINED;
+ // ugh, midi still wants outname
+ return output->process (ly_scm2string (outname));
}
void
-default_rendering (SCM mus, SCM outdef, SCM head, SCM outname)
+default_rendering (SCM music, SCM outdef, SCM header, SCM outname)
{
- SCM context = ly_run_translator (mus, outdef);
-
- if (unsmob_context (context))
- ly_render_output (context, head, outname);
+ SCM context = ly_run_translator (music, outdef);
+
+ if (Global_context *g = dynamic_cast<Global_context*>
+ (unsmob_context (context)))
+ {
+ SCM systems = ly_render_output (context, outname);
+ Music_output *output = g->get_output ();
+ if (systems != SCM_UNDEFINED)
+ {
+ paper_book->scores_.push (systems);
+ paper_book->headers_.push (header);
+ Paper_score *ps = dynamic_cast<Paper_score*> (output);
+ paper_book->papers_.push (ps->paper_);
+#ifndef PAGE_LAYOUT
+ paper_book->classic_output (ly_scm2string (outname));
+#endif
+ }
+ delete output;
+ }
}