]> git.donarmstrong.com Git - lilypond.git/blob - hdr/inputmusic.hh
release: 0.0.16
[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
13 struct Voice_list : public PointerList<Voice*> {
14     void translate_time(Real dt);
15     /// delete stuff; not in destructor!
16     void junk();
17 };
18
19 /// ABC for input structures
20 struct Input_music {
21     virtual Voice_list convert()=0;
22     virtual Real length()=0;
23     virtual void translate_time(Real dt)=0;
24     virtual ~Input_music();
25     virtual void print() const =0;
26     // virtual void transpose(...) const =0;
27 };
28 /**
29
30   Input_music is anything that can simply be regarded as/converted to
31   a set of voices "cooperating" or independant. It has some basic
32   characteristics that real music has too:
33
34   - it is rhythmic (it has a length, and can be translated horizontally)
35   - a pitch (it can be transposed)
36
37   */
38
39
40
41 /// 
42 struct Vertical_music : Input_music {
43     virtual Vertical_music *clone() const = 0;
44
45     /// check if it is a simple voice
46     virtual Vertical_simple *simple() { return 0;}
47 };
48 /**
49   chord like :
50
51   - different music forms which start at the same time ( stacked "vertically" )
52
53   This class really doesn't do very much, but it enables you to say
54
55   a Music_voice is a List<Vertical_music>
56   
57   */
58
59 ///
60 struct Horizontal_music : Input_music {
61     virtual Voice_list convert()=0;
62     virtual Horizontal_music *clone() const = 0;
63 };
64 /**
65   voice like.
66
67   different music forms which start after each other ( concatenated,
68   stacked "horizontally )
69
70   This class really doesn't do very much, but it enables you to say
71
72   a Chord is a List<Horizontal_music>
73  
74  */
75
76 /// the most basic element of a chord: a simple voice
77 struct Vertical_simple : Vertical_music {
78     Voice * voice_;             // should be a  real member
79     
80     /****************/
81     Vertical_simple(Vertical_simple const&);
82     Vertical_simple();
83     ~Vertical_simple();
84     void add(Voice_element*);
85     virtual Vertical_simple*simple() { return this; }
86     virtual Real length();
87     virtual Voice_list convert();
88     virtual void translate_time(Real dt);
89     virtual Vertical_music *clone() const {
90         return new Vertical_simple(*this);
91     }
92     virtual void print() const ;
93 };
94
95 /// the only child of Horizontal_music
96 struct Music_voice : Horizontal_music {
97     IPointerList<Vertical_music*> voice_ ;
98     
99     /****************/
100     Music_voice() {}
101     Music_voice(Music_voice const&);
102     Real length();
103     void add(Vertical_music*);
104     void add(Voice_element*);
105     virtual Voice_list convert();
106     virtual void translate_time(Real dt);
107     virtual Horizontal_music *clone() const {
108         return new Music_voice(*this);
109     }
110     void concatenate(Music_voice*);
111     virtual void print() const ;
112 };
113 ///
114 struct Music_general_chord : Vertical_music {
115     IPointerList<Horizontal_music*> chord_;
116
117     /****************/
118     Music_general_chord() {}
119     Music_general_chord(Music_general_chord const&s);
120     void add(Horizontal_music*);
121     virtual Real length();
122     virtual Voice_list convert();
123     virtual void translate_time(Real dt);
124     virtual Vertical_music *clone() const {
125         return new Music_general_chord(*this);
126     }
127     void concatenate(Music_general_chord*);
128     virtual void print() const ;
129 };
130
131
132 #endif // INPUTMUSIC_HH