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