Chris@32
|
1 "use strict";
|
Chris@32
|
2
|
Chris@32
|
3 var nayukiCModule = NayukiCModule({});
|
Chris@32
|
4
|
Chris@32
|
5 var nc_precalc = nayukiCModule.cwrap(
|
Chris@32
|
6 'precalc', 'number', ['number']
|
Chris@32
|
7 );
|
Chris@32
|
8
|
Chris@32
|
9 var nc_dispose = nayukiCModule.cwrap(
|
Chris@32
|
10 'dispose', 'void', ['number']
|
Chris@32
|
11 );
|
Chris@32
|
12
|
Chris@32
|
13 var nc_transform_radix2_precalc = nayukiCModule.cwrap(
|
Chris@32
|
14 'transform_radix2_precalc', 'void', ['number', 'number', 'number', 'number']
|
Chris@32
|
15 );
|
Chris@32
|
16
|
Chris@33
|
17 var nc_precalc_f = nayukiCModule.cwrap(
|
Chris@33
|
18 'precalc_f', 'number', ['number']
|
Chris@33
|
19 );
|
Chris@33
|
20
|
Chris@33
|
21 var nc_dispose_f = nayukiCModule.cwrap(
|
Chris@33
|
22 'dispose_f', 'void', ['number']
|
Chris@33
|
23 );
|
Chris@33
|
24
|
Chris@33
|
25 var nc_transform_radix2_precalc_f = nayukiCModule.cwrap(
|
Chris@33
|
26 'transform_radix2_precalc_f', 'void', ['number', 'number', 'number', 'number']
|
Chris@33
|
27 );
|
Chris@33
|
28
|
Chris@32
|
29 function FFTNayukiC(n) {
|
Chris@32
|
30
|
Chris@32
|
31 this.n = n;
|
Chris@32
|
32 this.rptr = nayukiCModule._malloc(n*8 + n*8);
|
Chris@32
|
33 this.iptr = this.rptr + n*8;
|
Chris@32
|
34 this.rarr = new Float64Array(nayukiCModule.HEAPU8.buffer, this.rptr, n);
|
Chris@32
|
35 this.iarr = new Float64Array(nayukiCModule.HEAPU8.buffer, this.iptr, n);
|
Chris@32
|
36 this.tables = nc_precalc(n);
|
Chris@32
|
37
|
Chris@32
|
38 this.forward = function(real, imag) {
|
Chris@32
|
39 this.rarr.set(real);
|
Chris@32
|
40 this.iarr.set(imag);
|
Chris@32
|
41 nc_transform_radix2_precalc(this.rptr, this.iptr, this.n, this.tables);
|
Chris@32
|
42 real.set(this.rarr);
|
Chris@32
|
43 imag.set(this.iarr);
|
Chris@32
|
44 };
|
Chris@32
|
45
|
Chris@32
|
46 this.dispose = function() {
|
Chris@32
|
47 nayukiCModule._free(this.rptr);
|
Chris@32
|
48 nc_dispose(this.tables);
|
Chris@32
|
49 }
|
Chris@32
|
50 }
|
Chris@32
|
51
|
Chris@33
|
52 function FFTNayukiCFloat(n) {
|
Chris@33
|
53
|
Chris@33
|
54 this.n = n;
|
Chris@33
|
55 this.rptr = nayukiCModule._malloc(n*4 + n*4);
|
Chris@33
|
56 this.iptr = this.rptr + n*4;
|
Chris@33
|
57 this.rarr = new Float32Array(nayukiCModule.HEAPU8.buffer, this.rptr, n);
|
Chris@33
|
58 this.iarr = new Float32Array(nayukiCModule.HEAPU8.buffer, this.iptr, n);
|
Chris@33
|
59 this.tables = nc_precalc_f(n);
|
Chris@33
|
60
|
Chris@33
|
61 this.forward = function(real, imag) {
|
Chris@33
|
62 this.rarr.set(real);
|
Chris@33
|
63 this.iarr.set(imag);
|
Chris@33
|
64 nc_transform_radix2_precalc_f(this.rptr, this.iptr, this.n, this.tables);
|
Chris@33
|
65 real.set(this.rarr);
|
Chris@33
|
66 imag.set(this.iarr);
|
Chris@33
|
67 };
|
Chris@33
|
68
|
Chris@33
|
69 this.dispose = function() {
|
Chris@33
|
70 nayukiCModule._free(this.rptr);
|
Chris@33
|
71 nc_dispose_f(this.tables);
|
Chris@33
|
72 }
|
Chris@33
|
73 }
|
Chris@33
|
74
|