comparison fft/test.html @ 2:44f670784d5f

Test jsfft
author Chris Cannam
date Thu, 01 Oct 2015 17:33:28 +0100
parents 1c027151f7ec
children b3243c84ccb3
comparison
equal deleted inserted replaced
1:1c027151f7ec 2:44f670784d5f
1 <html> 1 <html>
2 <meta charset="UTF-8">
2 <body> 3 <body>
3 <p>If 2150 iterations of real-to-complex FFT of size 2048 takes less than 10 seconds, then we may be able to make a high quality real-time phase vocoder (just).</p> 4 <p>If 2150 iterations of real-to-complex FFT of size 2048 takes less than 10 seconds, then we may be able to make a high quality real-time phase vocoder (just).</p>
4 5
5 <p>A phase-vocoder of course must use overlapped 6 <p>A phase-vocoder of course must use overlapped
6 windowed FFT (although you can choose the size, within limits), IFFT, 7 windowed FFT (although you can choose the size, within limits), IFFT,
12 Fourier transforms across the signal. </p> 13 Fourier transforms across the signal. </p>
13 14
14 <p>2150 iterations corresponds to 100 seconds of audio non-overlapped at 15 <p>2150 iterations corresponds to 100 seconds of audio non-overlapped at
15 44.1kHz, so if that takes less than 10 second, then in theory we might 16 44.1kHz, so if that takes less than 10 second, then in theory we might
16 be OK.</p> 17 be OK.</p>
17 <pre> 18
18 <script src="nayuki/fft.js"></script> 19 <script src="nayuki/fft.js"></script>
19 <script> 20 <script>
20 21
21 /* for a phase vocoder, we probably want 2048-point real-to-complex 22 /* for a phase vocoder, we probably want 2048-point real-to-complex
22 * FFTs (if available) */ 23 * FFTs (if available) */
60 61
61 document.write("total = " + total + "<br>"); 62 document.write("total = " + total + "<br>");
62 63
63 var end = performance.now(); 64 var end = performance.now();
64 65
65 document.write("nayuki fft.js: " + iterations + " iterations at size " + size + " took " + (end - start) + "ms (" + (1000.0 / ((end - start) / iterations)) + " iterations/sec)<br>"); 66 document.write("nayuki fft.js: " + iterations + " iterations at size " + size + " took " + (end - start) + "ms (" + (1000.0 / ((end - start) / iterations)) + " iterations/sec)<br><br>");
66 67
67 </script> 68 </script>
68 <script src="fft.js/lib/complex.js"></script> 69 <script src="fft.js/lib/complex.js"></script>
69 <script> 70 <script>
70 71
85 86
86 document.write("total = " + total + "<br>"); 87 document.write("total = " + total + "<br>");
87 88
88 var end = performance.now(); 89 var end = performance.now();
89 90
90 document.write("nockert fft.js: " + iterations + " iterations at size " + size + " took " + (end - start) + "ms (" + (1000.0 / ((end - start) / iterations)) + " iterations/sec)<br>"); 91 document.write("nockert fft.js: " + iterations + " iterations at size " + size + " took " + (end - start) + "ms (" + (1000.0 / ((end - start) / iterations)) + " iterations/sec)<br><br>");
91 92
92 </script> 93 </script>
93 </pre> 94 <script src="jsfft/lib/complex_array.js"></script><script src="jsfft/lib/fft.js"></script>
95 <script>
96
97 function inputComplexArray(size) {
98 var result = new complex_array.ComplexArray(size);
99 for (var i = 0; i < size; i++) {
100 result.real[i] = (i % 20) / 10.0 - 1.0;
101 result.imag[i] = 0.0;
102 }
103 return result;
104 }
105
106 start = performance.now();
107
108 total = 0.0;
109
110 for (var i = 0; i < iterations; ++i) {
111 var ci = inputComplexArray(size);
112 var co = ci.FFT();
113 for (var j = 0; j < size; ++j) {
114 total += co.real[j] + co.imag[j];
115 }
116 }
117
118 document.write("total = " + total + "<br>");
119
120 var end = performance.now();
121
122 document.write("dntj jsfft: " + iterations + " iterations at size " + size + " took " + (end - start) + "ms (" + (1000.0 / ((end - start) / iterations)) + " iterations/sec)<br><br>");
123
124 </script>
125
94 </body> 126 </body>
95 127