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