113{
114
115
116 static integer enctab[16] = { 0,7,11,12,13,10,6,1,14,9,5,2,3,4,8,15 };
117 static integer entau[60] = { 19,11,27,25,29,21,23,22,30,14,15,7,39,38,46,
118 42,43,41,45,37,53,49,51,50,54,52,60,56,58,26,90,88,92,84,86,82,83,
119 81,85,69,77,73,75,74,78,70,71,67,99,97,113,112,114,98,106,104,108,
120 100,101,76 };
121 static integer enadd[8] = { 1920,-768,2432,1280,3584,1536,2816,-1152 };
122 static real enscl[8] = { .0204f,.0167f,.0145f,.0147f,.0143f,.0135f,.0125f,
123 .0112f };
124 static integer enbits[8] = { 6,5,4,4,4,4,3,3 };
125 static integer entab6[64] = { 0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,
126 3,3,3,3,3,4,4,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,9,9,
127 9,10,10,11,11,12,13,14,15 };
128 static integer rmst[64] = { 1024,936,856,784,718,656,600,550,502,460,420,
129 384,352,328,294,270,246,226,206,188,172,158,144,132,120,110,102,
130 92,84,78,70,64,60,54,50,46,42,38,34,32,30,26,24,22,20,18,17,16,15,
131 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 };
132
133
135
136
138
139
140 integer idel, nbit, i__, j, i2, i3, mrk;
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
270
271
272
273
274
275
276 --irc;
277 --rc;
278 --voice;
279
280
281
284 for (i__ = 1; i__ <= i__1; ++i__) {
285 irc[i__] = (
integer)(rc[i__] * 32768.f);
286 }
287
288
289
290 if (voice[1] != 0 && voice[2] != 0) {
291 *ipitch = entau[*pitch - 1];
292 } else {
294 *ipitch = 0;
295 if (voice[1] != voice[2]) {
296 *ipitch = 127;
297 }
298 } else {
299 *ipitch = (voice[1] << 1) + voice[2];
300 }
301 }
302
303 j = 32;
304 idel = 16;
305 *irms =
min(*irms,1023);
306 while(idel > 0) {
307 if (*irms > rmst[j - 1]) {
308 j -= idel;
309 }
310 if (*irms < rmst[j - 1]) {
311 j += idel;
312 }
313 idel /= 2;
314 }
315 if (*irms > rmst[j - 1]) {
316 --j;
317 }
318 *irms = 31 - j / 2;
319
320 for (i__ = 1; i__ <= 2; ++i__) {
321 i2 = irc[i__];
322 mrk = 0;
323 if (i2 < 0) {
324 i2 = -i2;
325 mrk = 1;
326 }
327 i2 /= 512;
329 i2 = entab6[i2];
330 if (mrk != 0) {
331 i2 = -i2;
332 }
333 irc[i__] = i2;
334 }
335
337 for (i__ = 3; i__ <= i__1; ++i__) {
338 i2 = irc[i__] / 2;
341
344 nbit = enbits[
contrl_1.order + 1 - i__ - 1];
345 i3 = 0;
346 if (i2 < 0) {
347 i3 = -1;
348 }
350 if (i3 == -1) {
351 --i2;
352 }
353 irc[i__] = i2;
354 }
355
356
357
358
360 if (*ipitch == 0 || *ipitch == 127) {
361 irc[5] = enctab[(irc[1] & 30) / 2];
362 irc[6] = enctab[(irc[2] & 30) / 2];
363 irc[7] = enctab[(irc[3] & 30) / 2];
364 irc[8] = enctab[(*irms & 30) / 2];
365 irc[9] = enctab[(irc[4] & 30) / 2] / 2;
366 irc[10] = enctab[(irc[4] & 30) / 2] & 1;
367 }
368 }
369
370
371 return 0;
372}
integer pow_ii(integer *ap, integer *bp)