summaryrefslogtreecommitdiff
path: root/Build/source/utils/m-tx/mtx-src/control.c
blob: ee6907802df1dc248a2b9fbd0e3c8b9788b62859 (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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */
/* From input file "control.pas" */


#include "p2c.h"


#define CONTROL_G
#include "control.h"


#ifndef UTILITY_H
#include "utility.h"
#endif


/* enables Include: directive */
/* one-word shortcut is treated by simply inserting a blank */
/* detached form of shortcut allowed */
/* C: lines are taken into account */
/* U: lines are taken into account */
/* L: lines are taken into account */
/* non-melismatic eighth and shorter notes in vocal lines are unbeamed */
/* blind slurs are hidden */
/* U: lines synchronize with words and rests */
/* always insert duration into notes */
/* include macros in the count */
/* literally expand macros */
/* keep track of pitch and warn if unreal */
/* transform note words to canical form */
/* use solfa note names */
/* issue warnings even when default action is likely to be correct */
/* ignore all errors except fatal errors */
/* set instrument names */
/* report what is being done */
/* write all possible infomative messages */
typedef enum {
  noSuchFeature, FmultiFile, FsplitShortcut, FnewWordShortcut, FdoChords,
  FdoUptext, FdoLyrics, FunbeamVocal, FhideBlindSlurs, FuptextOnRests,
  FinsertDuration, FcountMacro, FexpandMacro, FcheckPitch, FrearrangeNote,
  FsolfaNoteNames, FpedanticWarnings, FignoreErrors, FinstrumentNames,
  FbeVerbose, FdebugMode
} feature;

typedef struct Tfeature {
  Char tag[31];
  boolean active, changed;
} Tfeature;


#define firstFeature    FmultiFile
#define lastFeature     FdebugMode


Static Tfeature feat[21] = {
  { "", false, false },
  { "multiFile", true, false },
  { "splitShortcut", true, false },
  { "newWordShortcut", true, false },
  { "doChords", true, false },
  { "doUptext", true, false },
  { "doLyrics", true, false },
  { "unbeamVocal", true, false },
  { "hideBlindSlurs", true, false },
  { "uptextOnRests", true, false },
  { "insertDuration", true, false },
  { "countMacro", false, false },
  { "expandMacro", false, false },
  { "checkPitch", true, false },
  { "rearrangeNote", true, false },
  { "solfaNoteNames", false, false },
  { "pedanticWarnings", false, false },
  { "ignoreErrors", false, false },
  { "instrumentNames", false, false },
  { "beVerbose", false, false },
  { "debugMode", false, false }
};


void printFeatures(boolean anyway)
{
  feature i;
  Tfeature *WITH;

  for (i = firstFeature; i <= lastFeature; i = (feature)((long)i + 1)) {
    WITH = &feat[(long)i];
    if (WITH->changed || anyway)
      printf("%s = %s\n", WITH->tag, WITH->active ? " TRUE" : "FALSE");
  }
}


Static feature featureNamed(Char *s)
{
  feature i;

  for (i = firstFeature; i <= lastFeature; i = (feature)((long)i + 1)) {
    if (equalsIgnoreCase(s, feat[(long)i].tag))
      return i;
  }
  return noSuchFeature;
}


boolean setFeature(Char *which, boolean val)
{
  boolean Result = false;
  feature f;
  Tfeature *WITH;

  f = featureNamed(which);
  if (f != noSuchFeature) {
    WITH = &feat[(long)f];
    WITH->active = val;
    WITH->changed = true;
    Result = true;
  }
  if (f == FdebugMode && val)
    feat[(long)FbeVerbose].active = true;
  if (f == FbeVerbose && !val)
    feat[(long)FdebugMode].active = false;
  return Result;
}


void mtxLevel(Char *level)
{
  if (strcmp(level, "0.57") < 0) {
    setFeature("splitShortcut", false);
    setFeature("newWordShortcut", false);
  }
}


/* Feature functions.  To add a new feature "newFeature":
   1. Insert a new value "FnewFeature" in the declaration of type "feature".
   2. Insert an entry for it in array "feat".
   3. Copy the template below and change "FEATURE" into "newFeature".
   4. Copy the function header to the interface section.
   5. (Optional) Insert code into "mtxLevel" to enable/disable the feature.

function FEATURE: boolean;
begin FEATURE := feat[FFEATURE].active end;
*/

boolean checkPitch(void)
{
  return (feat[(long)FcheckPitch].active);
}


boolean countMacro(void)
{
  return (feat[(long)FcountMacro].active);
}


boolean expandMacro(void)
{
  return (feat[(long)FexpandMacro].active);
}


boolean insertDuration(void)
{
  return (feat[(long)FinsertDuration].active);
}


boolean rearrangeNote(void)
{
  return (feat[(long)FrearrangeNote].active);
}


boolean beVerbose(void)
{
  return (feat[(long)FbeVerbose].active);
}


boolean debugMode(void)
{
  return (feat[(long)FdebugMode].active);
}


boolean instrumentNames(void)
{
  return (feat[(long)FinstrumentNames].active);
}


boolean hideBlindSlurs(void)
{
  return (feat[(long)FhideBlindSlurs].active);
}


boolean doLyrics(void)
{
  return (feat[(long)FdoLyrics].active);
}


boolean ignoreErrors(void)
{
  return (feat[(long)FignoreErrors].active);
}


boolean pedanticWarnings(void)
{
  return (feat[(long)FpedanticWarnings].active);
}


boolean solfaNoteNames(void)
{
  return (feat[(long)FsolfaNoteNames].active);
}


boolean uptextOnRests(void)
{
  return (feat[(long)FuptextOnRests].active);
}


boolean unbeamVocal(void)
{
  return (feat[(long)FunbeamVocal].active);
}


boolean doChords(void)
{
  return (feat[(long)FdoChords].active);
}


boolean doUptext(void)
{
  return (feat[(long)FdoUptext].active);
}


boolean newWordShortcut(void)
{
  return (feat[(long)FnewWordShortcut].active);
}


boolean splitShortcut(void)
{
  return (feat[(long)FsplitShortcut].active);
}


boolean multiFile(void)
{
  return (feat[(long)FmultiFile].active);
}





/* End. */