]> git.donarmstrong.com Git - lilypond.git/blob - hdr/inputmusic.hh
release: 0.0.30
[lilypond.git] / hdr / inputmusic.hh
1 /*
2   inputmusic.hh -- part of LilyPond
3
4   (c) 1996,97 Han-Wen Nienhuys
5 */
6
7 #ifndef INPUTMUSIC_HH
8 #define INPUTMUSIC_HH
9
10 #include "plist.hh"
11 #include "proto.hh"
12 #include "voice.hh"
13 #include "moment.hh"
14
15 struct Voice_list : public PointerList<Voice*> {
16     void translate_time(Moment dt);
17 };
18
19 /**
20
21   Input_music is anything that can simply be regarded as/converted to
22   a set of voices "cooperating" or independant. It has some basic
23   characteristics that real music has too:
24
25   - it is rhythmic (it has a length, and can be translated horizontally)
26   - a pitch (it can be transposed)
27
28   */
29
30
31 struct Input_music {
32     virtual Voice_list convert()const=0;
33     virtual Moment length()const=0;
34     virtual void translate_time(Moment dt)=0;
35     virtual ~Input_music(){}
36     virtual void print() const =0;
37     virtual void set_default_group(String)=0;
38     // virtual void transpose(...) const =0;
39     
40     
41     virtual Input_music *clone() const = 0;
42     virtual Simple_music *simple() { return 0; }
43 };
44
45 /// Simple music consists of one voice
46 struct Simple_music : Input_music {
47     Voice voice_;
48
49     /* *** */
50     virtual Simple_music*simple() { return this; }  
51     void add(Voice_element*);
52     virtual void set_default_group(String g) { voice_.set_default_group(g); }
53     virtual Moment length()const;
54     virtual Voice_list convert()const;
55     virtual void translate_time(Moment dt);
56     virtual void print() const;
57     virtual Input_music *clone() const {
58         return new Simple_music(*this);
59     }
60
61 };
62
63 /// Complex_music consists of multiple voices
64 struct Complex_music : Input_music {
65     IPointerList<Input_music*> elts;
66     /* *************** */
67     virtual void set_default_group(String g);
68     void add(Input_music*);
69     Complex_music();
70     Complex_music(Complex_music const &);
71     virtual void print() const ;
72     void concatenate(Complex_music*);
73  
74 };
75
76
77 /**
78   voice like.
79
80   different music forms which start after each other ( concatenated,
81   stacked "horizontally )
82  
83  */
84
85 struct Music_voice : Complex_music {
86  
87     
88     /* *************** */
89     Moment length()const;
90     virtual void translate_time(Moment dt);
91     virtual Voice_list convert()const;
92     void add_elt(Voice_element*);
93     virtual Input_music *clone() const {
94         return new Music_voice(*this);
95     }
96     virtual void print() const ;
97 };
98
99 /**
100   Multiple musicstuff stacked on top of each other
101   chord like :
102
103   - different music forms which start at the same time ( stacked "vertically" )
104   
105   */
106 struct Music_general_chord : Complex_music {
107
108
109     /* *************** */
110
111     virtual Moment length()const;
112     virtual Voice_list convert()const;
113     virtual void translate_time(Moment dt);
114     void add_elt(Voice_element*);
115     virtual Input_music *clone() const {
116         return new Music_general_chord(*this);
117     }
118     
119     virtual void print() const ;
120 };
121
122 struct Multi_voice_chord : Music_general_chord {
123     void set_default_group(String);
124     virtual Input_music *clone() const {
125         return new Multi_voice_chord(*this);
126     }
127 };
128 struct Voice_group_chord : Music_general_chord {
129
130     virtual Input_music *clone() const {
131         return new Voice_group_chord(*this);
132     }
133 };
134 #endif // INPUTMUSIC_HH