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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
|
#include "nw4r/snd/snd_Util.h"
/* Original source:
* kiwi515/ogws
* src/nw4r/snd/snd_Util.cpp
*/
/*******************************************************************************
* headers
*/
#include "common.h"
#include "nw4r/ut/ut_algorithm.h"
#include "nw4r/NW4RAssert.hpp"
/*******************************************************************************
* variables
*/
namespace nw4r { namespace snd { namespace detail
{
// just assuming this is what this number is
f32 const Util::CALC_LPF_FREQ_INTERCEPT = 0.13561438f;
// .rodata
// clang-format off
f32 const Util::NoteTable[OCTAVE_DIVISION] =
{
1.0f,
1.0594631f,
1.122462f,
1.1892071f,
1.2599211f,
1.3348398f,
1.4142135f,
1.4983071f,
1.587401f,
1.6817929f,
1.7817974f,
1.8877486f
};
f32 const Util::PitchTable[PITCH_DIVISION_RANGE] =
{
1.0f, 1.0002257f, 1.0004513f, 1.0006771f, 1.0009029f, 1.0011288f,
1.0013547f, 1.0015807f, 1.0018067f, 1.0020328f, 1.0022589f, 1.002485f,
1.0027113f, 1.0029376f, 1.0031638f, 1.0033902f, 1.0036167f, 1.0038432f,
1.0040697f, 1.0042963f, 1.0045229f, 1.0047495f, 1.0049763f, 1.005203f,
1.0054299f, 1.0056568f, 1.0058837f, 1.0061107f, 1.0063378f, 1.0065649f,
1.006792f, 1.0070192f, 1.0072464f, 1.0074737f, 1.007701f, 1.0079285f,
1.008156f, 1.0083834f, 1.008611f, 1.0088385f, 1.0090662f, 1.0092939f,
1.0095217f, 1.0097495f, 1.0099773f, 1.0102053f, 1.0104332f, 1.0106612f,
1.0108893f, 1.0111175f, 1.0113456f, 1.0115738f, 1.0118021f, 1.0120304f,
1.0122588f, 1.0124872f, 1.0127157f, 1.0129442f, 1.0131727f, 1.0134014f,
1.01363f, 1.0138588f, 1.0140876f, 1.0143164f, 1.0145453f, 1.0147743f,
1.0150033f, 1.0152323f, 1.0154614f, 1.0156906f, 1.0159198f, 1.016149f,
1.0163783f, 1.0166076f, 1.0168371f, 1.0170665f, 1.0172961f, 1.0175256f,
1.0177553f, 1.0179849f, 1.0182146f, 1.0184444f, 1.0186743f, 1.0189041f,
1.019134f, 1.019364f, 1.019594f, 1.019824f, 1.0200542f, 1.0202844f,
1.0205146f, 1.0207449f, 1.0209752f, 1.0212057f, 1.0214361f, 1.0216666f,
1.0218972f, 1.0221277f, 1.0223584f, 1.0225891f, 1.0228199f, 1.0230507f,
1.0232816f, 1.0235125f, 1.0237434f, 1.0239744f, 1.0242054f, 1.0244366f,
1.0246677f, 1.024899f, 1.0251303f, 1.0253617f, 1.025593f, 1.0258244f,
1.0260559f, 1.0262874f, 1.0265191f, 1.0267507f, 1.0269824f, 1.0272142f,
1.0274459f, 1.0276778f, 1.0279098f, 1.0281416f, 1.0283737f, 1.0286057f,
1.0288378f, 1.02907f, 1.0293022f, 1.0295345f, 1.0297668f, 1.0299993f,
1.0302316f, 1.0304642f, 1.0306966f, 1.0309292f, 1.0311619f, 1.0313946f,
1.0316273f, 1.0318601f, 1.0320929f, 1.0323259f, 1.0325588f, 1.0327919f,
1.0330249f, 1.033258f, 1.0334911f, 1.0337244f, 1.0339576f, 1.034191f,
1.0344243f, 1.0346577f, 1.0348912f, 1.0351248f, 1.0353583f, 1.035592f,
1.0358257f, 1.0360594f, 1.0362933f, 1.036527f, 1.0367609f, 1.0369949f,
1.037229f, 1.037463f, 1.0376971f, 1.0379313f, 1.0381655f, 1.0383998f,
1.0386341f, 1.0388684f, 1.0391029f, 1.0393374f, 1.0395719f, 1.0398065f,
1.0400412f, 1.0402758f, 1.0405107f, 1.0407454f, 1.0409802f, 1.0412152f,
1.0414501f, 1.0416851f, 1.0419202f, 1.0421553f, 1.0423905f, 1.0426257f,
1.042861f, 1.0430963f, 1.0433317f, 1.0435672f, 1.0438026f, 1.0440382f,
1.0442737f, 1.0445094f, 1.0447451f, 1.0449809f, 1.0452167f, 1.0454526f,
1.0456885f, 1.0459244f, 1.0461605f, 1.0463965f, 1.0466326f, 1.0468688f,
1.0471051f, 1.0473413f, 1.0475777f, 1.0478141f, 1.0480505f, 1.048287f,
1.0485237f, 1.0487603f, 1.0489969f, 1.0492337f, 1.0494704f, 1.0497072f,
1.049944f, 1.050181f, 1.050418f, 1.050655f, 1.0508921f, 1.0511292f,
1.0513664f, 1.0516037f, 1.051841f, 1.0520784f, 1.0523158f, 1.0525533f,
1.0527908f, 1.0530283f, 1.0532659f, 1.0535036f, 1.0537413f, 1.0539792f,
1.054217f, 1.0544549f, 1.0546929f, 1.0549308f, 1.0551689f, 1.055407f,
1.0556452f, 1.0558834f, 1.0561217f, 1.05636f, 1.0565984f, 1.0568368f,
1.0570753f, 1.0573138f, 1.0575525f, 1.0577911f, 1.0580298f, 1.0582685f,
1.0585073f, 1.0587462f, 1.0589851f, 1.0592241f
};
f32 const Util::Decibel2RatioTable[DECIBEL_TABLE_SIZE] =
{
0.0f, 3.05492e-5f, 3.0903e-5f, 3.12608e-5f, 3.16228e-5f,
3.1989e-5f, 3.23594e-5f, 3.27341e-5f, 3.31131e-5f, 3.34965e-5f,
3.38844e-5f, 3.42768e-5f, 3.46737e-5f, 3.50752e-5f, 3.54813e-5f,
3.58922e-5f, 3.63078e-5f, 3.67282e-5f, 3.71535e-5f, 3.75837e-5f,
3.80189e-5f, 3.84592e-5f, 3.89045e-5f, 3.9355e-5f, 3.98107e-5f,
4.02717e-5f, 4.0738e-5f, 4.12098e-5f, 4.16869e-5f, 4.21697e-5f,
4.2658e-5f, 4.31519e-5f, 4.36516e-5f, 4.4157e-5f, 4.46684e-5f,
4.51856e-5f, 4.57088e-5f, 4.62381e-5f, 4.67735e-5f, 4.73151e-5f,
4.7863e-5f, 4.84172e-5f, 4.89779e-5f, 4.9545e-5f, 5.01187e-5f,
5.06991e-5f, 5.12861e-5f, 5.188e-5f, 5.24807e-5f, 5.30884e-5f,
5.37032e-5f, 5.4325e-5f, 5.49541e-5f, 5.55904e-5f, 5.62341e-5f,
5.68853e-5f, 5.7544e-5f, 5.82103e-5f, 5.88844e-5f, 5.95662e-5f,
6.0256e-5f, 6.09537e-5f, 6.16595e-5f, 6.23735e-5f, 6.30957e-5f,
6.38263e-5f, 6.45654e-5f, 6.53131e-5f, 6.60693e-5f, 6.68344e-5f,
6.76083e-5f, 6.83912e-5f, 6.91831e-5f, 6.99842e-5f, 7.07946e-5f,
7.16143e-5f, 7.24436e-5f, 7.32825e-5f, 7.4131e-5f, 7.49894e-5f,
7.58578e-5f, 7.67361e-5f, 7.76247e-5f, 7.85236e-5f, 7.94328e-5f,
8.03526e-5f, 8.12831e-5f, 8.22243e-5f, 8.31764e-5f, 8.41395e-5f,
8.51138e-5f, 8.60994e-5f, 8.70964e-5f, 8.81049e-5f, 8.91251e-5f,
9.01571e-5f, 9.12011e-5f, 9.22571e-5f, 9.33254e-5f, 9.44061e-5f,
9.54993e-5f, 9.66051e-5f, 9.77237e-5f, 9.88553e-5f, 1.0e-4f,
1.01158e-4f, 1.02329e-4f, 1.03514e-4f, 1.04713e-4f, 1.05925e-4f,
1.07152e-4f, 1.08393e-4f, 1.09648e-4f, 1.10917e-4f, 1.12202e-4f,
1.13501e-4f, 1.14815e-4f, 1.16145e-4f, 1.1749e-4f, 1.1885e-4f,
1.20226e-4f, 1.21619e-4f, 1.23027e-4f, 1.24451e-4f, 1.25893e-4f,
1.2735e-4f, 1.28825e-4f, 1.30317e-4f, 1.31826e-4f, 1.33352e-4f,
1.34896e-4f, 1.36458e-4f, 1.38038e-4f, 1.39637e-4f, 1.41254e-4f,
1.42889e-4f, 1.44544e-4f, 1.46218e-4f, 1.47911e-4f, 1.49624e-4f,
1.51356e-4f, 1.53109e-4f, 1.54882e-4f, 1.56675e-4f, 1.58489e-4f,
1.60325e-4f, 1.62181e-4f, 1.64059e-4f, 1.65959e-4f, 1.6788e-4f,
1.69824e-4f, 1.71791e-4f, 1.7378e-4f, 1.75792e-4f, 1.77828e-4f,
1.79887e-4f, 1.8197e-4f, 1.84077e-4f, 1.86209e-4f, 1.88365e-4f,
1.90546e-4f, 1.92752e-4f, 1.94984e-4f, 1.97242e-4f, 1.99526e-4f,
2.01837e-4f, 2.04174e-4f, 2.06538e-4f, 2.0893e-4f, 2.11349e-4f,
2.13796e-4f, 2.16272e-4f, 2.18776e-4f, 2.21309e-4f, 2.23872e-4f,
2.26464e-4f, 2.29087e-4f, 2.31739e-4f, 2.34423e-4f, 2.37137e-4f,
2.39883e-4f, 2.42661e-4f, 2.45471e-4f, 2.48313e-4f, 2.51189e-4f,
2.54097e-4f, 2.5704e-4f, 2.60016e-4f, 2.63027e-4f, 2.66073e-4f,
2.69153e-4f, 2.7227e-4f, 2.75423e-4f, 2.78612e-4f, 2.81838e-4f,
2.85102e-4f, 2.88403e-4f, 2.91743e-4f, 2.95121e-4f, 2.98538e-4f,
3.01995e-4f, 3.05492e-4f, 3.0903e-4f, 3.12608e-4f, 3.16228e-4f,
3.1989e-4f, 3.23594e-4f, 3.27341e-4f, 3.31131e-4f, 3.34965e-4f,
3.38844e-4f, 3.42768e-4f, 3.46737e-4f, 3.50752e-4f, 3.54813e-4f,
3.58922e-4f, 3.63078e-4f, 3.67282e-4f, 3.71535e-4f, 3.75837e-4f,
3.80189e-4f, 3.84592e-4f, 3.89045e-4f, 3.9355e-4f, 3.98107e-4f,
4.02717e-4f, 4.0738e-4f, 4.12098e-4f, 4.16869e-4f, 4.21697e-4f,
4.2658e-4f, 4.31519e-4f, 4.36516e-4f, 4.4157e-4f, 4.46684e-4f,
4.51856e-4f, 4.57088e-4f, 4.62381e-4f, 4.67735e-4f, 4.73151e-4f,
4.7863e-4f, 4.84172e-4f, 4.89779e-4f, 4.9545e-4f, 5.01187e-4f,
5.06991e-4f, 5.12861e-4f, 5.188e-4f, 5.24807e-4f, 5.30884e-4f,
5.37032e-4f, 5.4325e-4f, 5.49541e-4f, 5.55904e-4f, 5.62341e-4f,
5.68853e-4f, 5.7544e-4f, 5.82103e-4f, 5.88844e-4f, 5.95662e-4f,
6.0256e-4f, 6.09537e-4f, 6.16595e-4f, 6.23735e-4f, 6.30957e-4f,
6.38263e-4f, 6.45654e-4f, 6.53131e-4f, 6.60693e-4f, 6.68344e-4f,
6.76083e-4f, 6.83912e-4f, 6.91831e-4f, 6.99842e-4f, 7.07946e-4f,
7.16143e-4f, 7.24436e-4f, 7.32825e-4f, 7.4131e-4f, 7.49894e-4f,
7.58578e-4f, 7.67361e-4f, 7.76247e-4f, 7.85236e-4f, 7.94328e-4f,
8.03526e-4f, 8.12831e-4f, 8.22243e-4f, 8.31764e-4f, 8.41395e-4f,
8.51138e-4f, 8.60994e-4f, 8.70964e-4f, 8.81049e-4f, 8.91251e-4f,
9.01571e-4f, 9.12011e-4f, 9.22571e-4f, 9.33254e-4f, 9.44061e-4f,
9.54993e-4f, 9.66051e-4f, 9.77237e-4f, 9.88553e-4f, 0.001f,
0.001011579f, 0.001023293f, 0.001035142f, 0.001047129f, 0.001059254f,
0.001071519f, 0.001083927f, 0.001096478f, 0.001109175f, 0.001122018f,
0.001135011f, 0.001148154f, 0.001161449f, 0.001174898f, 0.001188502f,
0.001202264f, 0.001216186f, 0.001230269f, 0.001244515f, 0.001258925f,
0.001273503f, 0.00128825f, 0.001303167f, 0.001318257f, 0.001333521f,
0.001348963f, 0.001364583f, 0.001380384f, 0.001396368f, 0.001412538f,
0.001428894f, 0.00144544f, 0.001462177f, 0.001479108f, 0.001496236f,
0.001513561f, 0.001531087f, 0.001548817f, 0.001566751f, 0.001584893f,
0.001603245f, 0.00162181f, 0.00164059f, 0.001659587f, 0.001678804f,
0.001698244f, 0.001717908f, 0.001737801f, 0.001757924f, 0.001778279f,
0.001798871f, 0.001819701f, 0.001840772f, 0.001862087f, 0.001883649f,
0.001905461f, 0.001927525f, 0.001949845f, 0.001972423f, 0.001995262f,
0.002018366f, 0.002041738f, 0.00206538f, 0.002089296f, 0.002113489f,
0.002137962f, 0.002162719f, 0.002187762f, 0.002213095f, 0.002238721f,
0.002264644f, 0.002290868f, 0.002317395f, 0.002344229f, 0.002371374f,
0.002398833f, 0.00242661f, 0.002454709f, 0.002483133f, 0.002511886f,
0.002540973f, 0.002570396f, 0.00260016f, 0.002630268f, 0.002660725f,
0.002691535f, 0.002722701f, 0.002754229f, 0.002786121f, 0.002818383f,
0.002851018f, 0.002884032f, 0.002917427f, 0.002951209f, 0.002985383f,
0.003019952f, 0.003054921f, 0.003090295f, 0.003126079f, 0.003162278f,
0.003198895f, 0.003235937f, 0.003273407f, 0.003311311f, 0.003349654f,
0.003388442f, 0.003427678f, 0.003467369f, 0.003507519f, 0.003548134f,
0.003589219f, 0.003630781f, 0.003672823f, 0.003715352f, 0.003758374f,
0.003801894f, 0.003845918f, 0.003890451f, 0.003935501f, 0.003981072f,
0.00402717f, 0.004073803f, 0.004120975f, 0.004168694f, 0.004216965f,
0.004265795f, 0.004315191f, 0.004365158f, 0.004415704f, 0.004466836f,
0.004518559f, 0.004570882f, 0.00462381f, 0.004677351f, 0.004731513f,
0.004786301f, 0.004841724f, 0.004897788f, 0.004954502f, 0.005011872f,
0.005069907f, 0.005128614f, 0.005188f, 0.005248075f, 0.005308844f,
0.005370318f, 0.005432503f, 0.005495409f, 0.005559043f, 0.005623413f,
0.005688529f, 0.005754399f, 0.005821032f, 0.005888437f, 0.005956621f,
0.006025596f, 0.006095369f, 0.00616595f, 0.006237348f, 0.006309573f,
0.006382635f, 0.006456542f, 0.006531306f, 0.006606934f, 0.006683439f,
0.00676083f, 0.006839116f, 0.00691831f, 0.00699842f, 0.007079458f,
0.007161434f, 0.00724436f, 0.007328245f, 0.007413102f, 0.007498942f,
0.007585776f, 0.007673615f, 0.007762471f, 0.007852356f, 0.007943282f,
0.008035261f, 0.008128305f, 0.008222426f, 0.008317638f, 0.008413951f,
0.00851138f, 0.008609938f, 0.008709636f, 0.008810489f, 0.008912509f,
0.009015711f, 0.009120108f, 0.009225714f, 0.009332543f, 0.009440609f,
0.009549926f, 0.009660509f, 0.009772372f, 0.009885531f, 0.01f,
0.010115795f, 0.01023293f, 0.010351422f, 0.010471285f, 0.010592537f,
0.010715193f, 0.010839269f, 0.010964782f, 0.011091748f, 0.011220185f,
0.011350108f, 0.011481536f, 0.011614486f, 0.011748976f, 0.011885022f,
0.012022644f, 0.01216186f, 0.012302688f, 0.012445146f, 0.012589254f,
0.012735031f, 0.012882496f, 0.013031668f, 0.013182567f, 0.013335214f,
0.013489629f, 0.013645831f, 0.013803843f, 0.013963684f, 0.014125375f,
0.01428894f, 0.014454398f, 0.014621772f, 0.014791084f, 0.014962357f,
0.015135612f, 0.015310875f, 0.015488166f, 0.015667511f, 0.015848933f,
0.016032454f, 0.016218102f, 0.016405897f, 0.016595868f, 0.01678804f,
0.016982436f, 0.017179083f, 0.017378008f, 0.017579235f, 0.017782794f,
0.01798871f, 0.01819701f, 0.01840772f, 0.018620871f, 0.01883649f,
0.019054607f, 0.01927525f, 0.019498445f, 0.019724227f, 0.019952623f,
0.020183664f, 0.02041738f, 0.020653803f, 0.020892961f, 0.02113489f,
0.021379622f, 0.021627186f, 0.021877617f, 0.022130948f, 0.02238721f,
0.022646444f, 0.022908676f, 0.023173947f, 0.023442289f, 0.023713738f,
0.023988329f, 0.024266101f, 0.024547089f, 0.02483133f, 0.025118863f,
0.025409726f, 0.025703957f, 0.026001597f, 0.02630268f, 0.02660725f,
0.026915347f, 0.027227012f, 0.027542287f, 0.027861211f, 0.028183829f,
0.028510183f, 0.028840315f, 0.02917427f, 0.029512092f, 0.029853826f,
0.030199517f, 0.030549211f, 0.030902954f, 0.031260792f, 0.03162278f,
0.031988952f, 0.032359365f, 0.03273407f, 0.03311311f, 0.033496544f,
0.033884417f, 0.03427678f, 0.034673683f, 0.035075188f, 0.035481337f,
0.035892192f, 0.036307804f, 0.03672823f, 0.037153523f, 0.03758374f,
0.03801894f, 0.038459178f, 0.038904514f, 0.03935501f, 0.039810717f,
0.040271703f, 0.040738028f, 0.041209754f, 0.041686937f, 0.04216965f,
0.042657953f, 0.043151908f, 0.043651585f, 0.044157047f, 0.044668358f,
0.045185596f, 0.04570882f, 0.046238102f, 0.046773516f, 0.047315124f,
0.04786301f, 0.048417237f, 0.04897788f, 0.04954502f, 0.050118722f,
0.05069907f, 0.05128614f, 0.051880006f, 0.052480746f, 0.053088445f,
0.05370318f, 0.054325033f, 0.054954085f, 0.055590425f, 0.056234132f,
0.056885295f, 0.057543993f, 0.05821032f, 0.058884367f, 0.059566215f,
0.06025596f, 0.06095369f, 0.0616595f, 0.062373485f, 0.06309573f,
0.06382635f, 0.06456542f, 0.065313056f, 0.06606934f, 0.06683439f,
0.0676083f, 0.06839117f, 0.0691831f, 0.0699842f, 0.070794575f,
0.07161434f, 0.0724436f, 0.07328245f, 0.07413103f, 0.07498942f,
0.07585776f, 0.07673615f, 0.07762471f, 0.07852356f, 0.07943282f,
0.08035261f, 0.081283055f, 0.082224265f, 0.083176374f, 0.08413951f,
0.0851138f, 0.08609937f, 0.087096356f, 0.08810489f, 0.0891251f,
0.090157114f, 0.09120108f, 0.09225714f, 0.09332543f, 0.09440609f,
0.09549926f, 0.096605085f, 0.09772372f, 0.09885531f, 0.1f,
0.10115795f, 0.1023293f, 0.10351422f, 0.10471285f, 0.105925374f,
0.10715193f, 0.10839269f, 0.10964782f, 0.11091748f, 0.11220185f,
0.11350108f, 0.11481536f, 0.11614486f, 0.117489755f, 0.11885022f,
0.12022644f, 0.1216186f, 0.12302688f, 0.12445146f, 0.12589253f,
0.1273503f, 0.12882495f, 0.13031667f, 0.13182567f, 0.13335215f,
0.1348963f, 0.13645831f, 0.13803843f, 0.13963683f, 0.14125375f,
0.1428894f, 0.14454398f, 0.14621772f, 0.14791083f, 0.14962357f,
0.15135613f, 0.15310875f, 0.15488166f, 0.1566751f, 0.15848932f,
0.16032454f, 0.162181f, 0.16405898f, 0.16595869f, 0.1678804f,
0.16982436f, 0.17179084f, 0.17378008f, 0.17579237f, 0.17782794f,
0.17988709f, 0.18197009f, 0.1840772f, 0.18620871f, 0.18836491f,
0.19054607f, 0.1927525f, 0.19498447f, 0.19724227f, 0.19952624f,
0.20183663f, 0.20417379f, 0.20653802f, 0.20892961f, 0.2113489f,
0.21379621f, 0.21627185f, 0.21877617f, 0.22130947f, 0.22387211f,
0.22646444f, 0.22908677f, 0.23173946f, 0.23442288f, 0.23713738f,
0.23988329f, 0.24266101f, 0.2454709f, 0.24831331f, 0.25118864f,
0.25409728f, 0.25703958f, 0.26001596f, 0.2630268f, 0.2660725f,
0.26915348f, 0.27227014f, 0.27542287f, 0.2786121f, 0.2818383f,
0.28510183f, 0.28840315f, 0.2917427f, 0.29512092f, 0.29853827f,
0.30199516f, 0.3054921f, 0.30902955f, 0.31260794f, 0.31622776f,
0.31988952f, 0.32359365f, 0.3273407f, 0.33113113f, 0.33496544f,
0.33884415f, 0.34276778f, 0.34673685f, 0.35075188f, 0.3548134f,
0.35892195f, 0.36307806f, 0.3672823f, 0.37153524f, 0.37583742f,
0.3801894f, 0.3845918f, 0.38904515f, 0.39355007f, 0.39810717f,
0.40271702f, 0.40738028f, 0.4120975f, 0.41686937f, 0.4216965f,
0.4265795f, 0.4315191f, 0.43651584f, 0.44157046f, 0.4466836f,
0.45185596f, 0.4570882f, 0.46238104f, 0.46773514f, 0.47315127f,
0.4786301f, 0.48417237f, 0.48977882f, 0.4954502f, 0.5011872f,
0.50699073f, 0.5128614f, 0.5188f, 0.52480745f, 0.53088444f,
0.53703177f, 0.5432503f, 0.5495409f, 0.55590427f, 0.56234133f,
0.5688529f, 0.57543993f, 0.5821032f, 0.58884364f, 0.5956621f,
0.60255957f, 0.6095369f, 0.61659503f, 0.62373483f, 0.63095737f,
0.63826346f, 0.6456542f, 0.65313053f, 0.66069347f, 0.6683439f,
0.67608297f, 0.6839116f, 0.691831f, 0.699842f, 0.70794576f,
0.7161434f, 0.724436f, 0.7328245f, 0.74131024f, 0.7498942f,
0.7585776f, 0.76736146f, 0.77624714f, 0.78523564f, 0.7943282f,
0.8035261f, 0.8128305f, 0.8222427f, 0.83176374f, 0.84139514f,
0.85113806f, 0.86099374f, 0.8709636f, 0.88104886f, 0.8912509f,
0.90157115f, 0.91201085f, 0.9225714f, 0.9332543f, 0.94406086f,
0.9549926f, 0.96605086f, 0.9772372f, 0.9885531f, 1.0f,
1.0115795f, 1.023293f, 1.0351422f, 1.0471286f, 1.0592537f,
1.0715193f, 1.0839269f, 1.0964782f, 1.1091748f, 1.1220185f,
1.1350108f, 1.1481537f, 1.1614486f, 1.1748976f, 1.1885022f,
1.2022644f, 1.216186f, 1.2302687f, 1.2445146f, 1.2589254f,
1.2735031f, 1.2882495f, 1.3031667f, 1.3182567f, 1.3335215f,
1.3489629f, 1.3645831f, 1.3803842f, 1.3963684f, 1.4125376f,
1.4288939f, 1.4454398f, 1.4621772f, 1.4791083f, 1.4962356f,
1.5135612f, 1.5310875f, 1.5488166f, 1.5667511f, 1.5848932f,
1.6032454f, 1.6218101f, 1.6405897f, 1.6595869f, 1.678804f,
1.6982436f, 1.7179084f, 1.7378008f, 1.7579236f, 1.7782794f,
1.7988709f, 1.8197008f, 1.840772f, 1.8620871f, 1.8836491f,
1.9054607f, 1.9275249f, 1.9498446f, 1.9724227f, 1.9952623f
};
f32 const Util::Pan2RatioTableSqrt[PAN_TABLE_SIZE] =
{
1.0f, 0.99804497f, 0.9960861f, 0.99412334f, 0.99215674f,
0.9901862f, 0.98821175f, 0.98623335f, 0.98425096f, 0.9822646f,
0.9802742f, 0.97827977f, 0.9762812f, 0.97427857f, 0.9722718f,
0.9702609f, 0.96824586f, 0.9662266f, 0.96420306f, 0.96217525f,
0.9601432f, 0.9581069f, 0.95606613f, 0.9540211f, 0.95197165f,
0.94991773f, 0.9478594f, 0.9457966f, 0.9437293f, 0.9416574f,
0.93958104f, 0.9375f, 0.9354144f, 0.93332404f, 0.93122905f,
0.9291293f, 0.9270248f, 0.92491555f, 0.92280143f, 0.9206825f,
0.91855866f, 0.9164299f, 0.91429615f, 0.9121575f, 0.91001374f,
0.9078649f, 0.90571105f, 0.903552f, 0.9013878f, 0.89921844f,
0.89704376f, 0.89486384f, 0.89267856f, 0.8904879f, 0.8882919f,
0.88609046f, 0.8838835f, 0.881671f, 0.87945294f, 0.8772293f,
0.875f, 0.872765f, 0.8705243f, 0.8682777f, 0.8660254f,
0.8637672f, 0.86150306f, 0.85923296f, 0.85695684f, 0.85467464f,
0.85238636f, 0.85009193f, 0.84779125f, 0.8454843f, 0.8431711f,
0.8408515f, 0.8385255f, 0.836193f, 0.833854f, 0.8315084f,
0.8291562f, 0.8267973f, 0.8244316f, 0.82205915f, 0.8196798f,
0.8172935f, 0.8149003f, 0.8125f, 0.81009257f, 0.807678f,
0.8052562f, 0.80282706f, 0.80039054f, 0.7979466f, 0.79549515f,
0.7930361f, 0.7905694f, 0.788095f, 0.7856128f, 0.7831228f,
0.78062475f, 0.7781187f, 0.7756046f, 0.7730823f, 0.77055174f,
0.7680129f, 0.76546556f, 0.7629097f, 0.76034534f, 0.7577722f,
0.7551904f, 0.75259966f, 0.75f, 0.7473913f, 0.74477345f,
0.7421464f, 0.73951f, 0.73686415f, 0.73420876f, 0.7315437f,
0.72886896f, 0.72618437f, 0.7234898f, 0.72078514f, 0.7180703f,
0.7153452f, 0.71260965f, 0.70986354f, 0.70710677f, 0.7043392f,
0.70156074f, 0.69877124f, 0.69597054f, 0.6931585f, 0.69033504f,
0.6875f, 0.6846532f, 0.6817945f, 0.6789238f, 0.6760409f,
0.6731456f, 0.67023784f, 0.6673174f, 0.6643841f, 0.6614378f,
0.6584784f, 0.65550554f, 0.65251917f, 0.649519f, 0.646505f,
0.6434769f, 0.64043444f, 0.63737744f, 0.6343057f, 0.631219f,
0.6281172f, 0.625f, 0.6218671f, 0.61871845f, 0.6155536f,
0.61237246f, 0.60917467f, 0.60596f, 0.6027282f, 0.59947896f,
0.596212f, 0.59292704f, 0.5896238f, 0.586302f, 0.5829612f,
0.57960117f, 0.5762215f, 0.572822f, 0.5694021f, 0.5659616f,
0.5625f, 0.559017f, 0.55551213f, 0.551985f, 0.5484353f,
0.5448624f, 0.5412659f, 0.53764534f, 0.5340002f, 0.53033006f,
0.52663434f, 0.5229125f, 0.51916397f, 0.5153882f, 0.5115845f,
0.5077524f, 0.5038911f, 0.5f, 0.49607837f, 0.49212548f,
0.4881406f, 0.48412293f, 0.4800716f, 0.47598583f, 0.47186464f,
0.4677072f, 0.4635124f, 0.45927933f, 0.45500687f, 0.4506939f,
0.44633928f, 0.44194174f, 0.4375f, 0.4330127f, 0.42847842f,
0.42389563f, 0.41926274f, 0.4145781f, 0.4098399f, 0.40504628f,
0.40019527f, 0.3952847f, 0.39031237f, 0.38527587f, 0.38017267f,
0.375f, 0.369755f, 0.36443448f, 0.35903516f, 0.35355338f,
0.34798527f, 0.3423266f, 0.3365728f, 0.3307189f, 0.3247595f,
0.31868872f, 0.3125f, 0.30618623f, 0.29973948f, 0.293151f,
0.286411f, 0.2795085f, 0.2724312f, 0.26516503f, 0.2576941f,
0.25f, 0.24206147f, 0.2338536f, 0.22534695f, 0.21650635f,
0.20728905f, 0.19764236f, 0.1875f, 0.17677669f, 0.16535945f,
0.15309311f, 0.13975425f, 0.125f, 0.10825317f, 0.088388346f,
0.0625f, 0.0f
};
f32 const Util::Pan2RatioTableSinCos[PAN_TABLE_SIZE] =
{
1.0f, 0.99998116f, 0.9999247f, 0.9998306f, 0.9996988f,
0.9995294f, 0.9993224f, 0.99907774f, 0.99879545f, 0.99847555f,
0.9981181f, 0.99772304f, 0.99729043f, 0.9968203f, 0.9963126f,
0.9957674f, 0.9951847f, 0.9945646f, 0.993907f, 0.9932119f,
0.99247956f, 0.99170977f, 0.99090266f, 0.9900582f, 0.9891765f,
0.9882576f, 0.9873014f, 0.9863081f, 0.98527765f, 0.9842101f,
0.9831055f, 0.9819639f, 0.98078525f, 0.9795698f, 0.9783174f,
0.97702813f, 0.9757021f, 0.97433937f, 0.97293997f, 0.9715039f,
0.97003126f, 0.9685221f, 0.96697646f, 0.96539444f, 0.96377605f,
0.9621214f, 0.9604305f, 0.95870346f, 0.95694035f, 0.9551412f,
0.953306f, 0.951435f, 0.94952816f, 0.9475856f, 0.9456073f,
0.94359344f, 0.94154406f, 0.9394592f, 0.937339f, 0.9351835f,
0.9329928f, 0.93076694f, 0.9285061f, 0.9262102f, 0.9238795f,
0.92151403f, 0.9191139f, 0.9166791f, 0.9142098f, 0.91170603f,
0.909168f, 0.9065957f, 0.9039893f, 0.9013488f, 0.8986745f,
0.89596623f, 0.8932243f, 0.89044875f, 0.88763964f, 0.8847971f,
0.8819213f, 0.8790122f, 0.8760701f, 0.873095f, 0.87008697f,
0.86704624f, 0.86397284f, 0.86086696f, 0.8577286f, 0.854558f,
0.8513552f, 0.84812033f, 0.8448536f, 0.841555f, 0.8382247f,
0.8348629f, 0.8314696f, 0.82804507f, 0.8245893f, 0.8211025f,
0.8175848f, 0.8140363f, 0.81045717f, 0.8068476f, 0.8032075f,
0.79953724f, 0.7958369f, 0.79210657f, 0.7883464f, 0.78455657f,
0.7807372f, 0.7768885f, 0.77301043f, 0.76910335f, 0.76516724f,
0.7612024f, 0.7572088f, 0.7531868f, 0.7491364f, 0.74505776f,
0.7409511f, 0.7368166f, 0.7326543f, 0.72846437f, 0.7242471f,
0.72000253f, 0.71573085f, 0.7114322f, 0.70710677f, 0.70275474f,
0.69837624f, 0.69397146f, 0.68954057f, 0.6850837f, 0.680601f,
0.6760927f, 0.671559f, 0.66699994f, 0.6624158f, 0.6578067f,
0.65317285f, 0.6485144f, 0.64383155f, 0.63912445f, 0.6343933f,
0.62963825f, 0.6248595f, 0.6200572f, 0.6152316f, 0.6103828f,
0.60551107f, 0.60061646f, 0.5956993f, 0.5907597f, 0.58579785f,
0.58081394f, 0.57580817f, 0.57078075f, 0.5657318f, 0.56066155f,
0.55557024f, 0.55045795f, 0.545325f, 0.54017144f, 0.53499764f,
0.52980363f, 0.52458966f, 0.519356f, 0.51410276f, 0.50883013f,
0.50353837f, 0.49822766f, 0.4928982f, 0.48755017f, 0.48218378f,
0.47679922f, 0.47139674f, 0.4659765f, 0.46053872f, 0.45508358f,
0.44961134f, 0.44412214f, 0.43861625f, 0.43309382f, 0.42755508f,
0.42200026f, 0.41642955f, 0.41084316f, 0.4052413f, 0.3996242f,
0.39399204f, 0.38834503f, 0.38268343f, 0.37700742f, 0.3713172f,
0.36561298f, 0.35989505f, 0.35416353f, 0.34841868f, 0.34266073f,
0.33688986f, 0.3311063f, 0.3253103f, 0.31950203f, 0.31368175f,
0.30784965f, 0.30200595f, 0.2961509f, 0.29028466f, 0.28440753f,
0.2785197f, 0.27262136f, 0.26671275f, 0.2607941f, 0.25486565f,
0.24892761f, 0.24298018f, 0.2370236f, 0.2310581f, 0.22508392f,
0.21910124f, 0.21311031f, 0.20711137f, 0.20110464f, 0.19509032f,
0.18906866f, 0.18303989f, 0.17700422f, 0.17096189f, 0.16491312f,
0.15885815f, 0.15279719f, 0.14673047f, 0.14065824f, 0.1345807f,
0.1284981f, 0.12241068f, 0.11631863f, 0.110222206f, 0.10412163f,
0.09801714f, 0.091908954f, 0.08579731f, 0.07968244f, 0.07356457f,
0.06744392f, 0.061320737f, 0.055195242f, 0.049067672f, 0.04293826f,
0.036807224f, 0.030674802f, 0.024541229f, 0.01840673f, 0.012271538f,
0.006135885f, 0.0f
};
f32 const Util::Pan2RatioTableLinear[PAN_TABLE_SIZE] =
{
1.0f, 0.99609375f, 0.9921875f, 0.98828125f, 0.984375f,
0.98046875f, 0.9765625f, 0.97265625f, 0.96875f, 0.96484375f,
0.9609375f, 0.95703125f, 0.953125f, 0.94921875f, 0.9453125f,
0.94140625f, 0.9375f, 0.93359375f, 0.9296875f, 0.92578125f,
0.921875f, 0.91796875f, 0.9140625f, 0.91015625f, 0.90625f,
0.90234375f, 0.8984375f, 0.89453125f, 0.890625f, 0.88671875f,
0.8828125f, 0.87890625f, 0.875f, 0.87109375f, 0.8671875f,
0.86328125f, 0.859375f, 0.85546875f, 0.8515625f, 0.84765625f,
0.84375f, 0.83984375f, 0.8359375f, 0.83203125f, 0.828125f,
0.82421875f, 0.8203125f, 0.81640625f, 0.8125f, 0.80859375f,
0.8046875f, 0.80078125f, 0.796875f, 0.79296875f, 0.7890625f,
0.78515625f, 0.78125f, 0.77734375f, 0.7734375f, 0.76953125f,
0.765625f, 0.76171875f, 0.7578125f, 0.75390625f, 0.75f,
0.74609375f, 0.7421875f, 0.73828125f, 0.734375f, 0.73046875f,
0.7265625f, 0.72265625f, 0.71875f, 0.71484375f, 0.7109375f,
0.70703125f, 0.703125f, 0.69921875f, 0.6953125f, 0.69140625f,
0.6875f, 0.68359375f, 0.6796875f, 0.67578125f, 0.671875f,
0.66796875f, 0.6640625f, 0.66015625f, 0.65625f, 0.65234375f,
0.6484375f, 0.64453125f, 0.640625f, 0.63671875f, 0.6328125f,
0.62890625f, 0.625f, 0.62109375f, 0.6171875f, 0.61328125f,
0.609375f, 0.60546875f, 0.6015625f, 0.59765625f, 0.59375f,
0.58984375f, 0.5859375f, 0.58203125f, 0.578125f, 0.57421875f,
0.5703125f, 0.56640625f, 0.5625f, 0.55859375f, 0.5546875f,
0.55078125f, 0.546875f, 0.54296875f, 0.5390625f, 0.53515625f,
0.53125f, 0.52734375f, 0.5234375f, 0.51953125f, 0.515625f,
0.51171875f, 0.5078125f, 0.50390625f, 0.5f, 0.49609375f,
0.4921875f, 0.48828125f, 0.484375f, 0.48046875f, 0.4765625f,
0.47265625f, 0.46875f, 0.46484375f, 0.4609375f, 0.45703125f,
0.453125f, 0.44921875f, 0.4453125f, 0.44140625f, 0.4375f,
0.43359375f, 0.4296875f, 0.42578125f, 0.421875f, 0.41796875f,
0.4140625f, 0.41015625f, 0.40625f, 0.40234375f, 0.3984375f,
0.39453125f, 0.390625f, 0.38671875f, 0.3828125f, 0.37890625f,
0.375f, 0.37109375f, 0.3671875f, 0.36328125f, 0.359375f,
0.35546875f, 0.3515625f, 0.34765625f, 0.34375f, 0.33984375f,
0.3359375f, 0.33203125f, 0.328125f, 0.32421875f, 0.3203125f,
0.31640625f, 0.3125f, 0.30859375f, 0.3046875f, 0.30078125f,
0.296875f, 0.29296875f, 0.2890625f, 0.28515625f, 0.28125f,
0.27734375f, 0.2734375f, 0.26953125f, 0.265625f, 0.26171875f,
0.2578125f, 0.25390625f, 0.25f, 0.24609375f, 0.2421875f,
0.23828125f, 0.234375f, 0.23046875f, 0.2265625f, 0.22265625f,
0.21875f, 0.21484375f, 0.2109375f, 0.20703125f, 0.203125f,
0.19921875f, 0.1953125f, 0.19140625f, 0.1875f, 0.18359375f,
0.1796875f, 0.17578125f, 0.171875f, 0.16796875f, 0.1640625f,
0.16015625f, 0.15625f, 0.15234375f, 0.1484375f, 0.14453125f,
0.140625f, 0.13671875f, 0.1328125f, 0.12890625f, 0.125f,
0.12109375f, 0.1171875f, 0.11328125f, 0.109375f, 0.10546875f,
0.1015625f, 0.09765625f, 0.09375f, 0.08984375f, 0.0859375f,
0.08203125f, 0.078125f, 0.07421875f, 0.0703125f, 0.06640625f,
0.0625f, 0.05859375f, 0.0546875f, 0.05078125f, 0.046875f,
0.04296875f, 0.0390625f, 0.03515625f, 0.03125f, 0.02734375f,
0.0234375f, 0.01953125f, 0.015625f, 0.01171875f, 0.0078125f,
0.00390625f, 0.0f
};
u16 const Util::RemoteFilterCoefTable[COEF_TABLE_SIZE][BIQUAD_COEF_COUNT] =
{
/* b0 b1 b2 a1 a2 */
{0x387c, 0x70f7, 0x387c, 0x8144, 0xc13e},
{0x3549, 0x6a93, 0x3549, 0x88e9, 0xc7f2},
{0x31c4, 0x6389, 0x31c4, 0x9211, 0xce95},
{0x2e7c, 0x5cf9, 0x2e7c, 0x9b3e, 0xd422},
{0x2b6f, 0x56de, 0x2b6f, 0xa44c, 0xd8c7},
{0x2899, 0x5133, 0x2899, 0xad24, 0xdca7},
{0x25f7, 0x4bee, 0x25f7, 0xb5ba, 0xdfe4},
{0x2384, 0x4709, 0x2384, 0xbe07, 0xe294},
{0x213d, 0x427a, 0x213d, 0xc608, 0xe4ce},
{0x1f1d, 0x3e3a, 0x1f1d, 0xcdbc, 0xe6a2},
{0x1d22, 0x3a44, 0x1d22, 0xd525, 0xe81d},
{0x1b48, 0x3690, 0x1b48, 0xdc45, 0xe94c},
{0x198d, 0x331a, 0x198d, 0xe31d, 0xea39},
{0x17ee, 0x2fdc, 0x17ee, 0xe9b0, 0xeaec},
{0x1669, 0x2cd2, 0x1669, 0xf001, 0xeb6c},
{0x14fd, 0x29f9, 0x14fd, 0xf613, 0xebbe},
{0x13a7, 0x274d, 0x13a7, 0xfbe7, 0xebe9},
{0x1265, 0x24cb, 0x1265, 0x0180, 0xebf1},
{0x1138, 0x2270, 0x1138, 0x06e2, 0xebd9},
{0x101c, 0x2039, 0x101c, 0x0c0d, 0xeba6},
{0x0f12, 0x1e24, 0x0f12, 0x1104, 0xeb5a},
{0x0e18, 0x1c30, 0x0e18, 0x15c9, 0xeaf8},
{0x0d2d, 0x1a59, 0x0d2d, 0x1a5d, 0xea84},
{0x0c50, 0x189f, 0x0c50, 0x1ec3, 0xe9fe},
{0x0b80, 0x1700, 0x0b80, 0x22fc, 0xe969},
{0x0abd, 0x1579, 0x0abd, 0x270a, 0xe8c7},
{0x0a05, 0x140b, 0x0a05, 0x2aed, 0xe81a},
{0x0959, 0x12b3, 0x0959, 0x2ea9, 0xe763},
{0x08b8, 0x1170, 0x08b8, 0x323d, 0xe6a3},
{0x0820, 0x1041, 0x0820, 0x35ac, 0xe5dd},
{0x0792, 0x0f25, 0x0792, 0x38f6, 0xe510},
{0x070d, 0x0e1a, 0x070d, 0x3c1d, 0xe43e},
{0x0690, 0x0d21, 0x0690, 0x3f23, 0xe369},
{0x061b, 0x0c37, 0x061b, 0x4208, 0xe290},
{0x05ae, 0x0b5c, 0x05ae, 0x44cd, 0xe1b6},
{0x0548, 0x0a90, 0x0548, 0x4774, 0xe0da},
{0x04e8, 0x09d0, 0x04e8, 0x49fe, 0xdffd},
{0x048f, 0x091e, 0x048f, 0x4c6c, 0xdf20},
{0x043b, 0x0877, 0x043b, 0x4ebf, 0xde44},
{0x03ed, 0x07db, 0x03ed, 0x50f8, 0xdd69},
{0x03a5, 0x0749, 0x03a5, 0x5317, 0xdc90},
{0x0361, 0x06c2, 0x0361, 0x551f, 0xdbb8},
{0x0322, 0x0643, 0x0322, 0x5710, 0xdae3},
{0x02e7, 0x05ce, 0x02e7, 0x58ea, 0xda11},
{0x02b0, 0x0560, 0x02b0, 0x5aaf, 0xd941},
{0x027d, 0x04fa, 0x027d, 0x5c60, 0xd875},
{0x024e, 0x049b, 0x024e, 0x5dfe, 0xd7ad},
{0x0222, 0x0443, 0x0222, 0x5f88, 0xd6e8},
{0x01f9, 0x03f1, 0x01f9, 0x6101, 0xd627},
{0x01d3, 0x03a5, 0x01d3, 0x6269, 0xd56a},
{0x01af, 0x035f, 0x01af, 0x63c0, 0xd4b1},
{0x018f, 0x031d, 0x018f, 0x6507, 0xd3fc},
{0x0170, 0x02e1, 0x0170, 0x6640, 0xd34c},
{0x0154, 0x02a8, 0x0154, 0x676a, 0xd2a0},
{0x013a, 0x0274, 0x013a, 0x6887, 0xd1f9},
{0x0122, 0x0244, 0x0122, 0x6996, 0xd156},
{0x010c, 0x0217, 0x010c, 0x6a99, 0xd0b7},
{0x00f7, 0x01ee, 0x00f7, 0x6b90, 0xd01d},
{0x00e4, 0x01c7, 0x00e4, 0x6c7c, 0xcf87},
{0x00d2, 0x01a4, 0x00d2, 0x6d5d, 0xcef6},
{0x00c2, 0x0183, 0x00c2, 0x6e33, 0xce69},
{0x00b2, 0x0165, 0x00b2, 0x6f00, 0xcde0},
{0x00a4, 0x0149, 0x00a4, 0x6fc3, 0xcd5c},
{0x0098, 0x012f, 0x0098, 0x707d, 0xccdc},
{0x008c, 0x0117, 0x008c, 0x712f, 0xcc60},
{0x0081, 0x0101, 0x0081, 0x71d9, 0xcbe7},
{0x0076, 0x00ed, 0x0076, 0x727a, 0xcb73},
{0x006d, 0x00da, 0x006d, 0x7315, 0xcb03},
{0x0064, 0x00c9, 0x0064, 0x73a8, 0xca97},
{0x005c, 0x00b9, 0x005c, 0x7434, 0xca2e},
{0x0055, 0x00aa, 0x0055, 0x74bb, 0xc9c9},
{0x004e, 0x009c, 0x004e, 0x753b, 0xc967},
{0x0048, 0x0090, 0x0048, 0x75b5, 0xc909},
{0x0042, 0x0084, 0x0042, 0x7629, 0xc8af},
{0x003d, 0x007a, 0x003d, 0x7699, 0xc857},
{0x0038, 0x0070, 0x0038, 0x7703, 0xc803},
{0x0033, 0x0067, 0x0033, 0x7768, 0xc7b1},
{0x002f, 0x005f, 0x002f, 0x77c9, 0xc763},
{0x002c, 0x0057, 0x002c, 0x7826, 0xc718},
{0x0028, 0x0050, 0x0028, 0x787e, 0xc6cf},
{0x0025, 0x004a, 0x0025, 0x78d2, 0xc689},
{0x0022, 0x0044, 0x0022, 0x7923, 0xc646},
{0x001f, 0x003e, 0x001f, 0x7970, 0xc606},
{0x001d, 0x0039, 0x001d, 0x79b9, 0xc5c7},
{0x001a, 0x0034, 0x001a, 0x7a00, 0xc58c},
{0x0018, 0x0030, 0x0018, 0x7a43, 0xc552},
{0x0016, 0x002c, 0x0016, 0x7a83, 0xc51b},
{0x0014, 0x0029, 0x0014, 0x7ac0, 0xc4e6},
{0x0013, 0x0025, 0x0013, 0x7afb, 0xc4b3},
{0x0011, 0x0022, 0x0011, 0x7b32, 0xc482},
{0x0010, 0x0020, 0x0010, 0x7b68, 0xc452},
{0x000e, 0x001d, 0x000e, 0x7b9b, 0xc425},
{0x000d, 0x001b, 0x000d, 0x7bcc, 0xc3fa},
{0x000c, 0x0018, 0x000c, 0x7bfa, 0xc3d0},
{0x000b, 0x0016, 0x000b, 0x7c27, 0xc3a8},
{0x000a, 0x0015, 0x000a, 0x7c52, 0xc381},
{0x0009, 0x0013, 0x0009, 0x7c7a, 0xc35c},
{0x0009, 0x0011, 0x0009, 0x7ca1, 0xc339},
{0x0008, 0x0010, 0x0008, 0x7cc7, 0xc317},
{0x0007, 0x000f, 0x0007, 0x7cea, 0xc2f6},
{0x0007, 0x000d, 0x0007, 0x7d0c, 0xc2d7},
{0x0006, 0x000c, 0x0006, 0x7d2d, 0xc2b9},
{0x0006, 0x000b, 0x0006, 0x7d4c, 0xc29c},
{0x0005, 0x000a, 0x0005, 0x7d6a, 0xc280},
{0x0005, 0x000a, 0x0005, 0x7d86, 0xc265},
{0x0004, 0x0009, 0x0004, 0x7da1, 0xc24c},
{0x0004, 0x0008, 0x0004, 0x7dbb, 0xc234},
{0x0004, 0x0007, 0x0004, 0x7dd4, 0xc21c},
{0x0003, 0x0007, 0x0003, 0x7dec, 0xc206},
{0x0003, 0x0006, 0x0003, 0x7e03, 0xc1f0},
{0x0003, 0x0006, 0x0003, 0x7e19, 0xc1db},
{0x0003, 0x0005, 0x0003, 0x7e2e, 0xc1c8},
{0x0002, 0x0005, 0x0002, 0x7e42, 0xc1b5},
{0x0002, 0x0004, 0x0002, 0x7e55, 0xc1a2},
{0x0002, 0x0004, 0x0002, 0x7e67, 0xc191},
{0x0002, 0x0004, 0x0002, 0x7e79, 0xc180},
{0x0002, 0x0003, 0x0002, 0x7e89, 0xc170},
{0x0002, 0x0003, 0x0002, 0x7e99, 0xc161},
{0x0001, 0x0003, 0x0001, 0x7ea9, 0xc152},
{0x0001, 0x0003, 0x0001, 0x7eb7, 0xc144},
{0x0001, 0x0002, 0x0001, 0x7ec5, 0xc136},
{0x0001, 0x0002, 0x0001, 0x7ed3, 0xc129},
{0x0001, 0x0002, 0x0001, 0x7ee0, 0xc11d},
{0x0001, 0x0002, 0x0001, 0x7eec, 0xc111},
{0x0001, 0x0002, 0x0001, 0x7ef8, 0xc105},
{0x0001, 0x0002, 0x0001, 0x7f03, 0xc0fa},
{0x0001, 0x0001, 0x0001, 0x7f0e, 0xc0f0},
{0x0001, 0x0001, 0x0001, 0x7f18, 0xc0e6}
};
u16 const Util::CalcLpfFreqTable[CALC_LPF_FREQ_TABLE_SIZE] =
{
80, 100, 128,
160, 200, 256,
320, 400, 500,
640, 800, 1000,
1280, 1600, 2000,
2560, 3200, 4000,
5120, 6400, 8000,
10240, 12800, 16000
};
// clang-format on
// .data
// clang-format off
f32 const *Util::PanTableTable[PAN_CURVE_NUM] =
{
/*[PAN_CURVE_SQRT] = */Pan2RatioTableSqrt,
/*[PAN_CURVE_SINCOS] =*/ Pan2RatioTableSinCos,
/*[PAN_CURVE_LINEAR] =*/ Pan2RatioTableLinear,
};
// clang-format on
}}} // namespace nw4r::snd::detail
/*******************************************************************************
* functions
*/
namespace nw4r { namespace snd { namespace detail {
f32 Util::CalcPitchRatio(int pitch)
{
f32 ratio;
int octave = 0;
f32 octave_float = 1.0f;
while (pitch < 0)
{
octave--;
pitch += OCTAVE_DIVISION * PITCH_DIVISION_RANGE;
}
while (pitch >= OCTAVE_DIVISION * PITCH_DIVISION_RANGE)
{
octave++;
pitch -= OCTAVE_DIVISION * PITCH_DIVISION_RANGE;
}
while (octave > 0)
{
octave_float *= 2.0f;
octave--;
}
while (octave < 0)
{
octave_float /= 2.0f;
octave++;
}
int note = pitch / PITCH_DIVISION_RANGE;
pitch %= PITCH_DIVISION_RANGE;
ratio = octave_float;
if (note != 0)
ratio *= NoteTable[note];
if (pitch != 0)
ratio *= PitchTable[pitch];
return ratio;
}
f32 Util::CalcVolumeRatio(f32 dB)
{
dB = ut::Clamp(dB, VOLUME_DB_MIN / 10.0f, VOLUME_DB_MAX / 10.0f);
return Decibel2RatioTable[static_cast<int>(dB * 10.0f) - VOLUME_DB_MIN];
}
f32 Util::CalcPanRatio(f32 pan, PanInfo const &info)
{
pan = (ut::Clamp(pan, -1.0f, 1.0f) + 1.0f) / 2.0f;
f32 const *table = PanTableTable[info.curve];
f32 ratio = table[static_cast<int>(pan * PAN_TABLE_MAX + 0.5f)];
if (info.centerZeroFlag)
ratio /= table[PAN_TABLE_CENTER];
return info.zeroClampFlag ? ut::Clamp(ratio, 0.0f, 1.0f)
: ut::Clamp(ratio, 0.0f, 2.0f);
}
f32 Util::CalcSurroundPanRatio(f32 pan, PanInfo const &info)
{
pan = ut::Clamp(pan, 0.0f, 2.0f) / 2.0f;
f32 const *table = PanTableTable[info.curve];
f32 ratio = table[static_cast<int>(pan * PAN_TABLE_MAX + 0.5f)];
return ut::Clamp(ratio, 0.0f, 2.0f);
}
u16 Util::CalcLpfFreq(f32 scale)
{
scale = ut::Clamp(scale, 0.0f, 1.0f);
u16 freq = 0;
if (scale < CALC_LPF_FREQ_INTERCEPT)
{
freq = CalcLpfFreqTable[0];
}
else if (scale >= 0.9f)
{
freq = CalcLpfFreqTable[CALC_LPF_FREQ_TABLE_SIZE - 1];
}
else
{
int idx = (scale - CALC_LPF_FREQ_INTERCEPT) / (1.0f / 3.0f / 10.0f);
freq = CalcLpfFreqTable[idx];
}
return freq;
}
void Util::GetRemoteFilterCoefs(int filter, u16 *b0, u16 *b1, u16 *b2, u16 *a1,
u16 *a2)
{
filter = ut::Clamp(filter, COEF_TABLE_MIN, COEF_TABLE_MAX);
*b0 = RemoteFilterCoefTable[filter][0];
*b1 = RemoteFilterCoefTable[filter][1];
*b2 = RemoteFilterCoefTable[filter][2];
*a1 = RemoteFilterCoefTable[filter][3];
*a2 = RemoteFilterCoefTable[filter][4];
}
u16 Util::CalcRandom()
{
/* ogws leaves this note:
*
* randq1 :D
*/
static unsigned long u = 0x12345678ul;
u = u * 0x19660d + 0x3c6ef35f;
return u >> 16;
}
void const *Util::GetDataRefAddressImpl(RefType refType, u32 value,
void const *baseAddress)
{
if (refType == REFTYPE_OFFSET)
{
return ut::AddOffsetToPtr(baseAddress, Util::ReadBigEndian(value));
}
else if (refType == REFTYPE_ADDRESS)
{
return reinterpret_cast<void const *>(Util::ReadBigEndian(value));
}
else
{
NW4RPanicMessage_Line(758, "invalid DataRef::RefType");
return nullptr;
}
}
}}} // namespace nw4r::snd::detail
|