CVSROOT: /cvsroot/lilypond
Module name: lilypond
Branch:
Changes by: Han-Wen Nienhuys <[EMAIL PROTECTED]> 05/07/11 13:30:57
Modified files:
. : ChangeLog
lily : book-scheme.cc book.cc paper-book-scheme.cc
paper-book.cc performance.cc score-scheme.cc
score.cc
lily/include : book.hh paper-book.hh
scm : framework-ps.scm lily-library.scm midi.scm
Added files:
lily : performance-scheme.cc
Log message:
* scm/midi.scm (paper-book-write-midis): new function. Write all
performances in numbered MIDI files.
* lily/performance-scheme.cc (LY_DEFINE): new file.
(LY_DEFINE): new function ly:performance-write.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.3866&tr2=1.3867&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/performance-scheme.cc?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/book-scheme.cc.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/book.cc.diff?tr1=1.42&tr2=1.43&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/paper-book-scheme.cc.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/paper-book.cc.diff?tr1=1.110&tr2=1.111&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/performance.cc.diff?tr1=1.56&tr2=1.57&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/score-scheme.cc.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/score.cc.diff?tr1=1.166&tr2=1.167&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/include/book.hh.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/include/paper-book.hh.diff?tr1=1.32&tr2=1.33&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/framework-ps.scm.diff?tr1=1.126&tr2=1.127&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/lily-library.scm.diff?tr1=1.41&tr2=1.42&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scm/midi.scm.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.3866 lilypond/ChangeLog:1.3867
--- lilypond/ChangeLog:1.3866 Mon Jul 11 12:51:12 2005
+++ lilypond/ChangeLog Mon Jul 11 13:30:56 2005
@@ -1,5 +1,11 @@
2005-07-11 Han-Wen Nienhuys <[EMAIL PROTECTED]>
+ * scm/midi.scm (paper-book-write-midis): new function. Write all
+ performances in numbered MIDI files.
+
+ * lily/performance-scheme.cc (LY_DEFINE): new file.
+ (LY_DEFINE): new function ly:performance-write.
+
* lily/lily-parser-scheme.cc (LY_DEFINE): ly:parser-output-name:
new function.
(LY_DEFINE): change name ly:parser-define -> ly:parser-define!
Index: lilypond/lily/book-scheme.cc
diff -u lilypond/lily/book-scheme.cc:1.6 lilypond/lily/book-scheme.cc:1.7
--- lilypond/lily/book-scheme.cc:1.6 Mon Jul 11 12:59:29 2005
+++ lilypond/lily/book-scheme.cc Mon Jul 11 13:30:57 2005
@@ -39,8 +39,11 @@
4, 0, 0, (SCM book_smob,
SCM default_paper,
SCM default_layout,
- SCM basename),
- "Print book.")
+ SCM output),
+ "Print book. @var{output} is passed to the backend unchanged. "
+ "Eg. it may be "
+ "a string (for file based outputs) or a socket (for network based "
+ "output).")
{
Book *book = unsmob_book (book_smob);
@@ -49,16 +52,12 @@
default_layout, SCM_ARG2, __FUNCTION__, "\\paper block");
SCM_ASSERT_TYPE (unsmob_output_def (default_layout),
default_layout, SCM_ARG3, __FUNCTION__, "\\layout block");
- SCM_ASSERT_TYPE (scm_is_string (basename), basename, SCM_ARG4, __FUNCTION__,
"string");
- String base = ly_scm2string (basename);
- Paper_book *pb = book->process (base,
- unsmob_output_def (default_paper),
- unsmob_output_def (default_layout)
- );
+ Paper_book *pb = book->process (unsmob_output_def (default_paper),
+ unsmob_output_def (default_layout));
if (pb)
{
- pb->output (base);
+ pb->output (output);
scm_gc_unprotect_object (pb->self_scm ());
}
Index: lilypond/lily/book.cc
diff -u lilypond/lily/book.cc:1.42 lilypond/lily/book.cc:1.43
--- lilypond/lily/book.cc:1.42 Mon Jul 11 12:51:13 2005
+++ lilypond/lily/book.cc Mon Jul 11 13:30:57 2005
@@ -74,11 +74,11 @@
scores_ = scm_cons (s, scores_);
}
-/* This function does not dump the output; outname is required eg. for
- dumping header fields. */
+/* Concatenate all score outputs into a Paper_book
+
+ */
Paper_book *
-Book::process (String outname,
- Output_def *default_paper,
+Book::process (Output_def *default_paper,
Output_def *default_layout)
{
for (SCM s = scores_; s != SCM_EOL; s = scm_cdr (s))
@@ -102,7 +102,6 @@
paper_book->header_ = header_;
/* Render in order of parsing. */
- int midi_count = 0;
for (SCM s = scm_reverse (scores_); s != SCM_EOL; s = scm_cdr (s))
{
if (Score *score = unsmob_score (scm_car (s)))
@@ -116,12 +115,7 @@
if (Performance *perf = dynamic_cast<Performance *> (output))
{
- String fn = outname;
- if (midi_count)
- fn += "-" + to_string (midi_count);
-
- midi_count ++;
- perf->write_output (fn);
+ paper_book->add_performance (perf->self_scm ());
}
else if (Paper_score *pscore = dynamic_cast<Paper_score *>
(output))
{
Index: lilypond/lily/include/book.hh
diff -u lilypond/lily/include/book.hh:1.17 lilypond/lily/include/book.hh:1.18
--- lilypond/lily/include/book.hh:1.17 Mon Jul 11 12:51:13 2005
+++ lilypond/lily/include/book.hh Mon Jul 11 13:30:57 2005
@@ -27,8 +27,7 @@
Book ();
void add_score (SCM);
- Paper_book *process (String,
- Output_def *def_paper,
+ Paper_book *process (Output_def *def_paper,
Output_def *def_layout);
void set_keys ();
};
Index: lilypond/lily/include/paper-book.hh
diff -u lilypond/lily/include/paper-book.hh:1.32
lilypond/lily/include/paper-book.hh:1.33
--- lilypond/lily/include/paper-book.hh:1.32 Mon Apr 18 12:29:24 2005
+++ lilypond/lily/include/paper-book.hh Mon Jul 11 13:30:57 2005
@@ -25,6 +25,7 @@
SCM systems_;
SCM pages_;
+ SCM performances_;
void add_score_title (SCM);
public:
@@ -34,15 +35,19 @@
Output_def *paper_;
Paper_book ();
-
+
void add_score (SCM);
+ void add_performance (SCM);
+
+ SCM performances () const;
SCM systems ();
SCM pages ();
Stencil book_title ();
Stencil score_title (SCM);
- void classic_output (String);
- void output (String);
+ void classic_output (SCM output_channel);
+ void output (SCM output_channel);
void post_processing (SCM, SCM);
+
};
DECLARE_UNSMOB (Paper_book, paper_book)
Index: lilypond/lily/paper-book-scheme.cc
diff -u lilypond/lily/paper-book-scheme.cc:1.4
lilypond/lily/paper-book-scheme.cc:1.5
--- lilypond/lily/paper-book-scheme.cc:1.4 Mon Jul 11 12:51:13 2005
+++ lilypond/lily/paper-book-scheme.cc Mon Jul 11 13:30:57 2005
@@ -31,6 +31,13 @@
return scopes;
}
+LY_DEFINE (ly_paper_book_performances, "ly:paper-book-performances",
+ 1, 0, 0, (SCM paper_book),
+ "Return performances in book @var{paper-book}.")
+{
+ return unsmob_paper_book (paper_book)->performances ();
+}
+
LY_DEFINE (ly_paper_book_systems, "ly:paper-book-systems",
1, 0, 0, (SCM pb),
"Return systems in book PB.")
Index: lilypond/lily/paper-book.cc
diff -u lilypond/lily/paper-book.cc:1.110 lilypond/lily/paper-book.cc:1.111
--- lilypond/lily/paper-book.cc:1.110 Mon Jul 11 12:51:13 2005
+++ lilypond/lily/paper-book.cc Mon Jul 11 13:30:57 2005
@@ -23,6 +23,7 @@
header_0_ = SCM_EOL;
pages_ = SCM_BOOL_F;
scores_ = SCM_EOL;
+ performances_ = SCM_EOL;
systems_ = SCM_BOOL_F;
paper_ = 0;
@@ -34,10 +35,10 @@
}
IMPLEMENT_DEFAULT_EQUAL_P (Paper_book);
-IMPLEMENT_SMOBS (Paper_book)
- IMPLEMENT_TYPE_P (Paper_book, "ly:paper-book?")
+IMPLEMENT_SMOBS (Paper_book);
+IMPLEMENT_TYPE_P (Paper_book, "ly:paper-book?");
- SCM
+SCM
Paper_book::mark_smob (SCM smob)
{
Paper_book *b = (Paper_book *) SCM_CELL_WORD_1 (smob);
@@ -46,6 +47,7 @@
scm_gc_mark (b->header_);
scm_gc_mark (b->header_0_);
scm_gc_mark (b->pages_);
+ scm_gc_mark (b->performances_);
scm_gc_mark (b->scores_);
return b->systems_;
}
@@ -79,8 +81,16 @@
scores_ = scm_cons (s, scores_);
}
+
void
-Paper_book::output (String outname)
+Paper_book::add_performance (SCM s)
+{
+ performances_ = scm_cons (s, performances_);
+}
+
+
+void
+Paper_book::output (SCM output_channel)
{
if (scores_ == SCM_EOL)
return;
@@ -100,7 +110,7 @@
SCM func = scm_c_module_lookup (mod, "output-framework");
func = scm_variable_ref (func);
- scm_apply_0 (func, scm_list_n (scm_makfrom0str (outname.to_str0 ()),
+ scm_apply_0 (func, scm_list_n (output_channel,
self_scm (),
scopes,
dump_fields (),
@@ -111,7 +121,7 @@
{
SCM func = scm_c_module_lookup (mod, "output-preview-framework");
func = scm_variable_ref (func);
- scm_apply_0 (func, scm_list_n (scm_makfrom0str (outname.to_str0 ()),
+ scm_apply_0 (func, scm_list_n (output_channel,
self_scm (),
scopes,
dump_fields (),
@@ -120,7 +130,7 @@
}
void
-Paper_book::classic_output (String outname)
+Paper_book::classic_output (SCM output)
{
/* Generate all stencils to trigger font loads. */
systems ();
@@ -139,7 +149,7 @@
SCM func = scm_c_module_lookup (mod, "output-classic-framework");
func = scm_variable_ref (func);
- scm_apply_0 (func, scm_list_n (scm_makfrom0str (outname.to_str0 ()),
+ scm_apply_0 (func, scm_list_n (output,
self_scm (),
scopes,
dump_fields (),
@@ -342,4 +352,10 @@
SCM proc = paper_->c_variable ("page-breaking");
pages_ = scm_apply_0 (proc, scm_list_2 (systems (), self_scm ()));
return pages_;
+}
+
+SCM
+Paper_book::performances () const
+{
+ return scm_reverse (performances_);
}
Index: lilypond/lily/performance.cc
diff -u lilypond/lily/performance.cc:1.56 lilypond/lily/performance.cc:1.57
--- lilypond/lily/performance.cc:1.56 Mon Apr 18 00:36:45 2005
+++ lilypond/lily/performance.cc Mon Jul 11 13:30:57 2005
@@ -167,3 +167,4 @@
output (midi_stream);
progress_indication ("\n");
}
+
Index: lilypond/lily/score-scheme.cc
diff -u lilypond/lily/score-scheme.cc:1.11 lilypond/lily/score-scheme.cc:1.12
--- lilypond/lily/score-scheme.cc:1.11 Mon Jul 11 12:59:29 2005
+++ lilypond/lily/score-scheme.cc Mon Jul 11 13:30:57 2005
@@ -91,8 +91,6 @@
default_header, SCM_ARG3, __FUNCTION__, "\\paper block");
SCM_ASSERT_TYPE (unsmob_output_def (default_layout),
default_header, SCM_ARG4, __FUNCTION__, "\\layout block");
- SCM_ASSERT_TYPE (scm_is_string (basename),
- default_header, SCM_ARG5, __FUNCTION__, "basename");
Object_key *key = new Lilypond_general_key (0, score->user_key_, 0);
Index: lilypond/lily/score.cc
diff -u lilypond/lily/score.cc:1.166 lilypond/lily/score.cc:1.167
--- lilypond/lily/score.cc:1.166 Mon Jul 11 12:51:13 2005
+++ lilypond/lily/score.cc Mon Jul 11 13:30:57 2005
@@ -136,7 +136,7 @@
SCM systems = pscore->get_paper_systems ();
paper_book->add_score (systems);
- paper_book->classic_output (ly_scm2string (outname));
+ paper_book->classic_output (outname);
scm_gc_unprotect_object (paper_book->self_scm ());
}
Index: lilypond/scm/framework-ps.scm
diff -u lilypond/scm/framework-ps.scm:1.126 lilypond/scm/framework-ps.scm:1.127
--- lilypond/scm/framework-ps.scm:1.126 Mon Jul 11 11:51:43 2005
+++ lilypond/scm/framework-ps.scm Mon Jul 11 13:30:57 2005
@@ -418,6 +418,8 @@
(page-count (length pages))
(port (ly:outputter-port outputter)))
+ (paper-book-write-midis book basename)
+
(output-scopes scopes fields basename)
(display (page-header paper page-count #t) port)
(write-preamble paper #t port)
Index: lilypond/scm/lily-library.scm
diff -u lilypond/scm/lily-library.scm:1.41 lilypond/scm/lily-library.scm:1.42
--- lilypond/scm/lily-library.scm:1.41 Mon Jul 11 12:59:30 2005
+++ lilypond/scm/lily-library.scm Mon Jul 11 13:30:57 2005
@@ -89,11 +89,10 @@
(set! count 0))
(if (> count 0)
- (set! (base (format #f "~a-~a" count))))
+ (set! base (format #f "~a-~a" base count)))
(ly:parser-define! parser 'output-count (1+ count))
-
(ly:book-process book paper layout base)
))
Index: lilypond/scm/midi.scm
diff -u lilypond/scm/midi.scm:1.28 lilypond/scm/midi.scm:1.29
--- lilypond/scm/midi.scm:1.28 Tue Jun 28 23:26:14 2005
+++ lilypond/scm/midi.scm Mon Jul 11 13:30:57 2005
@@ -277,3 +277,23 @@
(define-public (alterations-in-key pitch-list)
"Count number of sharps minus number of flats"
(/ (apply + (map cdr pitch-list)) 2))
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+
+(define-public (paper-book-write-midis paper-book basename)
+ (let
+ loop
+ ((perfs (ly:paper-book-performances paper-book))
+ (count 0))
+
+ (if (pair? perfs)
+ (begin
+ (ly:performance-write
+ (car perfs)
+ (if (> count 0)
+ (format #f "~a-~a.midi" basename count)
+ (format #f "~a.midi" basename)))
+ (loop (cdr perfs) (1+ count))))))
_______________________________________________
Lilypond-cvs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-cvs