From: Nicolas Sceaux Date: Sun, 24 Aug 2008 14:09:57 +0000 (+0200) Subject: Book parts: fix midi file naming accross book parts X-Git-Tag: release/2.11.65-1~51^2~2^2~19 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=00f0cfeccfc0c75a27a5193022f0f05e06b34048;p=lilypond.git Book parts: fix midi file naming accross book parts --- diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh index 74829492ed..1aaf6fab0a 100644 --- a/lily/include/paper-book.hh +++ b/lily/include/paper-book.hh @@ -51,12 +51,14 @@ public: Stencil book_title (); Stencil score_title (SCM); - void classic_output_aux (SCM output); + void classic_output_aux (SCM output, + int *first_performance_number); void classic_output (SCM output_channel); - int output_aux (SCM output_channel, - int first_page_number, - bool is_first, - bool is_last); + void output_aux (SCM output_channel, + bool is_first, + bool is_last, + int *first_page_number, + int *first_performance_number); void output (SCM output_channel); }; diff --git a/lily/paper-book.cc b/lily/paper-book.cc index dfd3f6257f..907ff1bd77 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -105,57 +105,64 @@ Paper_book::add_performance (SCM s) performances_ = scm_cons (s, performances_); } -int +void Paper_book::output_aux (SCM output_channel, - int first_page_number, bool is_first, - bool is_last) + bool is_last, + int *first_page_number, + int *first_performance_number) { if (scm_is_pair (performances_)) { SCM proc = ly_lily_module_constant ("write-performances-midis"); - scm_call_2 (proc, performances (), output_channel); + scm_call_3 (proc, + performances (), + output_channel, + scm_long2num (*first_performance_number)); + *first_performance_number += scm_ilength (performances_); } if (scm_is_pair (bookparts_)) { bool is_first_part = is_first; - int page_number = first_page_number; for (SCM p = scm_reverse (bookparts_); scm_is_pair (p); p = scm_cdr (p)) if (Paper_book *pbookpart = unsmob_paper_book (scm_car (p))) { bool is_last_part = (is_last && !scm_is_pair (scm_cdr (p))); - page_number += pbookpart->output_aux (output_channel, - page_number, - is_first_part, - is_last_part); + pbookpart->output_aux (output_channel, + is_first_part, + is_last_part, + first_page_number, + first_performance_number); is_first_part = false; } - return page_number; } else { if (scores_ == SCM_EOL) - return 0; + return; paper_->set_variable (ly_symbol2scm ("part-first-page-number"), - scm_long2num (first_page_number)); + scm_long2num (*first_page_number)); paper_->set_variable (ly_symbol2scm ("part-is-first"), ly_bool2scm (is_first)); paper_->set_variable (ly_symbol2scm ("part-is-last"), ly_bool2scm (is_last)); /* Generate all stencils to trigger font loads. */ - return scm_ilength (pages ()); + *first_page_number += scm_ilength (pages ()); } } void Paper_book::output (SCM output_channel) { + int first_page_number = robust_scm2int (paper_->c_variable ("first-page-number"), 1); + int first_performance_number = 0; output_aux (output_channel, - robust_scm2int (paper_->c_variable ("first-page-number"), 1), true, - true); + true, + &first_page_number, + &first_performance_number); SCM scopes = SCM_EOL; if (ly_is_module (header_)) @@ -190,13 +197,17 @@ Paper_book::output (SCM output_channel) } void -Paper_book::classic_output_aux (SCM output) +Paper_book::classic_output_aux (SCM output, + int *first_performance_number) { if (scm_is_pair (performances_)) { SCM proc = ly_lily_module_constant ("write-performances-midis"); - - scm_call_2 (proc, performances (), output); + scm_call_3 (proc, + performances (), + output, + scm_long2num (*first_performance_number)); + *first_performance_number += scm_ilength (performances_); } /* Generate all stencils to trigger font loads. */ @@ -206,7 +217,8 @@ Paper_book::classic_output_aux (SCM output) void Paper_book::classic_output (SCM output) { - classic_output_aux (output); + int first_performance_number = 0; + classic_output_aux (output, &first_performance_number); SCM scopes = SCM_EOL; if (ly_is_module (header_)) diff --git a/scm/midi.scm b/scm/midi.scm index 715c8c0e37..863128e905 100644 --- a/scm/midi.scm +++ b/scm/midi.scm @@ -284,11 +284,11 @@ returns the program of the instrument ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; -(define-public (write-performances-midis performances basename) +(define-public (write-performances-midis performances basename . rest) (let loop ((perfs performances) - (count 0)) + (count (if (null? rest) 0 (car rest)))) (if (pair? perfs)