summaryrefslogtreecommitdiff
path: root/request.hh
blob: 8ebb1468c01ad316c5df4c90104d87f06b68d841 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
// mpp96's second egg of columbus!
#ifndef REQUEST_HH
#define REQUEST_HH

#include "glob.hh"
#include "string.hh"

/// a voice element wants something printed
struct Request {
    Voice_element*elt;
    
    /****************/

    virtual void print()const ;
    virtual Note_req *note() {return 0;}
    virtual Rest_req *rest() {return 0;}
    virtual  Rhythmic_req*rhythmic() { return 0;}
    Request(Voice_element*);
    Request();
    virtual Real duration() const { return 0.0; }
};

/**
    Any Voice_element can do a number of requests. A request is done
    to the #Staff# which contains the #Voice_element#. The staff decides
    whether to to honor the request, ignore it, or merge it with other
    requests. Merging of requests is preferably done with other
    requests done by members of the same voicegroups (beams, brackets, stems) 

    Please refer to the documentation of the Child classes of
    #Request# for explanation of each request type.

    The result of a request will be an #Item# or a #Spanner#, which
    will be put on a #PStaff#. Note that the #PStaff# and the original
    #Staff# need not have anything in common. For example, the
    ``double'' piano Staff could interpret commands which juggle
    melodies across the left and right hand, and may put the result in
    two five-line PStaffs (maybe with extra PStaffs to carry the dynamic
    signs and any lyric.

    The class #Staff# should be thought as a container for the
    #Voice#s, and an interpreter for #Request#s and #Command#s.
    Different staffs can produce different outputs; a melodious voice
    which is put into a percussion-Staff, will be typeset as the rythm of
    that voice.

    After #Staff# made up her mind (Would #Staff# be a smart
    name? How about #struct Lily {}# :-), the resultant items and
    spanners are put on the PScore, and pointers to these items are
    stored in the #Voice_element#. This construction enables the
    beams/stems to look up the balls it has to connect to.  */
	

/// a request with a duration
struct Rhythmic_req : Request {
    int balltype;
    int dots;
    
    /****************/

    Real duration() const;
    Rhythmic_req(Voice_element*);
    Rhythmic_req*rhythmic() { return this;}
    void print ()const;
};

/// Put a note of specified type, height, and with accidental on the staff.
struct Note_req : Rhythmic_req {
    char name;
    int octave;
    int accidental;
    bool forceacc;
    
    /****************/

    // return height from central c (in halflines)
    int height()const; 
    Note_req(Voice_element*v);
    Note_req*note() { return this;}
    virtual void print() const;
};
/**
Staff has to decide if the ball should be hanging left or right. This
influences the horizontal dimensions of a column, and this  is why
request processing should be done before horizontal spacing.

Other voices' frivolities may cause the need for accidentals, so this
is also for the Staff to decide. The Staff can decide on positioning
based on ottava commands and the appropriate clef.
*/


///Put a rest on the staff.
struct Rest_req : Rhythmic_req {
    void print()const;
    Rest_req(Voice_element*v) : Rhythmic_req(v) {  }
    Rest_req * rest() { return this;}
};
/**
Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
*/

#if 0

///Put a lyric above or below (?) this staff.
struct Lyric_req : Request {
    String text;
};


///Put a script above or below this ``note''    
struct Script_req : Request {
    int orientation;
    Symbol sym;
};
/**
eg upbow, downbow. Why a request? These symbols may conflict with slurs and brackets, so this
also a request
*/




///Draw a (Guitar) chord above or below this ``note''
struct Chord : Request {
	// don't know how this looks.
};
/**
Why a request?
Because everything else is done in requests.
*/


/// for absolute dynamics
enum Loudness {
    FFF, FF, F, MF, MP, P, PP, PPP
} ;

/// attach a stem to the noteball
struct Stem_req : Request {
    /// 4,8,16, ..
    int stem_number ;
};
/// requests to start or stop something.
struct Span_req : Request {
    /// should the spanner start or stop, or is it unwanted?
    enum {
	NOSPAN, START, STOP
    } spantype ;
};
/**
 This type of request typically results in the creation of a #Spanner#
*/


///Start / stop a beam at this note.
struct Beam_req : Span_req {
    int nplet;
};
/** Staff will have to combine this with the stem_request, since the
    number of flags that a stem wants to carry will determine the
    number of beams.  if #nplet# is set, the staff will try to put an
    appropriate number over the beam

    [what to do  if the nplet fields of start and stop conflict?]
    */

///Start / stop a slur or a bracket.
struct Bracket_req : Span_req {
    int nplet;
};
/**
Start/stop a bracket at this note. if #nplet# is set, the staff will
try to put an appropriate number over the bracket
*/

/// a slur
struct Slur_req : Span_req {
    
};

/// helper in the hierarchy
struct Dynamic {
    Real subtime;
};
/** Each dynamic is bound to one note ( a crescendo spanning multiple
    notes is thought to be made of two "dynamics": a start and a stop).
    Dynamic changes can occur in a smaller time than the length of its
    note, therefore fore each Dynamic request carries a time, measured
    from the start of its note.

    This subfield would come in handy, if mpp96 was adapted for midi
    support.
    
    Dynamic should have been derived from request, but I don't want to
    fuss with virtual baseclasses.  */

/// do a crescendo
struct Cresc_req : Span_req, Dynamic {
    
};

/// do a decrescendo
struct Decresc_req : Span_req, Dynamic {
    
};

/// do a dynamic like "fff" or "mp"
struct Absdynamic_req : Request, Dynamic {
        Loudness loudness;
};
#endif
#endif