2 audio-score.cc -- implement Performance
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
12 #include "string-convert.hh"
14 #include "midi-def.hh"
15 #include "midi-item.hh"
16 #include "midi-stream.hh"
17 #include "audio-column.hh"
18 #include "audio-staff.hh"
19 #include "performance.hh"
22 Performance::Performance ()
28 Performance::add (Audio_column
* p
)
30 p
->performance_l_
= this;
31 audio_column_p_list_
.bottom().add (p
);
35 Performance::output (Midi_stream
& midi_stream_r
)
37 int tracks_i
= audio_staff_l_list_
.size() + 1;
39 int clocks_per_4_i
= 384;
40 midi_stream_r
<< Midi_header (1, tracks_i
, clocks_per_4_i
);
41 output_header_track (midi_stream_r
);
43 for (PCursor
<Audio_staff
*> i (audio_staff_l_list_
); i
.ok(); i
++)
44 i
->output (midi_stream_r
, n
++);
48 Performance::output_header_track (Midi_stream
& midi_stream_r
)
50 Midi_track midi_track
;
54 // perhaps multiple text events?
55 String str
= String (_("Creator: ")) + get_version_str() + "\n";
57 Midi_text
creator (Midi_text::TEXT
, str
);
58 midi_track
.add (Moment (0), &creator
);
60 str
= _("Automatically generated at ");
62 str
= str
.left_str (str
.length_i() - 1);
64 Midi_text
generate (Midi_text::TEXT
, str
);
65 midi_track
.add (Moment (0), &generate
);
67 str
= _("from musical definition: ");
70 Midi_text
from (Midi_text::TEXT
, str
);
71 midi_track
.add (Moment (0), &from
);
73 Midi_text
track_name (Midi_text::TRACK_NAME
, "Track "
74 + String_convert::i2dec_str (0, 0, '0'));
75 midi_track
.add (Moment (0), &track_name
);
77 Midi_tempo
tempo (midi_l_
->get_tempo_i (Moment (1, 4)));
78 midi_track
.add (Moment (0), &tempo
);
80 midi_stream_r
<< midi_track
;
84 Performance::add_staff (Audio_staff
* l
)
86 audio_staff_l_list_
.bottom().add (l
);
90 Performance::add (Audio_element
*p
)
92 audio_elem_p_list_
.bottom().add (p
);
96 Performance::print() const
99 DOUT
<< "Performance { ";
101 for (PCursor
<Audio_element
*> i (audio_elem_p_list_
.top ()); i
.ok (); i
++)
104 DOUT
<< "\ncolumns: ";
105 for (PCursor
<Audio_column
*> i (audio_column_p_list_
); i
.ok(); i
++)
112 Performance::process()
116 String out
=midi_l_
->outfile_str_
;
118 out
= default_out_str_
+ ".midi";
120 Midi_stream
midi_stream (out
);
121 *mlog
<< _("MIDI output to ") << out
<< " ..." << endl
;
123 output (midi_stream
);