]> git.donarmstrong.com Git - lilypond.git/blob - lily/control-track-performer.cc
Issue 4550 (1/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / control-track-performer.cc
1
2
3 #include "warn.hh"
4 #include "audio-item.hh"
5 #include "audio-staff.hh"
6 #include "performer.hh"
7 #include "string-convert.hh"
8 #include "lily-version.hh"
9
10 #include "translator.icc"
11
12 using std::string;
13
14 class Control_track_performer : public Performer
15 {
16   Audio_staff *control_track_;
17
18   void add_text (Audio_text::Type, const string&);
19   TRANSLATOR_DECLARATIONS (Control_track_performer);
20 protected:
21
22   virtual void initialize ();
23   virtual void acknowledge_audio_element (Audio_element_info info);
24 };
25
26 Control_track_performer::Control_track_performer ()
27 {
28   control_track_ = 0;
29 }
30
31 void
32 Control_track_performer::acknowledge_audio_element (Audio_element_info info)
33 {
34   if (Audio_tempo *tempo = dynamic_cast<Audio_tempo *> (info.elem_))
35     {
36       control_track_->add_audio_item (tempo);
37     }
38   if (Audio_time_signature *sig = dynamic_cast<Audio_time_signature *> (info.elem_))
39     {
40       control_track_->add_audio_item (sig);
41     }
42 }
43
44 void
45 Control_track_performer::add_text (Audio_text::Type text_type, const string &str)
46 {
47   Audio_item *text = new Audio_text (text_type, str);
48   control_track_->add_audio_item (text);
49
50   announce_element (Audio_element_info (text, 0));
51
52 }
53
54 void
55 Control_track_performer::initialize ()
56 {
57   control_track_ = new Audio_control_track_staff;
58   announce_element (Audio_element_info (control_track_, 0));
59
60   string id_string = String_convert::pad_to (gnu_lilypond_version_string (), 30);
61
62   // The first audio element in the control track is a placeholder for the
63   // name of the MIDI sequence.  The actual name is stored in the element
64   // later before outputting the track (in Performance::output, see
65   // performance.cc).
66   add_text (Audio_text::TRACK_NAME, "control track");
67   add_text (Audio_text::TEXT, "creator: ");
68   add_text (Audio_text::TEXT, id_string);
69 }
70
71 ADD_TRANSLATOR (Control_track_performer,
72                 /* doc */
73                 "",
74
75                 /* create */
76                 "",
77
78                 /* read */
79                 "",
80
81                 /* write */
82                 ""
83                );