Remove debug code.
[lilypond.git] / lily / performance.cc
blob70d5348a9b1d6f0513e7cc8b983538ec79b77cfe
1 /*
2 performance.cc -- implement Performance
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2007 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "performance.hh"
11 #include <ctime>
12 using namespace std;
14 #include "audio-column.hh"
15 #include "audio-staff.hh"
16 #include "file-name.hh"
17 #include "international.hh"
18 #include "lily-version.hh"
19 #include "main.hh"
20 #include "midi-chunk.hh"
21 #include "midi-stream.hh"
22 #include "score.hh"
23 #include "string-convert.hh"
24 #include "warn.hh"
26 Performance::Performance ()
28 midi_ = 0;
31 Performance::~Performance ()
33 junk_pointers (audio_elements_);
36 void
37 Performance::output (Midi_stream &midi_stream) const
39 int tracks_ = audio_staffs_.size ();
41 midi_stream.write (Midi_header (1, tracks_, 384));
42 if (be_verbose_global)
43 progress_indication (_ ("Track...") + " ");
45 int channel = 0;
46 for (vsize i = 0; i < audio_staffs_.size (); i++)
48 Audio_staff *s = audio_staffs_[i];
49 if (be_verbose_global)
50 progress_indication ("[" + to_string (i));
52 int midi_channel = s->channel_;
54 if (midi_channel < 0)
56 midi_channel = channel;
57 channel ++;
59 MIDI players tend to ignore instrument settings on
60 channel 10, the percussion channel.
62 if (channel % 16 == 9)
63 channel ++;
67 Huh? Why does each staff also have a separate channel? We
68 should map channels to voices, not staves. --hwn.
70 if (midi_channel > 15)
72 warning (_ ("MIDI channel wrapped around"));
73 warning (_ ("remapping modulo 16"));
75 midi_channel = midi_channel % 16;
78 s->output (midi_stream, midi_channel);
79 if (be_verbose_global)
80 progress_indication ("]");
83 void
84 Performance::add_element (Audio_element *p)
86 audio_elements_.push_back (p);
89 void
90 Performance::write_output (string out) const
92 if (out == "-")
93 out = "lelie.midi";
95 /* Maybe a bit crude, but we had this before */
96 File_name file_name (out);
97 file_name.ext_ = "midi";
98 out = file_name.to_string ();
100 Midi_stream midi_stream (out);
101 message (_f ("MIDI output to `%s'...", out));
103 output (midi_stream);
104 progress_indication ("\n");
108 void
109 Performance::process ()
113 Performance *
114 unsmob_performance (SCM x)
116 return dynamic_cast<Performance*> (unsmob_music_output (x));