X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fperformance.cc;h=0a6d10486ca42194765326e3b5fce10dafc3a7db;hb=4300e287a18cbc4569c79f8e8445609dc7d4546a;hp=f47aaa78d2b0e2ec95dd481b68789ef453f519d4;hpb=48631a04b6181cd7be65702574eaaa6c52284bd2;p=lilypond.git diff --git a/lily/performance.cc b/lily/performance.cc index f47aaa78d2..0a6d10486c 100644 --- a/lily/performance.cc +++ b/lily/performance.cc @@ -3,31 +3,29 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2002 Jan Nieuwenhuizen + (c) 1997--2005 Jan Nieuwenhuizen */ -#include -#include "warn.hh" -#include "string.hh" -#include "string-convert.hh" +#include "performance.hh" + +#include + +#include "audio-column.hh" +#include "audio-staff.hh" +#include "file-name.hh" +#include "lily-version.hh" #include "main.hh" -#include "midi-def.hh" #include "midi-item.hh" #include "midi-stream.hh" -#include "audio-column.hh" -#include "audio-item.hh" -#include "audio-staff.hh" -#include "performance.hh" #include "score.hh" -#include "file-results.hh" -#include "file-path.hh" -#include "lily-version.hh" +#include "string-convert.hh" +#include "warn.hh" #include "killing-cons.tcc" Performance::Performance () { - midi_ =0; + midi_ = 0; audio_elem_p_list_ = 0; } @@ -48,24 +46,35 @@ Performance::output (Midi_stream& midi_stream) midi_stream << Midi_header (1, tracks_i, clocks_per_4_i); output_header_track (midi_stream); progress_indication ("\n"); - progress_indication (_ ("Track ... ")); + progress_indication (_ ("Track...") + " "); int channel = 0; - for (int i =0; i < audio_staffs_.size (); i++) + for (int i = 0; i < audio_staffs_.size (); i++) { Audio_staff *s = audio_staffs_[i]; - if (verbose_global_b) + if (be_verbose_global) progress_indication ("[" + to_string (i)) ; /* MIDI players tend to ignore instrument settings on channel 10, the percussion channel by default. */ - if (channel == 9) + if (channel % 16 == 9) channel++; + + + /* + Huh? Why does each staff also have a separate channel? We + should map channels to voices, not staves. --hwn. + */ if (s->channel_ < 0) - s->channel_ = channel; + { + s->channel_ = channel % 16; + if (channel > 15) + warning ("MIDI channel wrapped around. Remapping modulo 16."); + } + s->output (midi_stream, channel++); - if (verbose_global_b) + if (be_verbose_global) progress_indication ("]"); } } @@ -110,8 +119,9 @@ Performance::output_header_track (Midi_stream& midi_stream) Midi_text at (&at_a); midi_track.add (Moment (0), &at); - - str = _f ("from musical definition: %s", origin_string_); + + // TODO: + // str = _f ("from musical definition: %s", origin_string_); Audio_text from_a (Audio_text::TEXT, str); Midi_text from (&from_a); @@ -134,42 +144,28 @@ Performance::output_header_track (Midi_stream& midi_stream) void Performance::add_element (Audio_element *p) { - if (Audio_staff*s=dynamic_cast (p)) + if (Audio_staff*s = dynamic_cast (p)) { audio_staffs_.push (s); } - else if (Audio_column *c = dynamic_cast (p)) - { - c->performance_ = this; - } audio_elem_p_list_ = new Killing_cons (p, audio_elem_p_list_); } - -void -Performance::process () +SCM +Performance::process (String out) { - String out = output_name_global; if (out == "-") out = "lelie.midi"; - int def = midi_->get_next_score_count (); - if (def) - { - Path p = split_path (out); - p.base += "-" + to_string (def); - out = p.string (); - } - + /* Maybe a bit crude, but we had this before */ - Path p = split_path (out); - p.ext = "midi"; - out = p.string (); + File_name file_name (out); + file_name.ext_ = "midi"; + out = file_name.to_string (); Midi_stream midi_stream (out); progress_indication (_f ("MIDI output to `%s'...", out)); - global_input_file->target_strings_.push (out); - output (midi_stream); progress_indication ("\n"); + return SCM_UNDEFINED; }