2 audio-score.cc -- implement Audio_score
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 "audio-score.hh"
22 Audio_score::Audio_score ()
28 Audio_score::add (Audio_column
* p
)
30 p
->audio_score_l_
= this;
31 audio_column_p_list_
.bottom().add (p
);
35 Audio_score::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 Audio_score::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 Audio_score::add_staff (Audio_staff
* l
)
86 audio_staff_l_list_
.bottom().add (l
);
90 Audio_score::add (Audio_element
*p
)
92 audio_elem_p_list_
.bottom().add (p
);
96 Audio_score::print() const
99 DOUT
<< "Audio_score { ";
100 DOUT
<< "\ncolumns: ";
101 for (PCursor
<Audio_column
*> i (audio_column_p_list_
); i
.ok(); i
++)
108 Audio_score::process()
110 String out
=midi_l_
->outfile_str_
;
112 out
= default_out_str_
+ ".midi";
114 Midi_stream
midi_stream (out
);
115 *mlog
<< "MIDI output to " << out
<< " ..." << endl
;
117 output (midi_stream
);