-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbtt_amalgamation.c
More file actions
4209 lines (3607 loc) · 175 KB
/
btt_amalgamation.c
File metadata and controls
4209 lines (3607 loc) · 175 KB
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
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==========================================================================
// btt_amalgamation.c -- Beat-and-Tempo-Tracking library
// Copyright (c) 2021 Michael Krzyzaniak -- MIT License
// https://github.com/michaelkrzyzaniak/Beat-and-Tempo-Tracking
//
// Single-file build. Add ONLY this file to your JUCE/Projucer project.
// Same pattern as sqlite3.c -- no external .c dependencies at build time.
// ==========================================================================
// --- Platform compatibility ---
#ifdef _MSC_VER
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#pragma warning(push)
#pragma warning(disable: 4244) // conversion double->float
#pragma warning(disable: 4305) // truncation double->float
#pragma warning(disable: 4267) // conversion size_t->int
#pragma warning(disable: 4018) // signed/unsigned mismatch
#pragma warning(disable: 4100) // unreferenced parameter
#pragma warning(disable: 4146) // unary minus on unsigned
#pragma warning(disable: 4706) // assignment within conditional
#endif
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <stdint.h>
#include <stdio.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifdef _MSC_VER
#define random() rand()
#endif
// VLA replacement (MSVC does not support C99 VLAs)
#define BTT_MAX_TEMPO_CANDIDATES 64
// --- C linkage for entire file (MSVC compiles .c as C++) ---
#ifdef __cplusplus
extern "C" {
#endif
// ======================================================================
// HEADERS
// ======================================================================
// --- fastsin.h ---
#ifndef __MK_SINE_TABLE__
#define __MK_SINE_TABLE__ 1
#include <stdint.h>
#define SIN_NUM_SAMPLES 4096
#define SIN_TWO_PI 0x100000000
#define SIN_PI 0x80000000
#define SIN_HALF_PI 0x40000000
#define SIN_QUARTER_PI 0x20000000
#define fastsin_t uint32_t
float fastsin (fastsin_t angle);
float fastcos (fastsin_t angle);
#define fastsin(angle) (*(sinTable + ((angle) >> 20)))
#define fastcos(angle) (*(sinTable + (((angle) + SIN_HALF_PI) >> 20)))
extern const float sinTable[SIN_NUM_SAMPLES];
//slowsin
/*
#define SIN_TWO_PI (2 * M_PI)
#define SIN_PI (M_PI)
#define SIN_HALF_PI (0.5 * M_PI)
#define SIN_QUARTER_PI (0.25 * M_PI)
#define fastsin_t double
float fastsin (fastsin_t angle);
float fastcos (fastsin_t angle);
#define fastsin(angle) (sin(angle))
#define fastcos(angle) (cos(angle))
*/
#endif//__MK_SINE_TABLE__
// --- DFT.h ---
/*__--------------_-----------_---------------------__---------------------
/ _|___ _ _ _ _(_)___ _ _ | |_ _ _ __ _ _ _ ___/ _|___ _ _ _ __
| _/ _ \ || | '_| / -_) '_| | _| '_/ _` | ' \(_-< _/ _ \ '_| ' \
|_| \___/\_,_|_| |_\___|_| \__|_| \__,_|_||_/__/_| \___/_| |_|_|_|
-------------------------------------------------------------------------*/
#ifndef __DFT__
#define __DFT__ 1
typedef float dft_sample_t;
void dft_init_blackman_window (dft_sample_t* window, int N);
void dft_init_hann_window (dft_sample_t* window, int N);
void dft_init_hamming_window (dft_sample_t* window, int N);
void dft_init_half_sine_window(dft_sample_t* window, int N);
void dft_apply_window (dft_sample_t* real, dft_sample_t* window, int N);
void dft_raw_forward_dft (dft_sample_t* real, dft_sample_t* imag, int N);
void dft_raw_inverse_dft (dft_sample_t* real, dft_sample_t* imag, int N);
void dft_bit_reverse_indices (dft_sample_t* real, dft_sample_t* imag, int N);
void dft_complex_forward_dft (dft_sample_t* real, dft_sample_t* imag, int N);
void dft_complex_inverse_dft (dft_sample_t* real, dft_sample_t* imag, int N);
void dft_real_forward_dft (dft_sample_t* real, dft_sample_t* imag, int N);
void dft_real_inverse_dft (dft_sample_t* real, dft_sample_t* imag, int N);
void dft_2_real_forward_dfts (dft_sample_t* real_1, dft_sample_t* real_2, dft_sample_t* imag_1, dft_sample_t* imag_2, int N);
void dft_2_real_inverse_dfts (dft_sample_t* real_1, dft_sample_t* real_2, dft_sample_t* imag_1, dft_sample_t* imag_2, int N);
/*
Note: dft_real_forward_dft takes real input and ignores imag input,
and uses a N/2-point complex DFT to produce 2-sided real and imaginary output
where the negative frequencies are filled in with the complex conjugates
of the positive ones.
rdft_forward_dft takes real input and uses a native real DFT to produce
single-sided real and imag output in-place, in the order
[real[0], real[1] ... real[N/2], imag[N/2-1], imag[1]]
imag[0] and imag[N/2] are understood to be 0. This is faster and uses
half the space of dft_real_forward_dft.
*/
void rdft_bit_reverse_indices (dft_sample_t* real, int N);
void rdft_real_forward_dft (dft_sample_t* real, int N);
void rdft_real_inverse_dft (dft_sample_t* real, int N);
void rdft_2_real_forward_dfts (dft_sample_t* real_1, dft_sample_t* real_2, int N);
void rdft_2_real_inverse_dfts (dft_sample_t* real_1, dft_sample_t* real_2, int N);
void rdft_real_generalized_autocorrelation (dft_sample_t* real, int N, double exponent);
void rdft_rect_to_polar (dft_sample_t* real, int N);
void rdft_polar_to_rect (dft_sample_t* real, int N);
/* user should zero-pad data to twice its original length for correlation and convolution */
void dft_real_convolve (dft_sample_t* real_1, dft_sample_t* real_2, dft_sample_t* imag_1, dft_sample_t* imag_2, int N);
void dft_real_correlate (dft_sample_t* real_1, dft_sample_t* real_2, dft_sample_t* imag_1, dft_sample_t* imag_2, int N);
void dft_real_autocorrelate (dft_sample_t* real , dft_sample_t* imag , int N);
/* generalized cross-correlation with phase transform */
void dft_real_generalized_autocorrelation (dft_sample_t* real , dft_sample_t* imag, int N, double exponent);
void dft_rect_to_polar (dft_sample_t* real, dft_sample_t* imag, int N);
void dft_polar_to_rect (dft_sample_t* real, dft_sample_t* imag, int N);
void dft_magnitude_to_db (dft_sample_t* real, int N);
void dft_normalize_magnitude (dft_sample_t* real, int N);
double dft_bin_of_frequency (double hz, double sample_rate, int N);
double dft_frequency_of_bin (double bin, double sample_rate, int N);
int dft_smallest_power_of_2_at_least_as_great_as(int n);
#endif // __DFT__
// --- Filter.h ---
#ifndef __FILTER__
#define __FILTER__
typedef struct opaque_filter_struct Filter;
typedef enum filter_type_enum
{
FILTER_LOW_PASS,
FILTER_HIGH_PASS,
FILTER_BAND_PASS,
FILTER_BAND_STOP,
FILTER_NUMBER_OF_TYPES,
}filter_type_t;
typedef enum filter_window_enum
{
FILTER_WINDOW_RESERVED = 0,
FILTER_WINDOW_RECT,
FILTER_WINDOW_BARTLETT,
FILTER_WINDOW_HANN,
FILTER_WINDOW_HAMMING,
FILTER_WINDOW_BLACKMANN,
}filter_window_t;
Filter* filter_new (filter_type_t type, float cutoff, int order);
Filter* filter_destroy (Filter* self);
void filter_clear (Filter* self);
void filter_set_filter_type(Filter* self, filter_type_t type);
filter_type_t filter_get_filter_type(Filter* self);
void filter_set_sample_rate(Filter* self, float sample_rate);
float filter_get_sample_rate(Filter* self);
void filter_set_cutoff (Filter* self, float cutoff);
float filter_get_cutoff (Filter* self);
void filter_set_order (Filter* self, int order); //cannot be greater than the initial order...
int filter_get_order (Filter* self);
void filter_set_window_type(Filter* self, filter_window_t window);
filter_window_t filter_get_window_type(Filter* self);
void filter_process_data (Filter* self, float* data, int num_samples);
#endif //__FILTER__
// --- STFT.h ---
/*__--------------_-----------_---------------------__---------------------
-------------------------------------------------------------------------*/
#ifndef __STFT__
#define __STFT__ 1
/*--------------------------------------------------------------------*/
typedef struct Opaque_STFT_Struct STFT;
typedef void (*stft_onprocess_t)(void* onprocess_self, dft_sample_t* real, int N);
STFT* stft_new (int window_size /*power of 2 please*/, int overlap /* 1, 2, 4, 8 */, int should_resynthesize);
STFT* stft_destroy (STFT* self);
void stft_process (STFT* self, dft_sample_t* real_input, int len, stft_onprocess_t onprocess, void* onprocess_self);
int stft_get_N (STFT* self);
int stft_get_overlap (STFT* self);
int stft_get_hop (STFT* self);
/*--------------------------------------------------------------------*/
typedef struct Opaque_TWO_STFTS_Struct TWO_STFTS;
typedef void (*two_stfts_onprocess_t)(void* onprocess_self, dft_sample_t* real, dft_sample_t* imag, dft_sample_t* real_2, dft_sample_t* imag_2, int N);
TWO_STFTS* two_stfts_new(int window_size /*power of 2 please*/, int overlap /* 1, 2, 4, 8 */, int should_resynthesize);
TWO_STFTS* two_stfts_destroy(TWO_STFTS* self);
void two_stfts_process(TWO_STFTS* self, dft_sample_t* real_input, dft_sample_t* real_input_2, int len, int two_inverses, two_stfts_onprocess_t onprocess, void* onprocess_self);
#endif // __DFT__
// --- Statistics.h ---
/*-____--_--------_---_-----_---_------------_--------------------------
/ ___|| |_ __ _| |_(_)___| |_(_) ___ ___ | |__
\___ \| __/ _` | __| / __| __| |/ __/ __| | '_ \
___) | || (_| | |_| \__ \ |_| | (__\__ \_| | | |
|____/ \__\__,_|\__|_|___/\__|_|\___|___(_)_| |_|
------------------------------------------------------------------------
----------------------------------------------------------------------*/
#ifndef __IC_STATISTICS__
#define __IC_STATISTICS__
/*--------------------------------------------------------------------*/
/*--___-------_-_--------------_----------------------------------------
/ _ \ _ _ | (_)_ _ ___ /_\__ _____ _ _ __ _ __ _ ___
| (_) | ' \| | | ' \/ -_) / _ \ V / -_) '_/ _` / _` / -_);
\___/|_||_|_|_|_||_\___| /_/ \_\_/\___|_| \__,_\__, \___|
--------------------------------------------------|___/-----------------
Calculate the mean and variance of a signal one sample at a time.
----------------------------------------------------------------------*/
typedef struct opaque_online_average_struct OnlineAverage;
OnlineAverage* online_average_new ();
void online_average_init (OnlineAverage* self);
OnlineAverage* online_average_destroy (OnlineAverage* self);
int online_average_n (OnlineAverage* self);
double online_average_mean (OnlineAverage* self);
double online_average_variance (OnlineAverage* self);
double online_average_std_dev (OnlineAverage* self);
void online_average_update (OnlineAverage* self, double x);
/*--------------------------------------------------------------------*/
/*-__--__---------_---------------_-------------------------------------
| \/ |_____ _(_)_ _ __ _ /_\__ _____ _ _ __ _ __ _ ___
| |\/| / _ \ V / | ' \/ _` | / _ \ V / -_) '_/ _` / _` / -_);
|_| |_\___/\_/|_|_||_\__, | /_/ \_\_/\___|_| \__,_\__, \___|
------------------------|___/------------------------|___/--------------
Calculate the moving or rolling mean and variance over the past N
samples of a signal. This algorithm is online and updates one sample
at a time.
----------------------------------------------------------------------*/
typedef struct opaque_moving_average_struct MovingAverage;
MovingAverage* moving_average_new (unsigned N);
void moving_average_init (MovingAverage* self);
MovingAverage* moving_average_destroy (MovingAverage* self);
int moving_average_N (MovingAverage* self);
int moving_average_n (MovingAverage* self);
double moving_average_mean (MovingAverage* self);
double moving_average_variance (MovingAverage* self);
double moving_average_std_dev (MovingAverage* self);
void moving_average_update (MovingAverage* self, double x);
/*--------------------------------------------------------------------*/
/*--___-------_-_------------___------------------------_---------------
/ _ \ _ _ | (_)_ _ ___ | _ \___ __ _ _ _ ___ _____(_)___ _ _
| (_) | ' \| | | ' \/ -_) | / -_) _` | '_/ -_|_-<_-< / _ \ ' \
\___/|_||_|_|_|_||_\___| |_|_\___\__, |_| \___/__/__/_\___/_||_|
------------------------------------|___/-------------------------------
Calculate the means, variances, covariance, slope, y-intercept and
correlation coeficient of two signals. This is an online algorithm
that operates one sample at a time.
----------------------------------------------------------------------*/
typedef struct opaque_online_regression_struct OnlineRegression;
OnlineRegression* online_regression_new ();
void online_regression_init (OnlineRegression* self);
OnlineRegression* online_regression_destroy (OnlineRegression* self);
int online_regression_n (OnlineRegression* self);
double online_regression_covariance (OnlineRegression* self);
double online_regression_slope (OnlineRegression* self);
double online_regression_y_intercept (OnlineRegression* self);
double online_regression_r_squared (OnlineRegression* self);
void online_regression_update (OnlineRegression* self, double a_data, double b_data);
/*--------------------------------------------------------------------*/
/*----------_-----------_---_-----------_____-_---------------_----_---- _ _
/_\ __| |__ _ _ __| |_(_)_ _____ |_ _| |_ _ _ ___ __| |_ | |_ ___| |__| |
/ _ \/ _` / _` | '_ \ _| \ V / -_) | | | ' \| '_/ -_|_-< ' \| ' \/ _ \ / _` |
/_/ \_\__,_\__,_| .__/\__|_|\_/\___| |_| |_||_|_| \___/__/_||_|_||_\___/_\__,_|
------------------|_|---------------------------------------------------
Adaptive threshhold tells you when your signal goes a specified number
of standard deviations above or below a moving average of a filtered
version of your signal. update() returns +1 or -1 whenever your signal
transitions to being above or below the threshold.
----------------------------------------------------------------------*/
typedef struct opaque_adaptive_threshold_struct AdaptiveThreshold;
AdaptiveThreshold* adaptive_threshold_new (unsigned N);
void adaptive_threshold_init (AdaptiveThreshold* self);
void adaptive_threshold_clear (AdaptiveThreshold* self);
AdaptiveThreshold* adaptive_threshold_destroy (AdaptiveThreshold* self);
double adaptive_threshold_smoothing (AdaptiveThreshold* self);
void adaptive_threshold_set_smoothing (AdaptiveThreshold* self, double coefficient);
double adaptive_threshold_threshold_value (AdaptiveThreshold* self); //mean + num std devs * std dev
double adaptive_threshold_threshold (AdaptiveThreshold* self); //num std devs
void adaptive_threshold_set_threshold (AdaptiveThreshold* self, double std_devs);
double adaptive_threshold_threshold_min (AdaptiveThreshold* self);
void adaptive_threshold_set_threshold_min(AdaptiveThreshold* self, double min); //raw value
double adaptive_threshold_onset_signal (AdaptiveThreshold* self);
double adaptive_threshold_mean (AdaptiveThreshold* self);
double adaptive_threshold_update (AdaptiveThreshold* self, double x);
double statistics_random_flat(); //(0, 1]
double statistics_random_normal(double mean, double std_dev);
double statistics_random_cauchy(double peak_location, double half_width_at_half_maximum);
#endif //__IC_STATISTICS__
// --- BTT.h ---
/*----------------------------------------------------------------------
____ _ _
| __ ) ___ __ _| |_ __ _ _ __ __| |
| _ \ / _ \/ _` | __| / _` | '_ \ / _` |
| |_) | __/ (_| | |_ | (_| | | | | (_| |
|____/ \___|\__,_|\__| \__,_|_| |_|\__,_|
_____
|_ _|__ _ __ ___ _ __ ___
| |/ _ \ '_ ` _ \| '_ \ / _ \
| | __/ | | | | | |_) | (_) |
|_|\___|_| |_| |_| .__/ \___/
|_|
_____ _ _
|_ _| __ __ _ ___| | _(_)_ __ __ _
| || '__/ _` |/ __| |/ / | '_ \ / _` |
| || | | (_| | (__| <| | | | | (_| |
|_||_| \__,_|\___|_|\_\_|_| |_|\__, |
|___/
------------------------------------------------------------------------
Made by Michael Krzyzaniak
Version:
1.0
----------------------------------------------------------------------*/
#ifndef __BTT__
#define __BTT__ 1
/*--------------------------------------------------------------------*/
typedef enum
{
BTT_COUNT_IN_TRACKING,
BTT_ONSET_TRACKING,
BTT_ONSET_AND_TEMPO_TRACKING,
BTT_ONSET_AND_TEMPO_AND_BEAT_TRACKING,
BTT_TEMPO_LOCKED_BEAT_TRACKING,
BTT_METRONOME_MODE,
BTT_NUM_TRACKING_MODES,
}btt_tracking_mode_t;
/*--------------------------------------------------------------------*/
#define BTT_SUGGESTED_SPECTRAL_FLUX_STFT_LEN 1024 // fft size
#define BTT_SUGGESTED_SPECTRAL_FLUX_STFT_OVERLAP 8 // hop size will be len / overlap
#define BTT_SUGGESTED_OSS_FILTER_ORDER 15 // this will delay the signal by about 7 samples
#define BTT_SUGGESTED_OSS_LENGTH 1024 // enough to hold 3 seconds at 44.1kHz and hop of 128
#define BTT_SUGGESTED_ONSET_THRESHOLD_N 1024 // size of moving average of oss to see if onset occured
#define BTT_SUGGESTED_SAMPLE_RATE 44100 // audio sample rate
#define BTT_SUGGESTED_CBSS_LENGTH 1024 // should be at least a little bigger than the slowest tempo lag in oss samples
#define BTT_DEFAULT_ANALYSIS_LATENCY_ONSET_ADJUSTMENT 857
#define BTT_DEFAULT_ANALYSIS_LATENCY_BEAT_ADJUSTMENT 1270
/*--------------------------------------------------------------------*/
#define BTT_DEFAULT_MIN_TEMPO 50 // BPM
#define BTT_DEFAULT_MAX_TEMPO 200 // BPM
#define BTT_DEFAULT_SPECTRAL_COMPRESSION_GAMMA 0 // COMPRESSED(spectrum) = log(1+gamma|spectrum|) / log(1+gamma)
#define BTT_DEFAULT_AUTOCORRELATION_EXPONENT 0.5 // for generalized autocorrelation
#define BTT_DEFAULT_NUM_TEMPO_CANDIDATES 10 //
#define BTT_DEFAULT_TRACKING_MODE BTT_ONSET_AND_TEMPO_AND_BEAT_TRACKING
#define BTT_DEFAULT_OSS_FILTER_CUTOFF 10 // Hz
#define BTT_DEFAULT_USE_AMP_NORMALIZATION 0 // false
#define BTT_DEFAULT_ONSET_TREHSHOLD 0.1 // std devs above mean OSS signal
#define BTT_DEFAULT_ONSET_TREHSHOLD_MIN 5.0 // raw flux value
#define BTT_DEFAULT_NOISE_CANCELLATION_THRESHOLD -74 // dB per freq bin
#define BTT_DEFAULT_LOG_GAUSSIAN_TEMPO_WEIGHT_MEAN 120 // supress harmonics by favoring tempos closer to 120
#define BTT_DEFAULT_LOG_GAUSSIAN_TEMPO_WEIGHT_WIDTH 75 // oss samples starndard deviation
#define BTT_DEFAULT_GAUSSIAN_TEMPO_HISTOGRAM_DECAY 0.999 //
#define BTT_DEFAULT_GAUSSIAN_TEMPO_HISTOGRAM_WIDTH 5 // oss samples starndard deviation
#define BTT_DEFAULT_CBSS_ALPHA 0.9 // 90% old, 10 percent new
#define BTT_DEFAULT_CBSS_ETA 300 // width of gaussian window. Larger number is narrower window
#define BTT_DEFAULT_BEAT_PREDICTION_ADJUSTMENT 10 // oss samples earlier than detected
#define BTT_DEFAULT_PREDICTED_BEAT_TRIGGER_INDEX 20 //
#define BTT_DEFAULT_PREDICTED_BEAT_GAUSSIAN_WIDTH 10 // oss samples
#define BTT_DEFAULT_IGNORE_SPURIOUS_BEATS_DURATION 40 // percent of beat at current tempo
#define BTT_DEFAULT_COUNT_IN_N 2
#define BTT_DEFAULT_XCORR_NUM_PULSES 8 //
#define BTT_DEFAULT_XCORR_PULSE_LOCATIONS {0, 1, 1.5, 2, 3, 4, 4.5, 6}
#define BTT_DEFAULT_XCORR_PULSE_VALUES {2.0, 1.0, 0.5, 1.5, 1.5, 0.5, 0.5, 0.5}
/*--------------------------------------------------------------------*/
typedef struct Opaque_BTT_Struct BTT;
typedef void (*btt_onset_callback_t) (void* SELF, unsigned long long sample_time);
typedef void (*btt_beat_callback_t) (void* SELF, unsigned long long sample_time);
/*--------------------------------------------------------------------*/
/* if you use btt_new you are going to have to empirically determine the analysis_latency_adjustments using the utility in demos/analysis_latency/
the analysis latency is caused by complex interactions between filters, buffering, adaptive thresholds, and other things, and I couldn't
find a closed-form expression that caputures it. If you use btt_new_default you will be fine, if not, you have to manually calculate it.
*/
BTT* btt_new (int spectral_flux_stft_len, int spectral_flux_stft_overlap,
int oss_filter_order , int oss_length,
int cbss_length , int onset_threshold_len, double sample_rate,
int analysis_latency_onset_adjustment, int analysis_latency_beat_adjustment);
BTT* btt_new_default ();
BTT* btt_destroy (BTT* self);
void btt_process (BTT* self, dft_sample_t* input, int num_samples);
double btt_get_sample_rate (BTT* self);
void btt_init (BTT* self);
void btt_clear (BTT* self);
void btt_init_tempo (BTT* self, double bpm /*0 to clear tempo*/);
int btt_get_beat_period_audio_samples (BTT* self);
double btt_get_tempo_bpm (BTT* self);
double btt_get_tempo_certainty (BTT* self);
void btt_set_count_in_n (BTT* self, int n);
int btt_get_count_in_n (BTT* self);
/* only valid in metronome mode */
void btt_set_metronome_bpm (BTT* self, double bpm);
/* onset detection adjustments */
void btt_set_use_amplitude_normalization (BTT* self, int use);
int btt_get_use_amplitude_normalization (BTT* self);
void btt_set_spectral_compression_gamma (BTT* self, double gamma);
double btt_get_spectral_compression_gamma (BTT* self);
void btt_set_oss_filter_cutoff (BTT* self, double Hz);
double btt_get_oss_filter_cutoff (BTT* self);
void btt_set_onset_threshold (BTT* self, double num_std_devs);
double btt_get_onset_threshold (BTT* self);
void btt_set_onset_threshold_min (BTT* self, double value);
double btt_get_onset_threshold_min (BTT* self);
void btt_set_noise_cancellation_threshold (BTT* self, double dB /*negative*/);
double btt_get_noise_cancellation_threshold (BTT* self);
/* tempo tracking adjustments */
void btt_set_autocorrelation_exponent (BTT* self, double exponent);
double btt_get_autocorrelation_exponent (BTT* self);
void btt_set_min_tempo (BTT* self, double min_tempo);
double btt_get_min_tempo (BTT* self);
void btt_set_max_tempo (BTT* self, double max_tempo);
double btt_get_max_tempo (BTT* self);
void btt_set_num_tempo_candidates (BTT* self, int num_candidates);
int btt_get_num_tempo_candidates (BTT* self);
void btt_set_gaussian_tempo_histogram_decay (BTT* self, double coefficient);
double btt_get_gaussian_tempo_histogram_decay (BTT* self);
void btt_set_gaussian_tempo_histogram_width (BTT* self, double width);
double btt_get_gaussian_tempo_histogram_width (BTT* self);
void btt_set_log_gaussian_tempo_weight_mean (BTT* self, double bpm);
double btt_get_log_gaussian_tempo_weight_mean (BTT* self);
void btt_set_log_gaussian_tempo_weight_width(BTT* self, double bpm);
double btt_get_log_gaussian_tempo_weight_width(BTT* self);
/* beat tracking adjustments */
void btt_set_cbss_alpha (BTT* self, double alpha);
double btt_get_cbss_alpha (BTT* self);
void btt_set_cbss_eta (BTT* self, double eta);
double btt_get_cbss_eta (BTT* self);
void btt_set_beat_prediction_adjustment (BTT* self, int oss_samples_earlier);
int btt_get_beat_prediction_adjustment (BTT* self);
int btt_get_beat_prediction_adjustment_audio_samples (BTT* self);
void btt_set_predicted_beat_trigger_index (BTT* self, int index);
int btt_get_predicted_beat_trigger_index (BTT* self);
void btt_set_predicted_beat_gaussian_width (BTT* self, double width);
double btt_get_predicted_beat_gaussian_width (BTT* self);
void btt_set_ignore_spurious_beats_duration (BTT* self, double percent_of_tempo);
double btt_get_ignore_spurious_beats_duration (BTT* self);
void btt_set_analysis_latency_onset_adjustment(BTT* self, int adjustment);
int btt_get_analysis_latency_onset_adjustment(BTT* self);
void btt_set_analysis_latency_beat_adjustment(BTT* self, int adjustment);
int btt_get_analysis_latency_beat_adjustment(BTT* self);
void btt_set_tracking_mode (BTT* self, btt_tracking_mode_t mode);
btt_tracking_mode_t btt_get_tracking_mode (BTT* self);
const char* btt_get_tracking_mode_string (BTT* self);
void btt_set_onset_tracking_callback (BTT* self, btt_onset_callback_t callback, void* callback_self);
btt_onset_callback_t btt_get_onset_tracking_callback (BTT* self, void** returned_callback_self);
void btt_set_beat_tracking_callback (BTT* self, btt_beat_callback_t callback, void* callback_self);
btt_beat_callback_t btt_get_beat_tracking_callback (BTT* self, void** returned_callback_self);
#endif // __BTT__
// ======================================================================
// IMPLEMENTATION
// ======================================================================
// --- fastsin.c ---
// Suppress MSVC C4305 (double→float truncation) for the sine lookup table
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4305)
#endif
extern const float sinTable[] =
{
0.000000, 0.001534, 0.003068, 0.004602, 0.006136, 0.007670, 0.009204, 0.010738, 0.012272, 0.013805,
0.015339, 0.016873, 0.018407, 0.019940, 0.021474, 0.023008, 0.024541, 0.026075, 0.027608, 0.029142,
0.030675, 0.032208, 0.033741, 0.035274, 0.036807, 0.038340, 0.039873, 0.041406, 0.042938, 0.044471,
0.046003, 0.047535, 0.049068, 0.050600, 0.052132, 0.053664, 0.055195, 0.056727, 0.058258, 0.059790,
0.061321, 0.062852, 0.064383, 0.065913, 0.067444, 0.068974, 0.070505, 0.072035, 0.073565, 0.075094,
0.076624, 0.078153, 0.079682, 0.081211, 0.082740, 0.084269, 0.085797, 0.087326, 0.088854, 0.090381,
0.091909, 0.093436, 0.094963, 0.096490, 0.098017, 0.099544, 0.101070, 0.102596, 0.104122, 0.105647,
0.107172, 0.108697, 0.110222, 0.111747, 0.113271, 0.114795, 0.116319, 0.117842, 0.119365, 0.120888,
0.122411, 0.123933, 0.125455, 0.126977, 0.128498, 0.130019, 0.131540, 0.133061, 0.134581, 0.136101,
0.137620, 0.139139, 0.140658, 0.142177, 0.143695, 0.145213, 0.146730, 0.148248, 0.149765, 0.151281,
0.152797, 0.154313, 0.155828, 0.157343, 0.158858, 0.160372, 0.161886, 0.163400, 0.164913, 0.166426,
0.167938, 0.169450, 0.170962, 0.172473, 0.173984, 0.175494, 0.177004, 0.178514, 0.180023, 0.181532,
0.183040, 0.184548, 0.186055, 0.187562, 0.189069, 0.190575, 0.192080, 0.193586, 0.195090, 0.196595,
0.198098, 0.199602, 0.201105, 0.202607, 0.204109, 0.205610, 0.207111, 0.208612, 0.210112, 0.211611,
0.213110, 0.214609, 0.216107, 0.217604, 0.219101, 0.220598, 0.222094, 0.223589, 0.225084, 0.226578,
0.228072, 0.229565, 0.231058, 0.232550, 0.234042, 0.235533, 0.237024, 0.238514, 0.240003, 0.241492,
0.242980, 0.244468, 0.245955, 0.247442, 0.248928, 0.250413, 0.251898, 0.253382, 0.254866, 0.256349,
0.257831, 0.259313, 0.260794, 0.262275, 0.263755, 0.265234, 0.266713, 0.268191, 0.269668, 0.271145,
0.272621, 0.274097, 0.275572, 0.277046, 0.278520, 0.279993, 0.281465, 0.282937, 0.284408, 0.285878,
0.287347, 0.288816, 0.290285, 0.291752, 0.293219, 0.294685, 0.296151, 0.297616, 0.299080, 0.300543,
0.302006, 0.303468, 0.304929, 0.306390, 0.307850, 0.309309, 0.310767, 0.312225, 0.313682, 0.315138,
0.316593, 0.318048, 0.319502, 0.320955, 0.322408, 0.323859, 0.325310, 0.326760, 0.328210, 0.329658,
0.331106, 0.332553, 0.334000, 0.335445, 0.336890, 0.338334, 0.339777, 0.341219, 0.342661, 0.344101,
0.345541, 0.346980, 0.348419, 0.349856, 0.351293, 0.352729, 0.354164, 0.355598, 0.357031, 0.358463,
0.359895, 0.361326, 0.362756, 0.364185, 0.365613, 0.367040, 0.368467, 0.369892, 0.371317, 0.372741,
0.374164, 0.375586, 0.377007, 0.378428, 0.379847, 0.381266, 0.382683, 0.384100, 0.385516, 0.386931,
0.388345, 0.389758, 0.391170, 0.392582, 0.393992, 0.395401, 0.396810, 0.398218, 0.399624, 0.401030,
0.402435, 0.403838, 0.405241, 0.406643, 0.408044, 0.409444, 0.410843, 0.412241, 0.413638, 0.415034,
0.416430, 0.417824, 0.419217, 0.420609, 0.422000, 0.423390, 0.424780, 0.426168, 0.427555, 0.428941,
0.430326, 0.431711, 0.433094, 0.434476, 0.435857, 0.437237, 0.438616, 0.439994, 0.441371, 0.442747,
0.444122, 0.445496, 0.446869, 0.448241, 0.449611, 0.450981, 0.452350, 0.453717, 0.455084, 0.456449,
0.457813, 0.459177, 0.460539, 0.461900, 0.463260, 0.464619, 0.465977, 0.467333, 0.468689, 0.470043,
0.471397, 0.472749, 0.474100, 0.475450, 0.476799, 0.478147, 0.479494, 0.480839, 0.482184, 0.483527,
0.484869, 0.486210, 0.487550, 0.488889, 0.490226, 0.491563, 0.492898, 0.494232, 0.495565, 0.496897,
0.498228, 0.499557, 0.500885, 0.502212, 0.503538, 0.504863, 0.506187, 0.507509, 0.508830, 0.510150,
0.511469, 0.512786, 0.514103, 0.515418, 0.516732, 0.518045, 0.519356, 0.520666, 0.521975, 0.523283,
0.524590, 0.525895, 0.527199, 0.528502, 0.529804, 0.531104, 0.532403, 0.533701, 0.534998, 0.536293,
0.537587, 0.538880, 0.540171, 0.541462, 0.542751, 0.544039, 0.545325, 0.546610, 0.547894, 0.549177,
0.550458, 0.551738, 0.553017, 0.554294, 0.555570, 0.556845, 0.558119, 0.559391, 0.560662, 0.561931,
0.563199, 0.564466, 0.565732, 0.566996, 0.568259, 0.569521, 0.570781, 0.572040, 0.573297, 0.574553,
0.575808, 0.577062, 0.578314, 0.579565, 0.580814, 0.582062, 0.583309, 0.584554, 0.585798, 0.587040,
0.588282, 0.589521, 0.590760, 0.591997, 0.593232, 0.594467, 0.595699, 0.596931, 0.598161, 0.599389,
0.600616, 0.601842, 0.603067, 0.604290, 0.605511, 0.606731, 0.607950, 0.609167, 0.610383, 0.611597,
0.612810, 0.614022, 0.615232, 0.616440, 0.617647, 0.618853, 0.620057, 0.621260, 0.622461, 0.623661,
0.624860, 0.626056, 0.627252, 0.628446, 0.629638, 0.630829, 0.632019, 0.633207, 0.634393, 0.635578,
0.636762, 0.637944, 0.639124, 0.640303, 0.641481, 0.642657, 0.643832, 0.645005, 0.646176, 0.647346,
0.648514, 0.649681, 0.650847, 0.652011, 0.653173, 0.654334, 0.655493, 0.656651, 0.657807, 0.658961,
0.660114, 0.661266, 0.662416, 0.663564, 0.664711, 0.665856, 0.667000, 0.668142, 0.669283, 0.670422,
0.671559, 0.672695, 0.673829, 0.674962, 0.676093, 0.677222, 0.678350, 0.679476, 0.680601, 0.681724,
0.682846, 0.683965, 0.685084, 0.686200, 0.687315, 0.688429, 0.689541, 0.690651, 0.691759, 0.692866,
0.693971, 0.695075, 0.696177, 0.697277, 0.698376, 0.699473, 0.700569, 0.701663, 0.702755, 0.703845,
0.704934, 0.706021, 0.707107, 0.708191, 0.709273, 0.710353, 0.711432, 0.712509, 0.713585, 0.714659,
0.715731, 0.716801, 0.717870, 0.718937, 0.720003, 0.721066, 0.722128, 0.723188, 0.724247, 0.725304,
0.726359, 0.727413, 0.728464, 0.729514, 0.730563, 0.731609, 0.732654, 0.733697, 0.734739, 0.735779,
0.736817, 0.737853, 0.738887, 0.739920, 0.740951, 0.741980, 0.743008, 0.744034, 0.745058, 0.746080,
0.747101, 0.748119, 0.749136, 0.750152, 0.751165, 0.752177, 0.753187, 0.754195, 0.755201, 0.756206,
0.757209, 0.758210, 0.759209, 0.760207, 0.761202, 0.762196, 0.763188, 0.764179, 0.765167, 0.766154,
0.767139, 0.768122, 0.769103, 0.770083, 0.771061, 0.772036, 0.773010, 0.773983, 0.774953, 0.775922,
0.776888, 0.777853, 0.778817, 0.779778, 0.780737, 0.781695, 0.782651, 0.783605, 0.784557, 0.785507,
0.786455, 0.787402, 0.788346, 0.789289, 0.790230, 0.791169, 0.792107, 0.793042, 0.793975, 0.794907,
0.795837, 0.796765, 0.797691, 0.798615, 0.799537, 0.800458, 0.801376, 0.802293, 0.803208, 0.804120,
0.805031, 0.805940, 0.806848, 0.807753, 0.808656, 0.809558, 0.810457, 0.811355, 0.812251, 0.813144,
0.814036, 0.814926, 0.815814, 0.816701, 0.817585, 0.818467, 0.819348, 0.820226, 0.821102, 0.821977,
0.822850, 0.823721, 0.824589, 0.825456, 0.826321, 0.827184, 0.828045, 0.828904, 0.829761, 0.830616,
0.831470, 0.832321, 0.833170, 0.834018, 0.834863, 0.835706, 0.836548, 0.837387, 0.838225, 0.839060,
0.839894, 0.840725, 0.841555, 0.842383, 0.843208, 0.844032, 0.844854, 0.845673, 0.846491, 0.847307,
0.848120, 0.848932, 0.849742, 0.850549, 0.851355, 0.852159, 0.852961, 0.853760, 0.854558, 0.855354,
0.856147, 0.856939, 0.857729, 0.858516, 0.859302, 0.860085, 0.860867, 0.861646, 0.862424, 0.863199,
0.863973, 0.864744, 0.865514, 0.866281, 0.867046, 0.867809, 0.868571, 0.869330, 0.870087, 0.870842,
0.871595, 0.872346, 0.873095, 0.873842, 0.874587, 0.875329, 0.876070, 0.876809, 0.877545, 0.878280,
0.879012, 0.879743, 0.880471, 0.881197, 0.881921, 0.882643, 0.883363, 0.884081, 0.884797, 0.885511,
0.886223, 0.886932, 0.887640, 0.888345, 0.889048, 0.889750, 0.890449, 0.891146, 0.891841, 0.892534,
0.893224, 0.893913, 0.894599, 0.895284, 0.895966, 0.896646, 0.897325, 0.898001, 0.898674, 0.899346,
0.900016, 0.900683, 0.901349, 0.902012, 0.902673, 0.903332, 0.903989, 0.904644, 0.905297, 0.905947,
0.906596, 0.907242, 0.907886, 0.908528, 0.909168, 0.909806, 0.910441, 0.911075, 0.911706, 0.912335,
0.912962, 0.913587, 0.914210, 0.914830, 0.915449, 0.916065, 0.916679, 0.917291, 0.917901, 0.918508,
0.919114, 0.919717, 0.920318, 0.920917, 0.921514, 0.922109, 0.922701, 0.923291, 0.923880, 0.924465,
0.925049, 0.925631, 0.926210, 0.926787, 0.927363, 0.927935, 0.928506, 0.929075, 0.929641, 0.930205,
0.930767, 0.931327, 0.931884, 0.932440, 0.932993, 0.933544, 0.934093, 0.934639, 0.935184, 0.935726,
0.936266, 0.936803, 0.937339, 0.937872, 0.938404, 0.938932, 0.939459, 0.939984, 0.940506, 0.941026,
0.941544, 0.942060, 0.942573, 0.943084, 0.943593, 0.944100, 0.944605, 0.945107, 0.945607, 0.946105,
0.946601, 0.947094, 0.947586, 0.948075, 0.948561, 0.949046, 0.949528, 0.950008, 0.950486, 0.950962,
0.951435, 0.951906, 0.952375, 0.952842, 0.953306, 0.953768, 0.954228, 0.954686, 0.955141, 0.955594,
0.956045, 0.956494, 0.956940, 0.957385, 0.957826, 0.958266, 0.958703, 0.959139, 0.959572, 0.960002,
0.960431, 0.960857, 0.961280, 0.961702, 0.962121, 0.962538, 0.962953, 0.963366, 0.963776, 0.964184,
0.964590, 0.964993, 0.965394, 0.965793, 0.966190, 0.966584, 0.966976, 0.967366, 0.967754, 0.968139,
0.968522, 0.968903, 0.969281, 0.969657, 0.970031, 0.970403, 0.970772, 0.971139, 0.971504, 0.971866,
0.972227, 0.972584, 0.972940, 0.973293, 0.973644, 0.973993, 0.974339, 0.974684, 0.975025, 0.975365,
0.975702, 0.976037, 0.976370, 0.976700, 0.977028, 0.977354, 0.977677, 0.977998, 0.978317, 0.978634,
0.978948, 0.979260, 0.979570, 0.979877, 0.980182, 0.980485, 0.980785, 0.981083, 0.981379, 0.981673,
0.981964, 0.982253, 0.982539, 0.982824, 0.983105, 0.983385, 0.983662, 0.983937, 0.984210, 0.984480,
0.984748, 0.985014, 0.985278, 0.985539, 0.985798, 0.986054, 0.986308, 0.986560, 0.986809, 0.987057,
0.987301, 0.987544, 0.987784, 0.988022, 0.988258, 0.988491, 0.988722, 0.988950, 0.989177, 0.989400,
0.989622, 0.989841, 0.990058, 0.990273, 0.990485, 0.990695, 0.990903, 0.991108, 0.991311, 0.991511,
0.991710, 0.991906, 0.992099, 0.992291, 0.992480, 0.992666, 0.992850, 0.993032, 0.993212, 0.993389,
0.993564, 0.993737, 0.993907, 0.994075, 0.994240, 0.994404, 0.994565, 0.994723, 0.994879, 0.995033,
0.995185, 0.995334, 0.995481, 0.995625, 0.995767, 0.995907, 0.996045, 0.996180, 0.996313, 0.996443,
0.996571, 0.996697, 0.996820, 0.996941, 0.997060, 0.997176, 0.997290, 0.997402, 0.997511, 0.997618,
0.997723, 0.997825, 0.997925, 0.998023, 0.998118, 0.998211, 0.998302, 0.998390, 0.998476, 0.998559,
0.998640, 0.998719, 0.998795, 0.998870, 0.998941, 0.999011, 0.999078, 0.999142, 0.999205, 0.999265,
0.999322, 0.999378, 0.999431, 0.999481, 0.999529, 0.999575, 0.999619, 0.999660, 0.999699, 0.999735,
0.999769, 0.999801, 0.999831, 0.999858, 0.999882, 0.999905, 0.999925, 0.999942, 0.999958, 0.999971,
0.999981, 0.999989, 0.999995, 0.999999, 1.000000, 0.999999, 0.999995, 0.999989, 0.999981, 0.999971,
0.999958, 0.999942, 0.999925, 0.999905, 0.999882, 0.999858, 0.999831, 0.999801, 0.999769, 0.999735,
0.999699, 0.999660, 0.999619, 0.999575, 0.999529, 0.999481, 0.999431, 0.999378, 0.999322, 0.999265,
0.999205, 0.999142, 0.999078, 0.999011, 0.998941, 0.998870, 0.998795, 0.998719, 0.998640, 0.998559,
0.998476, 0.998390, 0.998302, 0.998211, 0.998118, 0.998023, 0.997925, 0.997825, 0.997723, 0.997618,
0.997511, 0.997402, 0.997290, 0.997176, 0.997060, 0.996941, 0.996820, 0.996697, 0.996571, 0.996443,
0.996313, 0.996180, 0.996045, 0.995907, 0.995767, 0.995625, 0.995481, 0.995334, 0.995185, 0.995033,
0.994879, 0.994723, 0.994565, 0.994404, 0.994240, 0.994075, 0.993907, 0.993737, 0.993564, 0.993389,
0.993212, 0.993032, 0.992850, 0.992666, 0.992480, 0.992291, 0.992099, 0.991906, 0.991710, 0.991511,
0.991311, 0.991108, 0.990903, 0.990695, 0.990485, 0.990273, 0.990058, 0.989841, 0.989622, 0.989400,
0.989177, 0.988950, 0.988722, 0.988491, 0.988258, 0.988022, 0.987784, 0.987544, 0.987301, 0.987057,
0.986809, 0.986560, 0.986308, 0.986054, 0.985798, 0.985539, 0.985278, 0.985014, 0.984748, 0.984480,
0.984210, 0.983937, 0.983662, 0.983385, 0.983105, 0.982824, 0.982539, 0.982253, 0.981964, 0.981673,
0.981379, 0.981083, 0.980785, 0.980485, 0.980182, 0.979877, 0.979570, 0.979260, 0.978948, 0.978634,
0.978317, 0.977998, 0.977677, 0.977354, 0.977028, 0.976700, 0.976370, 0.976037, 0.975702, 0.975365,
0.975025, 0.974684, 0.974339, 0.973993, 0.973644, 0.973293, 0.972940, 0.972584, 0.972227, 0.971866,
0.971504, 0.971139, 0.970772, 0.970403, 0.970031, 0.969657, 0.969281, 0.968903, 0.968522, 0.968139,
0.967754, 0.967366, 0.966976, 0.966584, 0.966190, 0.965793, 0.965394, 0.964993, 0.964590, 0.964184,
0.963776, 0.963366, 0.962953, 0.962538, 0.962121, 0.961702, 0.961280, 0.960857, 0.960431, 0.960002,
0.959572, 0.959139, 0.958703, 0.958266, 0.957826, 0.957385, 0.956940, 0.956494, 0.956045, 0.955594,
0.955141, 0.954686, 0.954228, 0.953768, 0.953306, 0.952842, 0.952375, 0.951906, 0.951435, 0.950962,
0.950486, 0.950008, 0.949528, 0.949046, 0.948561, 0.948075, 0.947586, 0.947094, 0.946601, 0.946105,
0.945607, 0.945107, 0.944605, 0.944100, 0.943593, 0.943084, 0.942573, 0.942060, 0.941544, 0.941026,
0.940506, 0.939984, 0.939459, 0.938932, 0.938404, 0.937872, 0.937339, 0.936803, 0.936266, 0.935726,
0.935184, 0.934639, 0.934093, 0.933544, 0.932993, 0.932440, 0.931884, 0.931327, 0.930767, 0.930205,
0.929641, 0.929075, 0.928506, 0.927935, 0.927363, 0.926787, 0.926210, 0.925631, 0.925049, 0.924465,
0.923880, 0.923291, 0.922701, 0.922109, 0.921514, 0.920917, 0.920318, 0.919717, 0.919114, 0.918508,
0.917901, 0.917291, 0.916679, 0.916065, 0.915449, 0.914830, 0.914210, 0.913587, 0.912962, 0.912335,
0.911706, 0.911075, 0.910441, 0.909806, 0.909168, 0.908528, 0.907886, 0.907242, 0.906596, 0.905947,
0.905297, 0.904644, 0.903989, 0.903332, 0.902673, 0.902012, 0.901349, 0.900683, 0.900016, 0.899346,
0.898674, 0.898001, 0.897325, 0.896646, 0.895966, 0.895284, 0.894599, 0.893913, 0.893224, 0.892534,
0.891841, 0.891146, 0.890449, 0.889750, 0.889048, 0.888345, 0.887640, 0.886932, 0.886223, 0.885511,
0.884797, 0.884081, 0.883363, 0.882643, 0.881921, 0.881197, 0.880471, 0.879743, 0.879012, 0.878280,
0.877545, 0.876809, 0.876070, 0.875329, 0.874587, 0.873842, 0.873095, 0.872346, 0.871595, 0.870842,
0.870087, 0.869330, 0.868571, 0.867809, 0.867046, 0.866281, 0.865514, 0.864744, 0.863973, 0.863199,
0.862424, 0.861646, 0.860867, 0.860085, 0.859302, 0.858516, 0.857729, 0.856939, 0.856147, 0.855354,
0.854558, 0.853760, 0.852961, 0.852159, 0.851355, 0.850549, 0.849742, 0.848932, 0.848120, 0.847307,
0.846491, 0.845673, 0.844854, 0.844032, 0.843208, 0.842383, 0.841555, 0.840725, 0.839894, 0.839060,
0.838225, 0.837387, 0.836548, 0.835706, 0.834863, 0.834018, 0.833170, 0.832321, 0.831470, 0.830616,
0.829761, 0.828904, 0.828045, 0.827184, 0.826321, 0.825456, 0.824589, 0.823721, 0.822850, 0.821977,
0.821102, 0.820226, 0.819348, 0.818467, 0.817585, 0.816701, 0.815814, 0.814926, 0.814036, 0.813144,
0.812251, 0.811355, 0.810457, 0.809558, 0.808656, 0.807753, 0.806848, 0.805940, 0.805031, 0.804120,
0.803208, 0.802293, 0.801376, 0.800458, 0.799537, 0.798615, 0.797691, 0.796765, 0.795837, 0.794907,
0.793975, 0.793042, 0.792107, 0.791169, 0.790230, 0.789289, 0.788346, 0.787402, 0.786455, 0.785507,
0.784557, 0.783605, 0.782651, 0.781695, 0.780737, 0.779778, 0.778817, 0.777853, 0.776888, 0.775922,
0.774953, 0.773983, 0.773010, 0.772036, 0.771061, 0.770083, 0.769103, 0.768122, 0.767139, 0.766154,
0.765167, 0.764179, 0.763188, 0.762196, 0.761202, 0.760207, 0.759209, 0.758210, 0.757209, 0.756206,
0.755201, 0.754195, 0.753187, 0.752177, 0.751165, 0.750152, 0.749136, 0.748119, 0.747101, 0.746080,
0.745058, 0.744034, 0.743008, 0.741980, 0.740951, 0.739920, 0.738887, 0.737853, 0.736817, 0.735779,
0.734739, 0.733697, 0.732654, 0.731609, 0.730563, 0.729514, 0.728464, 0.727413, 0.726359, 0.725304,
0.724247, 0.723188, 0.722128, 0.721066, 0.720003, 0.718937, 0.717870, 0.716801, 0.715731, 0.714659,
0.713585, 0.712509, 0.711432, 0.710353, 0.709273, 0.708191, 0.707107, 0.706021, 0.704934, 0.703845,
0.702755, 0.701663, 0.700569, 0.699473, 0.698376, 0.697277, 0.696177, 0.695075, 0.693971, 0.692866,
0.691759, 0.690651, 0.689541, 0.688429, 0.687315, 0.686200, 0.685084, 0.683965, 0.682846, 0.681724,
0.680601, 0.679476, 0.678350, 0.677222, 0.676093, 0.674962, 0.673829, 0.672695, 0.671559, 0.670422,
0.669283, 0.668142, 0.667000, 0.665856, 0.664711, 0.663564, 0.662416, 0.661266, 0.660114, 0.658961,
0.657807, 0.656651, 0.655493, 0.654334, 0.653173, 0.652011, 0.650847, 0.649681, 0.648514, 0.647346,
0.646176, 0.645005, 0.643832, 0.642657, 0.641481, 0.640303, 0.639124, 0.637944, 0.636762, 0.635578,
0.634393, 0.633207, 0.632019, 0.630829, 0.629638, 0.628446, 0.627252, 0.626056, 0.624860, 0.623661,
0.622461, 0.621260, 0.620057, 0.618853, 0.617647, 0.616440, 0.615232, 0.614022, 0.612810, 0.611597,
0.610383, 0.609167, 0.607950, 0.606731, 0.605511, 0.604290, 0.603067, 0.601842, 0.600616, 0.599389,
0.598161, 0.596931, 0.595699, 0.594467, 0.593232, 0.591997, 0.590760, 0.589521, 0.588282, 0.587040,
0.585798, 0.584554, 0.583309, 0.582062, 0.580814, 0.579565, 0.578314, 0.577062, 0.575808, 0.574553,
0.573297, 0.572040, 0.570781, 0.569521, 0.568259, 0.566996, 0.565732, 0.564466, 0.563199, 0.561931,
0.560662, 0.559391, 0.558119, 0.556845, 0.555570, 0.554294, 0.553017, 0.551738, 0.550458, 0.549177,
0.547894, 0.546610, 0.545325, 0.544039, 0.542751, 0.541462, 0.540171, 0.538880, 0.537587, 0.536293,
0.534998, 0.533701, 0.532403, 0.531104, 0.529804, 0.528502, 0.527199, 0.525895, 0.524590, 0.523283,
0.521975, 0.520666, 0.519356, 0.518045, 0.516732, 0.515418, 0.514103, 0.512786, 0.511469, 0.510150,
0.508830, 0.507509, 0.506187, 0.504863, 0.503538, 0.502212, 0.500885, 0.499557, 0.498228, 0.496897,
0.495565, 0.494232, 0.492898, 0.491563, 0.490226, 0.488889, 0.487550, 0.486210, 0.484869, 0.483527,
0.482184, 0.480839, 0.479494, 0.478147, 0.476799, 0.475450, 0.474100, 0.472749, 0.471397, 0.470043,
0.468689, 0.467333, 0.465977, 0.464619, 0.463260, 0.461900, 0.460539, 0.459177, 0.457813, 0.456449,
0.455084, 0.453717, 0.452350, 0.450981, 0.449611, 0.448241, 0.446869, 0.445496, 0.444122, 0.442747,
0.441371, 0.439994, 0.438616, 0.437237, 0.435857, 0.434476, 0.433094, 0.431711, 0.430326, 0.428941,
0.427555, 0.426168, 0.424780, 0.423390, 0.422000, 0.420609, 0.419217, 0.417824, 0.416430, 0.415034,
0.413638, 0.412241, 0.410843, 0.409444, 0.408044, 0.406643, 0.405241, 0.403838, 0.402435, 0.401030,
0.399624, 0.398218, 0.396810, 0.395401, 0.393992, 0.392582, 0.391170, 0.389758, 0.388345, 0.386931,
0.385516, 0.384100, 0.382683, 0.381266, 0.379847, 0.378428, 0.377007, 0.375586, 0.374164, 0.372741,
0.371317, 0.369892, 0.368467, 0.367040, 0.365613, 0.364185, 0.362756, 0.361326, 0.359895, 0.358463,
0.357031, 0.355598, 0.354164, 0.352729, 0.351293, 0.349856, 0.348419, 0.346980, 0.345541, 0.344101,
0.342661, 0.341219, 0.339777, 0.338334, 0.336890, 0.335445, 0.334000, 0.332553, 0.331106, 0.329658,
0.328210, 0.326760, 0.325310, 0.323859, 0.322408, 0.320955, 0.319502, 0.318048, 0.316593, 0.315138,
0.313682, 0.312225, 0.310767, 0.309309, 0.307850, 0.306390, 0.304929, 0.303468, 0.302006, 0.300543,
0.299080, 0.297616, 0.296151, 0.294685, 0.293219, 0.291752, 0.290285, 0.288816, 0.287347, 0.285878,
0.284408, 0.282937, 0.281465, 0.279993, 0.278520, 0.277046, 0.275572, 0.274097, 0.272621, 0.271145,
0.269668, 0.268191, 0.266713, 0.265234, 0.263755, 0.262275, 0.260794, 0.259313, 0.257831, 0.256349,
0.254866, 0.253382, 0.251898, 0.250413, 0.248928, 0.247442, 0.245955, 0.244468, 0.242980, 0.241492,
0.240003, 0.238514, 0.237024, 0.235533, 0.234042, 0.232550, 0.231058, 0.229565, 0.228072, 0.226578,
0.225084, 0.223589, 0.222094, 0.220598, 0.219101, 0.217604, 0.216107, 0.214609, 0.213110, 0.211611,
0.210112, 0.208612, 0.207111, 0.205610, 0.204109, 0.202607, 0.201105, 0.199602, 0.198098, 0.196595,
0.195090, 0.193586, 0.192080, 0.190575, 0.189069, 0.187562, 0.186055, 0.184548, 0.183040, 0.181532,
0.180023, 0.178514, 0.177004, 0.175494, 0.173984, 0.172473, 0.170962, 0.169450, 0.167938, 0.166426,
0.164913, 0.163400, 0.161886, 0.160372, 0.158858, 0.157343, 0.155828, 0.154313, 0.152797, 0.151281,
0.149765, 0.148248, 0.146730, 0.145213, 0.143695, 0.142177, 0.140658, 0.139139, 0.137620, 0.136101,
0.134581, 0.133061, 0.131540, 0.130019, 0.128498, 0.126977, 0.125455, 0.123933, 0.122411, 0.120888,
0.119365, 0.117842, 0.116319, 0.114795, 0.113271, 0.111747, 0.110222, 0.108697, 0.107172, 0.105647,
0.104122, 0.102596, 0.101070, 0.099544, 0.098017, 0.096490, 0.094963, 0.093436, 0.091909, 0.090381,
0.088854, 0.087326, 0.085797, 0.084269, 0.082740, 0.081211, 0.079682, 0.078153, 0.076624, 0.075094,
0.073565, 0.072035, 0.070505, 0.068974, 0.067444, 0.065913, 0.064383, 0.062852, 0.061321, 0.059790,
0.058258, 0.056727, 0.055195, 0.053664, 0.052132, 0.050600, 0.049068, 0.047535, 0.046003, 0.044471,
0.042938, 0.041406, 0.039873, 0.038340, 0.036807, 0.035274, 0.033741, 0.032208, 0.030675, 0.029142,
0.027608, 0.026075, 0.024541, 0.023008, 0.021474, 0.019940, 0.018407, 0.016873, 0.015339, 0.013805,
0.012272, 0.010738, 0.009204, 0.007670, 0.006136, 0.004602, 0.003068, 0.001534, -0.000000, -0.001534,
-0.003068, -0.004602, -0.006136, -0.007670, -0.009204, -0.010738, -0.012272, -0.013805, -0.015339, -0.016873,
-0.018407, -0.019940, -0.021474, -0.023008, -0.024541, -0.026075, -0.027608, -0.029142, -0.030675, -0.032208,
-0.033741, -0.035274, -0.036807, -0.038340, -0.039873, -0.041406, -0.042938, -0.044471, -0.046003, -0.047535,
-0.049068, -0.050600, -0.052132, -0.053664, -0.055195, -0.056727, -0.058258, -0.059790, -0.061321, -0.062852,
-0.064383, -0.065913, -0.067444, -0.068974, -0.070505, -0.072035, -0.073565, -0.075094, -0.076624, -0.078153,
-0.079682, -0.081211, -0.082740, -0.084269, -0.085797, -0.087326, -0.088854, -0.090381, -0.091909, -0.093436,
-0.094963, -0.096490, -0.098017, -0.099544, -0.101070, -0.102596, -0.104122, -0.105647, -0.107172, -0.108697,
-0.110222, -0.111747, -0.113271, -0.114795, -0.116319, -0.117842, -0.119365, -0.120888, -0.122411, -0.123933,
-0.125455, -0.126977, -0.128498, -0.130019, -0.131540, -0.133061, -0.134581, -0.136101, -0.137620, -0.139139,
-0.140658, -0.142177, -0.143695, -0.145213, -0.146730, -0.148248, -0.149765, -0.151281, -0.152797, -0.154313,
-0.155828, -0.157343, -0.158858, -0.160372, -0.161886, -0.163400, -0.164913, -0.166426, -0.167938, -0.169450,
-0.170962, -0.172473, -0.173984, -0.175494, -0.177004, -0.178514, -0.180023, -0.181532, -0.183040, -0.184548,
-0.186055, -0.187562, -0.189069, -0.190575, -0.192080, -0.193586, -0.195090, -0.196595, -0.198098, -0.199602,
-0.201105, -0.202607, -0.204109, -0.205610, -0.207111, -0.208612, -0.210112, -0.211611, -0.213110, -0.214609,
-0.216107, -0.217604, -0.219101, -0.220598, -0.222094, -0.223589, -0.225084, -0.226578, -0.228072, -0.229565,
-0.231058, -0.232550, -0.234042, -0.235533, -0.237024, -0.238514, -0.240003, -0.241492, -0.242980, -0.244468,
-0.245955, -0.247442, -0.248928, -0.250413, -0.251898, -0.253382, -0.254866, -0.256349, -0.257831, -0.259313,
-0.260794, -0.262275, -0.263755, -0.265234, -0.266713, -0.268191, -0.269668, -0.271145, -0.272621, -0.274097,
-0.275572, -0.277046, -0.278520, -0.279993, -0.281465, -0.282937, -0.284408, -0.285878, -0.287347, -0.288816,
-0.290285, -0.291752, -0.293219, -0.294685, -0.296151, -0.297616, -0.299080, -0.300543, -0.302006, -0.303468,
-0.304929, -0.306390, -0.307850, -0.309309, -0.310767, -0.312225, -0.313682, -0.315138, -0.316593, -0.318048,
-0.319502, -0.320955, -0.322408, -0.323859, -0.325310, -0.326760, -0.328210, -0.329658, -0.331106, -0.332553,
-0.334000, -0.335445, -0.336890, -0.338334, -0.339777, -0.341219, -0.342661, -0.344101, -0.345541, -0.346980,
-0.348419, -0.349856, -0.351293, -0.352729, -0.354164, -0.355598, -0.357031, -0.358463, -0.359895, -0.361326,
-0.362756, -0.364185, -0.365613, -0.367040, -0.368467, -0.369892, -0.371317, -0.372741, -0.374164, -0.375586,
-0.377007, -0.378428, -0.379847, -0.381266, -0.382683, -0.384100, -0.385516, -0.386931, -0.388345, -0.389758,
-0.391170, -0.392582, -0.393992, -0.395401, -0.396810, -0.398218, -0.399624, -0.401030, -0.402435, -0.403838,
-0.405241, -0.406643, -0.408044, -0.409444, -0.410843, -0.412241, -0.413638, -0.415034, -0.416430, -0.417824,
-0.419217, -0.420609, -0.422000, -0.423390, -0.424780, -0.426168, -0.427555, -0.428941, -0.430326, -0.431711,
-0.433094, -0.434476, -0.435857, -0.437237, -0.438616, -0.439994, -0.441371, -0.442747, -0.444122, -0.445496,
-0.446869, -0.448241, -0.449611, -0.450981, -0.452350, -0.453717, -0.455084, -0.456449, -0.457813, -0.459177,
-0.460539, -0.461900, -0.463260, -0.464619, -0.465977, -0.467333, -0.468689, -0.470043, -0.471397, -0.472749,
-0.474100, -0.475450, -0.476799, -0.478147, -0.479494, -0.480839, -0.482184, -0.483527, -0.484869, -0.486210,
-0.487550, -0.488889, -0.490226, -0.491563, -0.492898, -0.494232, -0.495565, -0.496897, -0.498228, -0.499557,
-0.500885, -0.502212, -0.503538, -0.504863, -0.506187, -0.507509, -0.508830, -0.510150, -0.511469, -0.512786,
-0.514103, -0.515418, -0.516732, -0.518045, -0.519356, -0.520666, -0.521975, -0.523283, -0.524590, -0.525895,
-0.527199, -0.528502, -0.529804, -0.531104, -0.532403, -0.533701, -0.534998, -0.536293, -0.537587, -0.538880,
-0.540171, -0.541462, -0.542751, -0.544039, -0.545325, -0.546610, -0.547894, -0.549177, -0.550458, -0.551738,
-0.553017, -0.554294, -0.555570, -0.556845, -0.558119, -0.559391, -0.560662, -0.561931, -0.563199, -0.564466,
-0.565732, -0.566996, -0.568259, -0.569521, -0.570781, -0.572040, -0.573297, -0.574553, -0.575808, -0.577062,
-0.578314, -0.579565, -0.580814, -0.582062, -0.583309, -0.584554, -0.585798, -0.587040, -0.588282, -0.589521,
-0.590760, -0.591997, -0.593232, -0.594467, -0.595699, -0.596931, -0.598161, -0.599389, -0.600616, -0.601842,
-0.603067, -0.604290, -0.605511, -0.606731, -0.607950, -0.609167, -0.610383, -0.611597, -0.612810, -0.614022,
-0.615232, -0.616440, -0.617647, -0.618853, -0.620057, -0.621260, -0.622461, -0.623661, -0.624860, -0.626056,
-0.627252, -0.628446, -0.629638, -0.630829, -0.632019, -0.633207, -0.634393, -0.635578, -0.636762, -0.637944,
-0.639124, -0.640303, -0.641481, -0.642657, -0.643832, -0.645005, -0.646176, -0.647346, -0.648514, -0.649681,
-0.650847, -0.652011, -0.653173, -0.654334, -0.655493, -0.656651, -0.657807, -0.658961, -0.660114, -0.661266,
-0.662416, -0.663564, -0.664711, -0.665856, -0.667000, -0.668142, -0.669283, -0.670422, -0.671559, -0.672695,
-0.673829, -0.674962, -0.676093, -0.677222, -0.678350, -0.679476, -0.680601, -0.681724, -0.682846, -0.683965,
-0.685084, -0.686200, -0.687315, -0.688429, -0.689541, -0.690651, -0.691759, -0.692866, -0.693971, -0.695075,
-0.696177, -0.697277, -0.698376, -0.699473, -0.700569, -0.701663, -0.702755, -0.703845, -0.704934, -0.706021,
-0.707107, -0.708191, -0.709273, -0.710353, -0.711432, -0.712509, -0.713585, -0.714659, -0.715731, -0.716801,
-0.717870, -0.718937, -0.720003, -0.721066, -0.722128, -0.723188, -0.724247, -0.725304, -0.726359, -0.727413,
-0.728464, -0.729514, -0.730563, -0.731609, -0.732654, -0.733697, -0.734739, -0.735779, -0.736817, -0.737853,
-0.738887, -0.739920, -0.740951, -0.741980, -0.743008, -0.744034, -0.745058, -0.746080, -0.747101, -0.748119,
-0.749136, -0.750152, -0.751165, -0.752177, -0.753187, -0.754195, -0.755201, -0.756206, -0.757209, -0.758210,
-0.759209, -0.760207, -0.761202, -0.762196, -0.763188, -0.764179, -0.765167, -0.766154, -0.767139, -0.768122,
-0.769103, -0.770083, -0.771061, -0.772036, -0.773010, -0.773983, -0.774953, -0.775922, -0.776888, -0.777853,
-0.778817, -0.779778, -0.780737, -0.781695, -0.782651, -0.783605, -0.784557, -0.785507, -0.786455, -0.787402,
-0.788346, -0.789289, -0.790230, -0.791169, -0.792107, -0.793042, -0.793975, -0.794907, -0.795837, -0.796765,
-0.797691, -0.798615, -0.799537, -0.800458, -0.801376, -0.802293, -0.803208, -0.804120, -0.805031, -0.805940,
-0.806848, -0.807753, -0.808656, -0.809558, -0.810457, -0.811355, -0.812251, -0.813144, -0.814036, -0.814926,
-0.815814, -0.816701, -0.817585, -0.818467, -0.819348, -0.820226, -0.821102, -0.821977, -0.822850, -0.823721,
-0.824589, -0.825456, -0.826321, -0.827184, -0.828045, -0.828904, -0.829761, -0.830616, -0.831470, -0.832321,
-0.833170, -0.834018, -0.834863, -0.835706, -0.836548, -0.837387, -0.838225, -0.839060, -0.839894, -0.840725,
-0.841555, -0.842383, -0.843208, -0.844032, -0.844854, -0.845673, -0.846491, -0.847307, -0.848120, -0.848932,
-0.849742, -0.850549, -0.851355, -0.852159, -0.852961, -0.853760, -0.854558, -0.855354, -0.856147, -0.856939,
-0.857729, -0.858516, -0.859302, -0.860085, -0.860867, -0.861646, -0.862424, -0.863199, -0.863973, -0.864744,
-0.865514, -0.866281, -0.867046, -0.867809, -0.868571, -0.869330, -0.870087, -0.870842, -0.871595, -0.872346,
-0.873095, -0.873842, -0.874587, -0.875329, -0.876070, -0.876809, -0.877545, -0.878280, -0.879012, -0.879743,
-0.880471, -0.881197, -0.881921, -0.882643, -0.883363, -0.884081, -0.884797, -0.885511, -0.886223, -0.886932,
-0.887640, -0.888345, -0.889048, -0.889750, -0.890449, -0.891146, -0.891841, -0.892534, -0.893224, -0.893913,
-0.894599, -0.895284, -0.895966, -0.896646, -0.897325, -0.898001, -0.898674, -0.899346, -0.900016, -0.900683,
-0.901349, -0.902012, -0.902673, -0.903332, -0.903989, -0.904644, -0.905297, -0.905947, -0.906596, -0.907242,
-0.907886, -0.908528, -0.909168, -0.909806, -0.910441, -0.911075, -0.911706, -0.912335, -0.912962, -0.913587,
-0.914210, -0.914830, -0.915449, -0.916065, -0.916679, -0.917291, -0.917901, -0.918508, -0.919114, -0.919717,
-0.920318, -0.920917, -0.921514, -0.922109, -0.922701, -0.923291, -0.923880, -0.924465, -0.925049, -0.925631,
-0.926210, -0.926787, -0.927363, -0.927935, -0.928506, -0.929075, -0.929641, -0.930205, -0.930767, -0.931327,
-0.931884, -0.932440, -0.932993, -0.933544, -0.934093, -0.934639, -0.935184, -0.935726, -0.936266, -0.936803,
-0.937339, -0.937872, -0.938404, -0.938932, -0.939459, -0.939984, -0.940506, -0.941026, -0.941544, -0.942060,
-0.942573, -0.943084, -0.943593, -0.944100, -0.944605, -0.945107, -0.945607, -0.946105, -0.946601, -0.947094,
-0.947586, -0.948075, -0.948561, -0.949046, -0.949528, -0.950008, -0.950486, -0.950962, -0.951435, -0.951906,
-0.952375, -0.952842, -0.953306, -0.953768, -0.954228, -0.954686, -0.955141, -0.955594, -0.956045, -0.956494,
-0.956940, -0.957385, -0.957826, -0.958266, -0.958703, -0.959139, -0.959572, -0.960002, -0.960431, -0.960857,
-0.961280, -0.961702, -0.962121, -0.962538, -0.962953, -0.963366, -0.963776, -0.964184, -0.964590, -0.964993,
-0.965394, -0.965793, -0.966190, -0.966584, -0.966976, -0.967366, -0.967754, -0.968139, -0.968522, -0.968903,
-0.969281, -0.969657, -0.970031, -0.970403, -0.970772, -0.971139, -0.971504, -0.971866, -0.972227, -0.972584,
-0.972940, -0.973293, -0.973644, -0.973993, -0.974339, -0.974684, -0.975025, -0.975365, -0.975702, -0.976037,
-0.976370, -0.976700, -0.977028, -0.977354, -0.977677, -0.977998, -0.978317, -0.978634, -0.978948, -0.979260,
-0.979570, -0.979877, -0.980182, -0.980485, -0.980785, -0.981083, -0.981379, -0.981673, -0.981964, -0.982253,
-0.982539, -0.982824, -0.983105, -0.983385, -0.983662, -0.983937, -0.984210, -0.984480, -0.984748, -0.985014,
-0.985278, -0.985539, -0.985798, -0.986054, -0.986308, -0.986560, -0.986809, -0.987057, -0.987301, -0.987544,
-0.987784, -0.988022, -0.988258, -0.988491, -0.988722, -0.988950, -0.989177, -0.989400, -0.989622, -0.989841,
-0.990058, -0.990273, -0.990485, -0.990695, -0.990903, -0.991108, -0.991311, -0.991511, -0.991710, -0.991906,
-0.992099, -0.992291, -0.992480, -0.992666, -0.992850, -0.993032, -0.993212, -0.993389, -0.993564, -0.993737,
-0.993907, -0.994075, -0.994240, -0.994404, -0.994565, -0.994723, -0.994879, -0.995033, -0.995185, -0.995334,
-0.995481, -0.995625, -0.995767, -0.995907, -0.996045, -0.996180, -0.996313, -0.996443, -0.996571, -0.996697,
-0.996820, -0.996941, -0.997060, -0.997176, -0.997290, -0.997402, -0.997511, -0.997618, -0.997723, -0.997825,
-0.997925, -0.998023, -0.998118, -0.998211, -0.998302, -0.998390, -0.998476, -0.998559, -0.998640, -0.998719,
-0.998795, -0.998870, -0.998941, -0.999011, -0.999078, -0.999142, -0.999205, -0.999265, -0.999322, -0.999378,
-0.999431, -0.999481, -0.999529, -0.999575, -0.999619, -0.999660, -0.999699, -0.999735, -0.999769, -0.999801,
-0.999831, -0.999858, -0.999882, -0.999905, -0.999925, -0.999942, -0.999958, -0.999971, -0.999981, -0.999989,
-0.999995, -0.999999, -1.000000, -0.999999, -0.999995, -0.999989, -0.999981, -0.999971, -0.999958, -0.999942,
-0.999925, -0.999905, -0.999882, -0.999858, -0.999831, -0.999801, -0.999769, -0.999735, -0.999699, -0.999660,
-0.999619, -0.999575, -0.999529, -0.999481, -0.999431, -0.999378, -0.999322, -0.999265, -0.999205, -0.999142,
-0.999078, -0.999011, -0.998941, -0.998870, -0.998795, -0.998719, -0.998640, -0.998559, -0.998476, -0.998390,
-0.998302, -0.998211, -0.998118, -0.998023, -0.997925, -0.997825, -0.997723, -0.997618, -0.997511, -0.997402,
-0.997290, -0.997176, -0.997060, -0.996941, -0.996820, -0.996697, -0.996571, -0.996443, -0.996313, -0.996180,
-0.996045, -0.995907, -0.995767, -0.995625, -0.995481, -0.995334, -0.995185, -0.995033, -0.994879, -0.994723,
-0.994565, -0.994404, -0.994240, -0.994075, -0.993907, -0.993737, -0.993564, -0.993389, -0.993212, -0.993032,
-0.992850, -0.992666, -0.992480, -0.992291, -0.992099, -0.991906, -0.991710, -0.991511, -0.991311, -0.991108,
-0.990903, -0.990695, -0.990485, -0.990273, -0.990058, -0.989841, -0.989622, -0.989400, -0.989177, -0.988950,
-0.988722, -0.988491, -0.988258, -0.988022, -0.987784, -0.987544, -0.987301, -0.987057, -0.986809, -0.986560,
-0.986308, -0.986054, -0.985798, -0.985539, -0.985278, -0.985014, -0.984748, -0.984480, -0.984210, -0.983937,
-0.983662, -0.983385, -0.983105, -0.982824, -0.982539, -0.982253, -0.981964, -0.981673, -0.981379, -0.981083,
-0.980785, -0.980485, -0.980182, -0.979877, -0.979570, -0.979260, -0.978948, -0.978634, -0.978317, -0.977998,
-0.977677, -0.977354, -0.977028, -0.976700, -0.976370, -0.976037, -0.975702, -0.975365, -0.975025, -0.974684,
-0.974339, -0.973993, -0.973644, -0.973293, -0.972940, -0.972584, -0.972227, -0.971866, -0.971504, -0.971139,
-0.970772, -0.970403, -0.970031, -0.969657, -0.969281, -0.968903, -0.968522, -0.968139, -0.967754, -0.967366,
-0.966976, -0.966584, -0.966190, -0.965793, -0.965394, -0.964993, -0.964590, -0.964184, -0.963776, -0.963366,
-0.962953, -0.962538, -0.962121, -0.961702, -0.961280, -0.960857, -0.960431, -0.960002, -0.959572, -0.959139,
-0.958703, -0.958266, -0.957826, -0.957385, -0.956940, -0.956494, -0.956045, -0.955594, -0.955141, -0.954686,
-0.954228, -0.953768, -0.953306, -0.952842, -0.952375, -0.951906, -0.951435, -0.950962, -0.950486, -0.950008,
-0.949528, -0.949046, -0.948561, -0.948075, -0.947586, -0.947094, -0.946601, -0.946105, -0.945607, -0.945107,
-0.944605, -0.944100, -0.943593, -0.943084, -0.942573, -0.942060, -0.941544, -0.941026, -0.940506, -0.939984,
-0.939459, -0.938932, -0.938404, -0.937872, -0.937339, -0.936803, -0.936266, -0.935726, -0.935184, -0.934639,
-0.934093, -0.933544, -0.932993, -0.932440, -0.931884, -0.931327, -0.930767, -0.930205, -0.929641, -0.929075,
-0.928506, -0.927935, -0.927363, -0.926787, -0.926210, -0.925631, -0.925049, -0.924465, -0.923880, -0.923291,
-0.922701, -0.922109, -0.921514, -0.920917, -0.920318, -0.919717, -0.919114, -0.918508, -0.917901, -0.917291,
-0.916679, -0.916065, -0.915449, -0.914830, -0.914210, -0.913587, -0.912962, -0.912335, -0.911706, -0.911075,
-0.910441, -0.909806, -0.909168, -0.908528, -0.907886, -0.907242, -0.906596, -0.905947, -0.905297, -0.904644,
-0.903989, -0.903332, -0.902673, -0.902012, -0.901349, -0.900683, -0.900016, -0.899346, -0.898674, -0.898001,
-0.897325, -0.896646, -0.895966, -0.895284, -0.894599, -0.893913, -0.893224, -0.892534, -0.891841, -0.891146,
-0.890449, -0.889750, -0.889048, -0.888345, -0.887640, -0.886932, -0.886223, -0.885511, -0.884797, -0.884081,
-0.883363, -0.882643, -0.881921, -0.881197, -0.880471, -0.879743, -0.879012, -0.878280, -0.877545, -0.876809,
-0.876070, -0.875329, -0.874587, -0.873842, -0.873095, -0.872346, -0.871595, -0.870842, -0.870087, -0.869330,
-0.868571, -0.867809, -0.867046, -0.866281, -0.865514, -0.864744, -0.863973, -0.863199, -0.862424, -0.861646,
-0.860867, -0.860085, -0.859302, -0.858516, -0.857729, -0.856939, -0.856147, -0.855354, -0.854558, -0.853760,
-0.852961, -0.852159, -0.851355, -0.850549, -0.849742, -0.848932, -0.848120, -0.847307, -0.846491, -0.845673,
-0.844854, -0.844032, -0.843208, -0.842383, -0.841555, -0.840725, -0.839894, -0.839060, -0.838225, -0.837387,
-0.836548, -0.835706, -0.834863, -0.834018, -0.833170, -0.832321, -0.831470, -0.830616, -0.829761, -0.828904,
-0.828045, -0.827184, -0.826321, -0.825456, -0.824589, -0.823721, -0.822850, -0.821977, -0.821102, -0.820226,
-0.819348, -0.818467, -0.817585, -0.816701, -0.815814, -0.814926, -0.814036, -0.813144, -0.812251, -0.811355,
-0.810457, -0.809558, -0.808656, -0.807753, -0.806848, -0.805940, -0.805031, -0.804120, -0.803208, -0.802293,
-0.801376, -0.800458, -0.799537, -0.798615, -0.797691, -0.796765, -0.795837, -0.794907, -0.793975, -0.793042,
-0.792107, -0.791169, -0.790230, -0.789289, -0.788346, -0.787402, -0.786455, -0.785507, -0.784557, -0.783605,
-0.782651, -0.781695, -0.780737, -0.779778, -0.778817, -0.777853, -0.776888, -0.775922, -0.774953, -0.773983,
-0.773010, -0.772036, -0.771061, -0.770083, -0.769103, -0.768122, -0.767139, -0.766154, -0.765167, -0.764179,
-0.763188, -0.762196, -0.761202, -0.760207, -0.759209, -0.758210, -0.757209, -0.756206, -0.755201, -0.754195,
-0.753187, -0.752177, -0.751165, -0.750152, -0.749136, -0.748119, -0.747101, -0.746080, -0.745058, -0.744034,
-0.743008, -0.741980, -0.740951, -0.739920, -0.738887, -0.737853, -0.736817, -0.735779, -0.734739, -0.733697,
-0.732654, -0.731609, -0.730563, -0.729514, -0.728464, -0.727413, -0.726359, -0.725304, -0.724247, -0.723188,
-0.722128, -0.721066, -0.720003, -0.718937, -0.717870, -0.716801, -0.715731, -0.714659, -0.713585, -0.712509,
-0.711432, -0.710353, -0.709273, -0.708191, -0.707107, -0.706021, -0.704934, -0.703845, -0.702755, -0.701663,
-0.700569, -0.699473, -0.698376, -0.697277, -0.696177, -0.695075, -0.693971, -0.692866, -0.691759, -0.690651,
-0.689541, -0.688429, -0.687315, -0.686200, -0.685084, -0.683965, -0.682846, -0.681724, -0.680601, -0.679476,
-0.678350, -0.677222, -0.676093, -0.674962, -0.673829, -0.672695, -0.671559, -0.670422, -0.669283, -0.668142,
-0.667000, -0.665856, -0.664711, -0.663564, -0.662416, -0.661266, -0.660114, -0.658961, -0.657807, -0.656651,
-0.655493, -0.654334, -0.653173, -0.652011, -0.650847, -0.649681, -0.648514, -0.647346, -0.646176, -0.645005,
-0.643832, -0.642657, -0.641481, -0.640303, -0.639124, -0.637944, -0.636762, -0.635578, -0.634393, -0.633207,
-0.632019, -0.630829, -0.629638, -0.628446, -0.627252, -0.626056, -0.624860, -0.623661, -0.622461, -0.621260,
-0.620057, -0.618853, -0.617647, -0.616440, -0.615232, -0.614022, -0.612810, -0.611597, -0.610383, -0.609167,
-0.607950, -0.606731, -0.605511, -0.604290, -0.603067, -0.601842, -0.600616, -0.599389, -0.598161, -0.596931,
-0.595699, -0.594467, -0.593232, -0.591997, -0.590760, -0.589521, -0.588282, -0.587040, -0.585798, -0.584554,
-0.583309, -0.582062, -0.580814, -0.579565, -0.578314, -0.577062, -0.575808, -0.574553, -0.573297, -0.572040,
-0.570781, -0.569521, -0.568259, -0.566996, -0.565732, -0.564466, -0.563199, -0.561931, -0.560662, -0.559391,
-0.558119, -0.556845, -0.555570, -0.554294, -0.553017, -0.551738, -0.550458, -0.549177, -0.547894, -0.546610,
-0.545325, -0.544039, -0.542751, -0.541462, -0.540171, -0.538880, -0.537587, -0.536293, -0.534998, -0.533701,
-0.532403, -0.531104, -0.529804, -0.528502, -0.527199, -0.525895, -0.524590, -0.523283, -0.521975, -0.520666,
-0.519356, -0.518045, -0.516732, -0.515418, -0.514103, -0.512786, -0.511469, -0.510150, -0.508830, -0.507509,
-0.506187, -0.504863, -0.503538, -0.502212, -0.500885, -0.499557, -0.498228, -0.496897, -0.495565, -0.494232,
-0.492898, -0.491563, -0.490226, -0.488889, -0.487550, -0.486210, -0.484869, -0.483527, -0.482184, -0.480839,
-0.479494, -0.478147, -0.476799, -0.475450, -0.474100, -0.472749, -0.471397, -0.470043, -0.468689, -0.467333,
-0.465977, -0.464619, -0.463260, -0.461900, -0.460539, -0.459177, -0.457813, -0.456449, -0.455084, -0.453717,
-0.452350, -0.450981, -0.449611, -0.448241, -0.446869, -0.445496, -0.444122, -0.442747, -0.441371, -0.439994,
-0.438616, -0.437237, -0.435857, -0.434476, -0.433094, -0.431711, -0.430326, -0.428941, -0.427555, -0.426168,
-0.424780, -0.423390, -0.422000, -0.420609, -0.419217, -0.417824, -0.416430, -0.415034, -0.413638, -0.412241,
-0.410843, -0.409444, -0.408044, -0.406643, -0.405241, -0.403838, -0.402435, -0.401030, -0.399624, -0.398218,
-0.396810, -0.395401, -0.393992, -0.392582, -0.391170, -0.389758, -0.388345, -0.386931, -0.385516, -0.384100,
-0.382683, -0.381266, -0.379847, -0.378428, -0.377007, -0.375586, -0.374164, -0.372741, -0.371317, -0.369892,
-0.368467, -0.367040, -0.365613, -0.364185, -0.362756, -0.361326, -0.359895, -0.358463, -0.357031, -0.355598,
-0.354164, -0.352729, -0.351293, -0.349856, -0.348419, -0.346980, -0.345541, -0.344101, -0.342661, -0.341219,
-0.339777, -0.338334, -0.336890, -0.335445, -0.334000, -0.332553, -0.331106, -0.329658, -0.328210, -0.326760,
-0.325310, -0.323859, -0.322408, -0.320955, -0.319502, -0.318048, -0.316593, -0.315138, -0.313682, -0.312225,
-0.310767, -0.309309, -0.307850, -0.306390, -0.304929, -0.303468, -0.302006, -0.300543, -0.299080, -0.297616,
-0.296151, -0.294685, -0.293219, -0.291752, -0.290285, -0.288816, -0.287347, -0.285878, -0.284408, -0.282937,
-0.281465, -0.279993, -0.278520, -0.277046, -0.275572, -0.274097, -0.272621, -0.271145, -0.269668, -0.268191,
-0.266713, -0.265234, -0.263755, -0.262275, -0.260794, -0.259313, -0.257831, -0.256349, -0.254866, -0.253382,
-0.251898, -0.250413, -0.248928, -0.247442, -0.245955, -0.244468, -0.242980, -0.241492, -0.240003, -0.238514,
-0.237024, -0.235533, -0.234042, -0.232550, -0.231058, -0.229565, -0.228072, -0.226578, -0.225084, -0.223589,
-0.222094, -0.220598, -0.219101, -0.217604, -0.216107, -0.214609, -0.213110, -0.211611, -0.210112, -0.208612,
-0.207111, -0.205610, -0.204109, -0.202607, -0.201105, -0.199602, -0.198098, -0.196595, -0.195090, -0.193586,
-0.192080, -0.190575, -0.189069, -0.187562, -0.186055, -0.184548, -0.183040, -0.181532, -0.180023, -0.178514,
-0.177004, -0.175494, -0.173984, -0.172473, -0.170962, -0.169450, -0.167938, -0.166426, -0.164913, -0.163400,
-0.161886, -0.160372, -0.158858, -0.157343, -0.155828, -0.154313, -0.152797, -0.151281, -0.149765, -0.148248,
-0.146730, -0.145213, -0.143695, -0.142177, -0.140658, -0.139139, -0.137620, -0.136101, -0.134581, -0.133061,
-0.131540, -0.130019, -0.128498, -0.126977, -0.125455, -0.123933, -0.122411, -0.120888, -0.119365, -0.117842,
-0.116319, -0.114795, -0.113271, -0.111747, -0.110222, -0.108697, -0.107172, -0.105647, -0.104122, -0.102596,
-0.101070, -0.099544, -0.098017, -0.096490, -0.094963, -0.093436, -0.091909, -0.090381, -0.088854, -0.087326,
-0.085797, -0.084269, -0.082740, -0.081211, -0.079682, -0.078153, -0.076624, -0.075094, -0.073565, -0.072035,
-0.070505, -0.068974, -0.067444, -0.065913, -0.064383, -0.062852, -0.061321, -0.059790, -0.058258, -0.056727,
-0.055195, -0.053664, -0.052132, -0.050600, -0.049068, -0.047535, -0.046003, -0.044471, -0.042938, -0.041406,
-0.039873, -0.038340, -0.036807, -0.035274, -0.033741, -0.032208, -0.030675, -0.029142, -0.027608, -0.026075,
-0.024541, -0.023008, -0.021474, -0.019940, -0.018407, -0.016873, -0.015339, -0.013805, -0.012272, -0.010738,
-0.009204, -0.007670, -0.006136, -0.004602, -0.003068, -0.001534,
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif
// --- DFT.c ---
/*__--------------_-----------_---------------------__---------------------
/ _|___ _ _ _ _(_)___ _ _ | |_ _ _ __ _ _ _ ___/ _|___ _ _ _ __
| _/ _ \ || | '_| / -_) '_| | _| '_/ _` | ' \(_-< _/ _ \ '_| ' \
|_| \___/\_,_|_| |_\___|_| \__|_| \__,_|_||_/__/_| \___/_| |_|_|_|
-------------------------------------------------------------------------*/
//MODIFIED AUGUST 29 2018 TO FIX ERRORS IN REAL FORWARD AND INVERSE TRANSFORMS!
//MODIFIED MARCH 25 2023 TO INCLUDE IN PLACE REAL TRANSFORMS