]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/include/music-output.hh (process): Change signature to
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 9 Mar 2004 20:37:44 +0000 (20:37 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 9 Mar 2004 20:37:44 +0000 (20:37 +0000)
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.

14 files changed:
ChangeLog
lily/include/lily-proto.hh
lily/include/music-output.hh
lily/include/paper-book.hh
lily/include/paper-score.hh
lily/include/performance.hh
lily/include/score.hh
lily/input-file-results.cc
lily/paper-book.cc
lily/paper-score.cc
lily/performance.cc
lily/score-context.cc
lily/score-engraver.cc
lily/score.cc

index e786ed705106ee3ec1e5ef93fca572ba9619e644..05b08bc7e1ce9827930de5f260e7e10f78b122a6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+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
@@ -9,11 +31,6 @@
        * 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.
index 493b5ef46d56dfe319a722e62cf2de0b4a2ce157..017271de13bdb6e92e052ff0663886dfc1f3c858 100644 (file)
@@ -105,6 +105,7 @@ class Music_output_def;
 class Music_sequence;
 class Music_wrapper;
 class Music_wrapper_iterator;
+class Page;
 class Pitch;
 class My_lily_lexer;
 class Note_performer;
index d1423852b1359f1f8523049c178bf3fbe84a82a7..1bee38d812af178181b2f63e84db24fe96d8955f 100644 (file)
@@ -7,26 +7,18 @@
 */
 
 
-#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 */
index 42945d5434e579ec30fcb489d609d34ef0cacdc6..3c2dd05f6739918ebae305b92ac6a3974c173e69 100644 (file)
@@ -9,19 +9,25 @@
 #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 */
index 6ef31f47964a3af63ee19b2b258845a76bd6f8d5..f6db4de5753b4a15728708c2c41e99896c1c1b84 100644 (file)
@@ -6,9 +6,8 @@
   (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 */
index 8b29187aab4fab1392cdb4ce4e04a30eb025e923..907b1ec9989a7dbf6e70c547e5698e66a3f7d6ba 100644 (file)
 #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 ();
@@ -27,11 +25,11 @@ public:
   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 */
index 4a03be69322781d48901b7400b59f0f7a133fea4..38e4b3aaf5db94eddb68ca8274011ec94f62c645 100644 (file)
@@ -6,7 +6,6 @@
   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-
 #ifndef SCORE_HH
 #define SCORE_HH
 
@@ -26,12 +25,12 @@ public:
   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 */
index a70ed99376b465f6b0e868335015de8fab3aed19..6c446f881d21f4882c8848a17f25dae59477413b 100644 (file)
@@ -226,16 +226,14 @@ do_one_file (char const *file)
       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
 }
index eaeaf4a27e2bb435332e35eea56c10be3cb16751..0aa137a6b7a8778a09eb00b40f0165fecd005612 100644 (file)
@@ -8,16 +8,15 @@
 
 #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
@@ -62,19 +61,12 @@ Page::Page (Paper_def *paper)
 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
@@ -96,16 +88,12 @@ Paper_book::Paper_book ()
 }
 
 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 ();
@@ -116,6 +104,32 @@ Paper_book::output ()
   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
 
@@ -133,58 +147,51 @@ Link_array<Page>*
 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)
            {
@@ -202,8 +209,25 @@ Paper_book::get_pages ()
            }
        }
     }
-#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");
+}
index 9202095e17aceae65fa377aa146431265b84c86f..92f27355f6ff84836701a8f00f4692d56e266067 100644 (file)
@@ -18,7 +18,7 @@
 #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)
@@ -44,18 +40,16 @@ 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>
@@ -72,8 +66,8 @@ Paper_score::calc_breaking ()
   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) ",
@@ -94,65 +88,11 @@ Paper_score::process (String outname)
  
   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;
 }
index 5ce6da278f67517387cee3748116b846e21a91fb..71a84ddb5a3bc3cd75161754a9a9a38aa3503a85 100644 (file)
@@ -146,8 +146,7 @@ Performance::add_element (Audio_element *p)
   audio_elem_p_list_ = new Killing_cons<Audio_element> (p, audio_elem_p_list_);
 }
 
-
-void
+SCM
 Performance::process (String out)
 {
   if (out == "-")
@@ -165,4 +164,5 @@ Performance::process (String out)
 
   output (midi_stream);
   progress_indication ("\n");
+  return SCM_UNDEFINED;
 }
index 0ffef5660ef1720455fd9daa6126fa83d4482b7b..acabbe813f20f2275f561320042343a7fc98d6a6 100644 (file)
@@ -35,12 +35,11 @@ Score_context::one_time_step ()
   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 ();
 }
 
index 5eef0cb6ee1e44534c3a7c3d9acae1adb66789a3..6fd90611cb22ada272b43937596c0cfacf3d83a6 100644 (file)
@@ -253,12 +253,11 @@ Score_engraver::set_columns (Paper_column *new_command,
 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)
 {
index 0f3c924df13da985fffc0e4f1ea670147ce4ff27..ae9c81f64775c96c1a9cf125aac58e0c8ec4e98d 100644 (file)
@@ -22,8 +22,8 @@
 #include "main.hh"
 #include "paper-def.hh"
 #include "ly-module.hh"
-
 #include "paper-book.hh"
+#include "paper-score.hh"
 
 
 /*
@@ -146,36 +146,42 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
   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;
+    }
 }