Created
February 1, 2025 19:15
-
-
Save geraintluff/288080d44aaa7487de811887c8c6c499 to your computer and use it in GitHub Desktop.
Test code and output plots comparing two very-close BLAMPs vs a single BLEP, with single-precision float
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "elliptic-blep.h" | |
#include "plot.h" | |
#include "simple-fft.h" | |
#include <vector> | |
void generateWaveform(float freq, float shape, std::vector<float> &result, bool sawtooth) { | |
float phase = 0; | |
float gradUp = freq*2/shape; | |
float gradDown = freq*-2/(1 - shape); | |
float corner1 = 0.5*shape, corner2 = 1 - corner1; | |
signalsmith::blep::EllipticBlep<float> blepper; | |
// Initial gradient change to kick us off | |
blepper.add(gradUp, 2); | |
for (auto &v : result) { | |
// Move the oscillator forwards | |
float prevPhase = phase; | |
phase += freq; | |
// And the blepper | |
blepper.step(); | |
if (sawtooth) { | |
if (phase >= corner1 && prevPhase < corner1) { | |
float samplesInPast = (phase - corner1)/freq; | |
// -2 step jump | |
blepper.add(-2, 1, samplesInPast); | |
} | |
if (phase >= 1) { | |
phase -= 1; | |
} | |
} else { | |
if (phase >= corner2 && prevPhase < corner2) { | |
float samplesInPast = (phase - corner2)/freq; | |
blepper.add(gradUp - gradDown, 2, samplesInPast); | |
} | |
if (phase >= 1) { | |
phase -= 1; | |
prevPhase -= 1; | |
} | |
// Discontinuities | |
if (phase >= corner1 && prevPhase < corner1) { | |
float samplesInPast = (phase - corner1)/freq; | |
blepper.add(gradDown - gradUp, 2, samplesInPast); | |
} | |
} | |
// Naive waveform | |
if (phase < corner1) { | |
v = 2*phase/shape; | |
} else if (phase < corner2) { | |
v = (2*phase - 1)/(shape - 1); | |
} else { | |
v = 2*(phase - 1)/shape; | |
} | |
// Add BLEP | |
v += blepper.get(); | |
} | |
} | |
int main() { | |
size_t length = 16384; | |
float freq = 0.02373020996; // C6 at 44.1kHz | |
signalsmith::plot::Figure figure; | |
auto &timePlot = figure(0, 0).plot(600, 150); | |
timePlot.x.linear(9.9/freq, 14.6/freq); | |
timePlot.y.major(0).linear(-1.1, 1.1).minors(-1, 1); | |
auto &freqPlot = figure(0, 1).plot(600, 200); | |
freqPlot.x.linear(0, 0.5).major(0).minor(0.5, "Nyquist").label("frequency"); | |
freqPlot.y.linear(-130, 0).major(0).minors(-30, -60, -90, -120).label("dB"); | |
auto &timeLine = timePlot.line(); | |
auto &freqLine = freqPlot.line(); | |
std::vector<float> signal(length); | |
signalsmith::linear::SimpleFFT<float> fft(length); | |
using Complex = std::complex<float>; | |
std::vector<Complex> fftTime(length), fftFreq(length); | |
auto plotWaveform = [&](float shape, bool sawtooth){ | |
generateWaveform(freq, shape, signal, sawtooth); | |
// Spectrum analysis | |
for (size_t i = 0; i < length; ++i) { | |
float r = (i + 0.5f)/length; | |
fftTime[i] = signal[i]*(1 - std::cos(2*M_PI*r)); | |
} | |
fft.fft(length, fftTime.data(), fftFreq.data()); | |
// Plot waveform and spectrum | |
for (size_t i = 0; i < length; ++i) { | |
timeLine.add(i, signal[i]); | |
float db = 10*std::log10(std::norm(fftFreq[i]/float(length)) + 1e-30f); | |
freqLine.add(i/float(length), db); | |
} | |
}; | |
for (double r = 0; r <= 1; r += 0.01) { | |
float shape = 0.5 + 0.499*std::sin(r*2*M_PI); | |
plotWaveform(shape, false); | |
figure.toFrame(r*10); | |
} | |
figure.loopFrame(10); | |
figure.write("animation.svg"); | |
figure.toFrame(0); | |
figure.clearFrames(); | |
timePlot.title("shape = 0.5"); | |
plotWaveform(0.5, false); | |
figure.write("shape-5.svg"); | |
figure.toFrame(0); | |
figure.clearFrames(); | |
timePlot.title("shape = 0.9"); | |
plotWaveform(0.9, false); | |
figure.write("shape-9.svg"); | |
figure.toFrame(0); | |
figure.clearFrames(); | |
timePlot.title("shape = 0.999"); | |
plotWaveform(0.999, false); | |
figure.write("shape-999.svg"); | |
figure.toFrame(0); | |
figure.clearFrames(); | |
timePlot.title("shape = 0.9999"); | |
plotWaveform(0.9999, false); | |
figure.write("shape-9999.svg"); | |
figure.toFrame(0); | |
figure.clearFrames(); | |
timePlot.title("shape = 0.99999"); | |
plotWaveform(0.99999, false); | |
figure.write("shape-99999.svg"); | |
figure.toFrame(0); | |
figure.clearFrames(); | |
timePlot.title("shape = sawtooth"); | |
plotWaveform(1, true); | |
figure.write("shape-sawtooth.svg"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" standalone="no"?> | |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | |
<svg version="1.1" class="svg-plot" xmlns="http://www.w3.org/2000/svg" width="680.8pt" height="428pt" viewBox="-10 -10 680.8 428" preserveAspectRatio="xMidYMid"><rect x="-10" y="-10" width="680.8" height="428" class="svg-plot-bg"/><g transform="translate(42.7 4)"><g class="svg-plot-group"><rect x="0" y="0" width="600" height="150" class="svg-plot-axis"/><line x1="0" x2="600" y1="75" y2="75" class="svg-plot-major"/><line x1="0" x2="600" y1="143.182" y2="143.182" class="svg-plot-minor"/><line x1="0" x2="600" y1="6.81818" y2="6.81818" class="svg-plot-minor"/><clipPath id="clip0"><rect x="-0.75" y="-0.75" width="601.5" height="151.5"/></clipPath><g clip-path="url(#clip0)"><path class="svg-plot-line svg-plot-s0 svg-plot-d0" d="M -1263.83 74.98 -1263.83 74.98 -3.6 95.38 -0.57 94.98 2.45 90.69 5.48 86.76 8.51 85.5 11.54 79.19 14.57 79.55 17.6 72.4 20.63 72.88 23.66 66.22 26.69 65.74 29.72 60.35 32.75 58.45 35.78 54.51 38.81 51.22 41.84 48.53 44.87 44.2 47.9 42.31 50.92 37.43 53.95 35.85 56.98 30.89 60.01 29.16 63.04 24.55 66.07 22.33 69.1 18.31 72.13 15.43 75.16 12.65 78.19 17.73 81.22 68.5 81.22 68.5 84.25 153.4 84.25 153.4 87.28 150.97 90.31 115.18 93.34 142.09 96.37 121.26 99.39 123.44 102.42 124.37 105.45 112.19 108.48 120.12 111.51 105.32 114.54 112.09 117.57 101.19 120.6 102.88 123.63 97.09 126.66 94.2 129.69 92.29 132.72 86.25 135.75 86.7 138.78 79.16 141.81 80.24 144.84 72.87 147.87 73.13 150.89 67.05 153.92 65.73 156.95 61.34 159.98 58.37 163.01 55.48 166.04 51.23 169.07 49.36 172.1 44.38 175.13 42.96 178.16 37.8 181.19 36.3 184.22 31.45 187.25 29.46 190.28 25.22 193.31 22.54 196.34 19.03 199.36 15.64 202.39 13.15 205.42 15.23 208.45 57.55 211.48 144.03 211.48 144.03 214.51 157.89 214.51 157.89 217.54 115.12 220.57 139.63 223.6 125.66 226.63 120.27 229.66 127.36 232.69 111.22 235.72 120.98 238.75 106.24 241.78 111.49 244.81 103.02 247.84 101.89 250.86 98.93 253.89 93.43 256.92 93.75 259.95 85.99 262.98 87.58 266.01 79.48 269.04 80.59 272.07 73.65 275.1 73.11 278.13 68.07 281.16 65.59 284.19 62.39 287.22 58.29 290.25 56.4 293.28 51.33 296.31 50.07 299.33 44.7 302.36 43.45 305.39 38.33 308.42 36.61 311.45 32.12 314.48 29.66 317.51 25.96 320.54 22.72 323.57 19.76 326.6 15.86 329.63 13.65 332.66 13.54 335.69 47.8 338.72 132.97 338.72 132.97 341.75 163.3 341.75 163.3 344.78 117.18 347.8 135.8 350.83 130.46 353.86 117.46 356.89 129.54 359.92 111.2 362.95 120.91 365.98 107.95 369.01 110.33 372.04 105.17 375.07 100.79 378.1 100.71 381.13 92.88 384.16 94.89 387.19 86.1 390.22 88.08 393.25 80.17 396.28 80.6 399.3 74.7 402.33 72.91 405.36 69.21 408.39 65.41 411.42 63.41 414.45 58.29 417.48 57.2 420.51 51.59 423.54 50.62 426.57 45.19 429.6 43.78 432.63 39 435.66 36.8 438.69 32.88 444.75 26.73 447.77 22.9 450.8 20.46 453.83 16.14 456.86 14.11 459.89 12.52 462.92 39.34 465.95 120.71 465.95 120.71 468.98 166.65 468.98 166.65 472.01 121.29 475.04 131.06 478.07 135.1 481.1 115.47 484.13 130.63 487.16 112.26 490.19 119.95 493.22 110.29 499.27 107.39 502.3 99.83 505.33 102.2 508.36 92.71 511.39 95.61 514.42 86.64 517.45 88.18 520.48 81.21 523.51 80.35 526.54 75.92 529.57 72.61 532.6 70.36 535.63 65.29 538.66 64.32 541.69 58.46 544.72 57.81 547.74 52.03 550.77 50.98 553.8 45.85 556.83 43.97 559.86 39.77 562.89 36.92 565.92 33.68 568.95 29.95 571.98 27.46 575.01 23.14 578.04 21.07 581.07 16.51 584.1 14.5 587.13 12.04 590.16 32.19 593.19 107.8 593.19 107.8 596.21 167.55 596.21 167.55 599.24 127.17 599.24 127.17 602.27 126.01"/></g></g></g><g transform="translate(42.7 173)"><g class="svg-plot-group"><rect x="0" y="0" width="600" height="200" class="svg-plot-axis"/><line x1="0" x2="0" y1="0" y2="200" class="svg-plot-major"/><line x1="600" x2="600" y1="0" y2="200" class="svg-plot-minor"/><line x1="0" x2="600" y1="0" y2="0" class="svg-plot-major"/><line x1="0" x2="600" y1="46.1538" y2="46.1538" class="svg-plot-minor"/><line x1="0" x2="600" y1="92.3077" y2="92.3077" class="svg-plot-minor"/><line x1="0" x2="600" y1="138.462" y2="138.462" class="svg-plot-minor"/><line x1="0" x2="600" y1="184.615" y2="184.615" class="svg-plot-minor"/><clipPath id="clip1"><rect x="-0.75" y="-0.75" width="601.5" height="201.5"/></clipPath><g clip-path="url(#clip1)"><path class="svg-plot-line svg-plot-s0 svg-plot-d0" d="M 0 180.47 0.07 190.07 0.07 190.07 0.15 238.22 3.81 210.32 3.96 161.84 4.03 160.52 4.1 179.77 4.1 179.77 4.17 207.62 7.84 229.2 7.91 189.58 7.98 177.29 8.06 183.62 8.06 183.62 8.13 223.85 8.42 209.05 8.5 201.15 8.5 201.15 8.57 212.34 11.87 223 11.94 192.29 12.01 188.32 12.01 188.32 12.08 203.53 12.38 219.26 12.45 197.41 12.52 197.61 12.52 197.61 12.6 218.52 15.89 210.68 15.97 196.34 16.04 199.16 16.04 199.16 16.11 234.32 16.33 256.03 16.41 199.13 16.48 187.69 16.55 196.12 16.55 196.12 16.63 234.25 20.36 208.04 20.43 181.05 20.51 178.52 20.58 195.46 20.58 195.46 20.65 219.69 23.8 203.8 23.88 201.91 23.88 201.91 23.95 207.12 23.95 207.12 24.02 196.92 24.02 196.92 24.1 202.67 24.1 202.67 24.17 201.6 24.24 202 24.24 202 24.32 207.27 24.32 207.27 24.39 176.32 24.46 159.24 24.54 166.29 24.61 188.27 24.68 193.59 24.76 194.04 24.83 193.63 24.9 191.86 24.98 194.52 25.05 190.38 25.12 190.58 25.42 187.04 25.49 185.78 25.56 185.05 25.93 179.63 26.29 173.37 26.59 167.58 26.88 160.81 27.1 154.88 27.32 147.89 27.54 139.43 27.76 128.65 27.91 119.41 28.05 107.34 28.2 89.82 28.27 76.7 28.34 55.82 28.42 20.85 28.49 15.51 28.56 29.12 28.64 65.91 28.71 82.62 28.86 102.93 29 116.21 29.15 126.13 29.3 134.07 29.52 143.6 29.74 151.32 29.96 157.75 30.18 163.33 30.47 169.78 30.76 175.21 30.98 178.78 31.13 181.17 31.42 185.3 31.49 186.51 31.57 187.23 31.86 190.97 31.93 191.02 32.01 192.88 32.08 192.98 32.15 193.66 32.23 193.66 32.3 191.47 32.45 160.14 32.52 161.09 32.59 193.09 32.59 193.09 32.67 204.19 32.67 204.19 32.74 201.97 32.81 201.88 32.81 201.88 32.89 206.48 32.89 206.48 32.96 195.08 32.96 195.08 33.03 211.62 36.33 227.65 36.4 184.51 36.47 177.14 36.55 186.67 36.55 186.67 36.62 222.64 36.91 206.37 36.99 201.66 36.99 201.66 37.06 217.43 40.36 211.42 40.43 189.97 40.5 189.44 40.5 189.44 40.58 210.75 40.87 213.35 40.94 195.97 41.02 200.56 41.02 200.56 41.09 225.49 44.38 205.47 44.46 195.6 44.53 201.93 44.53 201.93 44.6 248.73 44.82 229.42 44.9 195.4 44.97 188 45.04 200.87 45.04 200.87 45.12 255.55 48.78 221.64 48.93 179.47 49 180.35 49 180.35 49.07 204.08 52.44 204.57 52.51 200.56 52.51 200.56 52.59 204.46 52.81 202.91 52.88 170.97 52.95 159.62 53.03 170.35 53.1 198.52 53.17 198.28 53.32 196.94 53.39 193.93 53.47 198.67 53.54 193.3 53.61 193.38 53.83 190.66 53.91 190.11 53.98 188.41 54.05 187.89 54.49 181.25 54.86 174.76 55.15 168.7 55.44 161.59 55.66 155.25 55.88 147.75 56.1 138.47 56.25 130.83 56.4 121.36 56.54 108.91 56.69 90.52 56.76 76.37 56.91 27.57 56.98 25.94 57.06 44.69 57.13 73.05 57.2 88.3 57.35 107.55 57.5 120.38 57.64 130.05 57.79 137.83 58.01 147.22 58.23 154.83 58.45 161.18 58.67 166.72 58.96 173.13 59.25 178.52 59.4 181.1 59.47 181.99 59.55 183.41 59.84 187.64 59.91 188.34 59.99 189.97 60.06 190.45 60.28 193.28 60.42 194.87 60.5 195.23 60.57 196.61 60.64 197.16 60.72 197.37 60.79 195.52 60.86 169.74 60.94 158.17 61.01 163.45 61.01 163.45 61.08 202.83 61.38 213 61.45 196.85 61.45 196.85 61.52 213.31 64.82 217.74 64.89 181.04 64.97 177.38 65.04 191.21 65.04 191.21 65.11 218.16 68.85 204.4 68.92 188.1 68.99 191.46 68.99 191.46 69.07 219.69 69.36 207.19 69.43 195.59 69.43 195.59 69.51 203.54 72.8 253.41 72.88 201.66 72.95 195.24 72.95 195.24 73.02 205.94 73.32 218.18 73.39 192.4 73.46 189.03 73.46 189.03 73.54 206.75 76.83 228.84 76.9 201.64 76.9 201.64 76.98 204.48 77.27 222.84 77.34 192.56 77.42 178.57 77.49 182.99 77.49 182.99 77.56 217.45 81.23 205.49 81.3 196.98 81.37 167.2 81.45 160.77 81.52 175.19 81.52 175.19 81.59 208.94 81.81 203.41 81.88 198.07 81.88 198.07 81.96 206.2 81.96 206.2 82.03 198.98 82.1 198.93 82.25 197.2 82.32 196.07 82.4 196.17 82.47 193.71 82.54 193.46 82.84 189.11 82.91 187.8 82.98 186.85 83.35 180.24 83.64 174.14 83.94 166.96 84.16 160.56 84.38 152.97 84.59 143.53 84.74 135.74 84.89 126.02 85.03 113.16 85.18 93.82 85.25 78.43 85.33 49.46 85.4 31.28 85.47 33.29 85.62 82.5 85.69 96.55 85.84 114.84 85.99 127.25 86.13 136.7 86.28 144.32 86.5 153.57 86.72 161.08 86.94 167.36 87.16 172.85 87.38 177.56 87.52 180.52 87.74 184.56 87.89 187.25 87.96 187.92 88.04 189.42 88.33 193.77 88.4 193.92 88.48 196.29 88.55 196.42 88.77 199.23 88.84 199.3 88.84 199.3 88.92 202.35 88.92 202.35 88.99 199.96 88.99 199.96 89.06 202.8 89.28 205.43 89.36 165.27 89.43 157.02 89.5 166.8 89.5 166.8 89.58 206.64 89.87 217.73 89.94 200.42 89.94 200.42 90.01 217.1 93.31 202.7 93.38 178.5 93.46 178.28 93.53 197.58 93.6 219.95 97.27 243.49 97.34 198.79 97.41 187.09 97.49 194.31 97.49 194.31 97.56 235.47 97.85 203.06 97.92 195.88 97.92 195.88 98 207.72 101.29 228.57 101.37 198.75 101.44 195.66 101.44 195.66 101.51 211.46 101.81 210.06 101.88 190.39 101.95 190.88 101.95 190.88 102.03 214.32 105.32 217.6 105.4 200.73 105.4 200.73 105.47 206.16 105.76 237.42 105.83 188.07 105.91 178.33 105.98 186.69 105.98 186.69 106.05 250.09 109.72 209.32 109.86 164.74 109.94 162.61 110.01 181.3 110.01 181.3 110.08 210.52 111.11 203.14 111.33 200.17 111.4 198.33 111.47 197.89 111.77 192.45 111.91 189.76 112.21 183.23 112.43 177.64 112.65 171.22 112.87 163.54 113.09 153.94 113.23 145.99 113.38 136 113.53 122.71 113.67 102.29 113.75 85.41 113.82 47.27 113.89 34.13 113.96 39.86 114.04 76.36 114.11 96.97 114.18 110 114.33 127.43 114.48 139.45 114.62 148.68 114.84 159.43 115.06 167.89 115.28 174.86 115.5 180.81 115.8 187.62 115.87 188.9 115.94 190.72 116.24 195.97 116.31 197.04 116.38 199 116.46 199.07 116.53 200.8 116.6 201.83 116.67 202.91 117.7 210.22 117.77 193.39 117.85 161.38 117.92 156.7 117.99 171.25 117.99 171.25 118.07 205.46 121.73 227.34 121.8 193.79 121.88 176.74 121.95 179.91 121.95 179.91 122.02 206.96 125.76 238.63 125.83 194.29 125.9 186.82 125.98 198.07 125.98 198.07 126.05 244.4 126.27 228.22 126.34 200.07 126.42 196.78 126.42 196.78 126.49 213.14 129.79 217.58 129.86 196.47 129.93 196.87 129.93 196.87 130 218.66 130.3 203.87 130.37 189.17 130.44 193.48 130.44 193.48 130.52 225.11 133.81 210.8 133.89 200.46 133.89 200.46 133.96 208.47 134.25 222.35 134.33 184.75 134.4 178.75 134.47 191.6 134.47 191.6 134.55 230.98 138.21 210.4 138.28 182.03 138.35 163.36 138.43 165.06 138.5 189.87 138.57 213.99 141.06 204.27 141.28 197.09 141.5 188.06 141.65 180.67 141.87 166.52 142.02 152.4 142.09 143.08 142.16 130.75 142.24 112.02 142.31 45.65 142.38 36.8 142.46 46.48 142.53 113.04 142.6 131.36 142.68 143.52 142.82 160.37 142.97 172.06 143.19 184.69 143.33 191.1 143.41 194.73 143.63 202.11 143.63 202.11 143.7 204.47 146.19 206.66 146.34 158.16 146.41 157.22 146.48 177.04 146.48 177.04 146.56 204.16 150.22 229.87 150.29 187.57 150.37 175.65 150.44 182.42 150.44 182.42 150.51 224.35 150.81 209.21 150.88 201.89 150.88 201.89 150.95 213.21 154.25 220.63 154.32 190.9 154.39 187.33 154.39 187.33 154.47 203.09 154.76 218.39 154.83 198.09 154.91 198.38 154.91 198.38 154.98 220.92 158.28 210.31 158.35 194.9 158.42 199.01 158.42 199.01 158.5 229.06 158.72 250.92 158.79 199.1 158.86 188.76 158.94 196.98 158.94 196.98 159.01 249.92 162.3 206.43 162.38 200.72 162.38 200.72 162.45 212.01 162.74 207.67 162.82 182.35 162.89 179.91 162.96 198.1 162.96 198.1 163.04 230.41 166.7 210.1 166.77 176.22 166.85 162.9 166.92 168.15 166.92 168.15 166.99 204.26 168.24 203.74 168.31 201.89 168.38 202.09 168.46 199.97 168.6 197.59 168.75 194.86 168.82 193.8 168.9 191.78 168.97 190.56 169.26 183.78 169.41 180 169.7 170.79 169.92 162.28 170.07 155.45 170.21 147.16 170.36 136.69 170.51 122.34 170.58 112.55 170.65 99.33 170.73 78.17 170.8 44.59 170.87 39.63 170.95 53.72 171.02 89.31 171.09 105.85 171.24 126.05 171.39 139.23 171.53 149.19 171.68 157.1 171.9 166.71 172.12 174.32 172.34 180.83 172.63 188.03 172.92 194.18 173.22 199.48 173.29 200.96 173.36 201.47 173.36 201.47 173.44 203.17 174.68 206.31 174.76 173.23 174.83 155.69 174.9 158.55 174.98 184.86 175.05 205.24 178.71 233.04 178.78 182.92 178.86 175.24 178.93 185.97 178.93 185.97 179 232.65 182.74 210.16 182.81 188.37 182.89 188.55 182.89 188.55 182.96 209.7 183.25 211.5 183.33 196.86 183.4 200.67 183.4 200.67 183.47 232.81 186.77 204.89 186.84 194.06 186.91 202.06 186.91 202.06 186.99 248.25 187.21 234.02 187.28 195.41 187.35 189.11 187.43 201.52 187.43 201.52 187.5 241.58 190.8 203.54 190.87 201.39 190.87 201.39 190.94 217.32 191.16 224.67 191.24 199.38 191.31 180.71 191.38 181.88 191.38 181.88 191.46 206.84 194.75 237.16 194.82 202.07 194.82 202.07 194.9 217.96 195.19 218.88 195.26 171.95 195.34 163.2 195.41 172.05 195.41 172.05 195.48 215.19 196.51 202.99 196.58 202.24 196.73 200.24 196.8 198.39 196.88 198.12 196.95 196.49 197.17 192.63 197.24 191.09 197.31 190.12 197.39 188.2 197.53 185.23 197.75 180.05 197.9 176.17 198.19 166.9 198.41 158.26 198.56 151.31 198.71 142.84 198.85 132.05 199 117.16 199.07 106.83 199.15 92.56 199.29 44.13 199.37 42.87 199.44 62.22 199.51 89.99 199.58 105.11 199.73 124.25 199.88 137 200.02 146.7 200.24 157.86 200.46 166.53 200.68 173.67 200.83 177.91 201.12 184.99 201.34 189.53 201.49 192.45 201.78 197.63 202.08 202.14 202.08 202.14 202.15 203.16 203.17 216.68 203.25 166.71 203.32 153.99 203.39 160.72 203.47 197.4 203.47 197.4 203.54 210.8 207.2 209.78 207.28 179.42 207.35 175.49 207.42 190.89 207.42 190.89 207.5 223.21 211.23 202.72 211.3 186.74 211.38 190.55 211.38 190.55 211.45 219.5 211.74 206.65 211.82 196.38 211.82 196.38 211.89 203.92 215.19 238.91 215.26 200.71 215.33 193.96 215.33 193.96 215.41 206.22 215.7 219.74 215.77 192.75 215.84 190.22 215.84 190.22 215.92 207.29 219.21 221.49 219.29 201.62 219.29 201.62 219.36 202.72 219.65 226.96 219.73 193.53 219.8 179.81 219.87 184.75 219.87 184.75 219.95 219.56 223.68 207.71 223.75 168.98 223.83 164.15 223.9 177.11 223.9 177.11 223.97 206.94 225.22 202.79 225.29 200.94 225.37 200.32 225.66 195.12 225.73 193.54 225.81 192.55 225.95 189.21 226.25 182.45 226.39 178.48 226.68 169.1 226.9 160.33 227.05 153.25 227.2 144.58 227.34 133.48 227.49 117.99 227.56 107.05 227.64 91.53 227.71 61.91 227.78 44.29 227.86 46.67 228 96.36 228.08 110.29 228.22 128.49 228.37 140.84 228.52 150.29 228.74 161.27 228.96 169.79 229.17 176.85 229.32 181.1 229.61 188.05 229.76 191.31 229.83 192.43 229.91 194.18 230.2 199.33 230.27 200.37 230.35 202 230.35 202 230.42 202.8 231.67 206.38 231.74 161.42 231.81 153.06 231.88 163.8 231.88 163.8 231.96 231.52 235.62 223.46 235.77 176.8 235.84 176.48 235.91 197.61 235.99 224.38 239.65 246.43 239.72 197.05 239.79 185.85 239.87 193.42 239.87 193.42 239.94 238.62 240.23 202.99 240.31 196.61 240.31 196.61 240.38 208.4 243.68 224.83 243.75 197.65 243.82 194.67 243.82 194.67 243.9 211.59 244.19 210.74 244.26 190.96 244.34 192.08 244.34 192.08 244.41 215.34 247.71 214.76 247.78 200.43 247.78 200.43 247.85 204.95 248.14 249.95 248.22 189.16 248.29 179.66 248.36 188.6 248.36 188.6 248.44 254.73 252.1 220.73 252.25 167.07 252.32 165.72 252.39 184.01 252.39 184.01 252.47 208.73 254.3 202.34 254.37 200.39 254.59 195.6 254.74 192.27 254.81 189.71 254.88 188.07 255.18 178.63 255.32 173.1 255.54 162.47 255.69 153.58 255.83 142.14 255.98 126.03 256.05 114.4 256.13 97.36 256.2 57.7 256.27 45.02 256.35 51.14 256.42 89.35 256.49 109.69 256.57 122.62 256.71 139.97 256.86 151.94 257.01 161.17 257.23 172.02 257.37 177.8 257.59 185.12 257.74 189.09 257.81 191.74 257.96 195.02 258.18 199.91 258.25 202.05 258.25 202.05 258.33 202.43 260.08 207.51 260.16 187.88 260.23 157.21 260.3 152.87 260.38 168 260.38 168 260.45 202.8 264.11 222.08 264.18 191.07 264.26 174.96 264.33 178.3 264.33 178.3 264.4 207.31 264.7 212.95 264.77 202.2 264.77 202.2 264.84 209.59 268.14 235.51 268.21 192.74 268.29 185.69 268.36 197.35 268.36 197.35 268.43 240.54 268.65 228.23 268.73 200.35 268.8 197.55 268.8 197.55 268.87 214.35 272.17 215.4 272.24 195.46 272.31 196.19 272.31 196.19 272.39 218.91 272.68 204.33 272.75 190 272.83 194.73 272.83 194.73 272.9 227.38 276.2 210 276.27 199.77 276.27 199.77 276.34 208.32 276.64 221.96 276.71 185.86 276.78 180.27 276.86 193.56 276.86 193.56 276.93 230.67 280.59 212.35 280.66 183.95 280.74 165.97 280.81 167.99 280.88 193.96 280.96 217.95 283.52 202.26 283.67 196.92 283.74 195.34 283.81 190.84 283.89 188.28 284.11 176.56 284.18 172.04 284.33 160.19 284.47 143.08 284.55 130.67 284.62 111.72 284.69 54.71 284.77 46.27 284.84 56.37 284.91 113.75 284.99 131.87 285.06 143.95 285.21 160.54 285.35 172.15 285.5 181.15 285.64 188.55 285.72 191.23 285.79 195.17 285.94 200 286.01 202.38 288.5 217.02 288.57 202.13 288.72 153.96 288.79 153.38 288.94 200.46 288.94 200.46 289.01 214.79 292.6 231.04 292.68 185.36 292.75 173.85 292.82 181.03 292.82 181.03 292.9 224.77 296.63 218 296.7 189.5 296.78 186.26 296.78 186.26 296.85 202.66 297.14 218.42 297.22 198.49 297.29 199.29 297.29 199.29 297.36 222.28 300.66 208.91 300.73 193.98 300.81 198.46 300.81 198.46 300.88 229.78 301.1 251.95 301.17 199.59 301.25 189.78 301.32 198.32 301.32 198.32 301.39 280.62 304.69 206.22 304.76 199.84 304.76 199.84 304.83 213.02 305.13 208.94 305.2 183.46 305.27 181.63 305.35 199.82 305.35 199.82 305.42 227.3 309.08 213.69 309.16 178.34 309.23 165.55 309.3 171.14 309.3 171.14 309.38 210.09 311.06 203.6 311.21 200.67 311.28 199.54 311.5 194.58 311.79 187.16 312.01 180.54 312.23 172.73 312.45 162.7 312.6 154.39 312.74 143.77 312.89 129.49 312.96 119.64 313.04 106.32 313.11 84.87 313.18 52.57 313.26 48 313.33 62.58 313.4 97.07 313.48 113.45 313.62 133.54 313.77 146.77 313.92 156.59 314.06 164.5 314.28 174.04 314.5 181.69 314.72 188.38 314.94 193.68 315.16 198.84 315.23 199.51 315.31 201.78 315.31 201.78 315.38 202.88 316.99 214.63 317.07 199.2 317.14 168.21 317.21 151.55 317.29 154.63 317.36 182.55 317.43 204.86 321.09 224.85 321.17 180.92 321.24 173.48 321.31 184.82 321.31 184.82 321.39 232.8 325.12 207.88 325.2 187.2 325.27 187.57 325.27 187.57 325.34 209.97 325.63 212.01 325.71 197.47 325.78 201.89 325.78 201.89 325.85 234.14 329.15 203.73 329.22 193.41 329.3 201.63 329.3 201.63 329.37 256.72 329.59 235.25 329.66 196.14 329.74 190.29 329.74 190.29 329.81 203.07 333.18 203.42 333.25 200.66 333.25 200.66 333.33 219.33 333.54 230.98 333.62 200.75 333.69 181.91 333.76 183.8 333.76 183.8 333.84 208.19 337.57 225.81 337.65 174.43 337.72 165.73 337.79 175.39 337.79 175.39 337.87 220.95 339.4 202.42 339.62 198.43 339.7 196.6 339.77 195.73 339.99 190.64 340.21 185.26 340.43 178.84 340.65 171.28 340.87 162 341.02 154.33 341.16 144.88 341.31 132.29 341.46 113.71 341.53 99.32 341.67 51.22 341.75 50.32 341.82 70.28 341.89 97.5 341.97 112.49 342.11 131.54 342.26 144.34 342.41 153.91 342.55 161.65 342.77 170.98 342.99 178.59 343.21 185.04 343.51 192.14 343.65 195.52 343.73 196.59 343.87 199.63 343.95 200.92 344.02 202.32 345.56 203.15 345.63 161.7 345.7 149.91 345.78 156.7 345.85 199.14 345.85 199.14 345.92 219.19 349.58 206.46 349.66 177.48 349.73 173.84 349.8 189.88 349.8 189.88 349.88 222.72 353.54 232.88 353.61 200.78 353.69 185.67 353.76 189.68 353.76 189.68 353.83 221.13 354.13 207.35 354.2 197.1 354.2 197.1 354.27 205.49 357.57 239.79 357.64 199.77 357.71 193.5 357.71 193.5 357.79 205.88 358.08 219.82 358.15 193.65 358.23 191.5 358.23 191.5 358.3 209.3 361.6 219.81 361.67 201.29 361.67 201.29 361.74 202.41 362.04 233.85 362.11 194.8 362.18 181.15 362.26 186.75 362.26 186.75 362.33 220.96 366.06 203.89 366.14 171.61 366.21 166.58 366.28 180.98 366.28 180.98 366.36 216.75 367.97 203.34 368.12 200.9 368.19 198.61 368.26 198.01 368.55 191.06 368.7 187.55 368.92 180.9 369.14 173.32 369.36 163.82 369.51 156 369.65 146.27 369.8 133.29 369.95 113.72 370.02 98.06 370.09 67.74 370.17 50.67 370.24 53.42 370.39 103.64 370.46 117.46 370.61 135.6 370.75 147.99 370.9 157.31 371.04 164.9 371.19 171.42 371.41 179.27 371.63 185.95 371.85 191.62 372.14 198.21 372.29 201.06 372.36 202.44 374.05 207.27 374.12 156.57 374.19 148.96 374.27 159.76 374.27 159.76 374.34 206.4 378 221.61 378.15 174.92 378.22 174.98 378.3 196.72 378.37 222.81 382.03 244.16 382.1 195.47 382.18 184.88 382.25 192.72 382.25 192.72 382.32 245.6 382.62 203.81 382.69 197.48 382.69 197.48 382.76 210.18 386.06 224.03 386.13 196.84 386.21 194.29 386.21 194.29 386.28 211.47 386.57 211.03 386.65 192 386.72 193.44 386.72 193.44 386.79 217.82 390.09 213.78 390.16 199.93 390.16 199.93 390.23 204.96 390.53 258.65 390.6 190.3 390.67 181.12 390.75 190.57 390.75 190.57 390.82 268.62 394.48 215.78 394.63 169.55 394.7 168.21 394.78 188.01 394.78 188.01 394.85 218.32 396.97 203.2 397.05 201.44 397.12 199.06 397.19 198.2 397.27 195.38 397.41 191.12 397.63 183.72 397.78 177.31 398 165.81 398.14 155.71 398.29 142.37 398.44 121.72 398.51 104.5 398.58 63.1 398.66 50.88 398.73 57.39 398.8 97.52 398.88 117.6 398.95 130.45 399.1 147.78 399.24 159.78 399.39 168.85 399.54 176.32 399.68 182.98 399.9 190.44 400.12 197.39 400.2 198.56 400.27 200.99 400.27 200.99 400.34 202.72 402.47 205.74 402.54 183.01 402.61 152.52 402.69 148.68 402.76 164.11 402.83 196.36 402.83 196.36 402.91 211.13 406.49 221.25 406.57 188.83 406.64 173.14 406.71 176.9 406.71 176.9 406.79 206.7 410.52 232.63 410.6 191.38 410.67 184.77 410.74 196.81 410.74 196.81 410.82 237.31 411.04 227.59 411.11 201.26 411.18 198.56 411.18 198.56 411.25 215.98 414.55 214.43 414.62 194.69 414.7 195.77 414.7 195.77 414.77 219.3 415.06 204.86 415.14 191.07 415.21 196.21 415.21 196.21 415.28 230.31 418.58 208.8 418.65 199.36 418.65 199.36 418.73 208.23 419.02 221.42 419.09 186.97 419.17 181.77 419.24 195.53 419.24 195.53 419.31 231.64 422.97 216.32 423.05 185.85 423.12 168.2 423.19 170.71 423.27 196.79 423.34 219.73 425.83 204.52 426.05 197.45 426.12 193.35 426.2 192.06 426.42 180.69 426.64 166.63 426.78 152.24 426.86 142.83 426.93 130.33 427 111.16 427.08 59.66 427.15 51.62 427.22 62.16 427.29 114.21 427.37 132.14 427.51 153.27 427.66 167.02 427.81 176.96 427.95 185.01 428.1 192.35 428.17 193.94 428.25 197.62 428.32 200.08 428.39 202.45 430.88 211.2 430.96 196.54 431.1 149.32 431.18 149.09 431.32 196.72 431.32 196.72 431.4 211.64 434.99 230.35 435.06 183.14 435.13 172.12 435.21 179.68 435.21 179.68 435.28 227.01 439.01 215.76 439.09 188.23 439.16 185.37 439.23 202.22 439.23 202.22 439.31 232.28 439.53 218.84 439.6 199.28 439.67 200.37 439.67 200.37 439.75 223.77 443.04 207.58 443.12 193.28 443.19 198 443.19 198 443.26 231.3 443.48 274.03 443.55 200.29 443.63 190.77 443.7 199.9 443.7 199.9 443.77 269.13 447.07 204.76 447.14 199.57 447.14 199.57 447.22 212.19 447.51 208.84 447.58 184.62 447.66 183.05 447.73 202.14 447.73 202.14 447.8 230.97 451.46 222.65 451.54 180.47 451.61 167.64 451.68 174 451.68 174 451.76 209.87 453.66 203.05 453.74 201.82 454.03 194.92 454.25 189.01 454.47 182.02 454.69 173.59 454.91 162.68 455.05 153.26 455.2 141.15 455.35 123.41 455.42 109.99 455.49 88.24 455.57 57.13 455.64 52.93 455.71 68.01 455.79 101.5 455.86 117.73 456.01 137.7 456.15 150.79 456.3 160.69 456.45 168.58 456.67 178.03 456.88 185.75 457.03 190.27 457.1 191.95 457.25 195.99 457.47 201.04 457.54 202.19 457.54 202.19 457.62 204.97 459.38 209.62 459.45 194.46 459.52 162.91 459.59 146.83 459.67 150.26 459.81 201.79 459.81 201.79 459.89 215.32 463.48 222.45 463.55 178.71 463.62 171.8 463.7 183.43 463.7 183.43 463.77 225.92 467.5 206.1 467.58 185.87 467.65 186.68 467.65 186.68 467.72 209.5 468.02 212.49 468.09 198.15 468.09 198.15 468.16 202.87 471.53 202.36 471.61 192.49 471.68 201.14 471.68 201.14 471.75 263.39 471.97 231.96 472.05 196.78 472.12 191.18 472.12 191.18 472.19 204.6 475.49 228.36 475.56 201.88 475.63 200.34 475.63 200.34 475.71 217.58 475.93 228.16 476 200.8 476.07 183.09 476.15 185.1 476.15 185.1 476.22 211.41 479.96 228.24 480.03 176.23 480.1 167.95 480.18 178.01 480.18 178.01 480.25 223.26 482.01 202.8 482.08 202.12 482.15 199.6 482.23 198.53 482.52 191.72 482.59 189.44 482.67 187.9 482.96 178.51 483.18 169.86 483.33 162.88 483.47 154.37 483.62 143.56 483.76 128.51 483.84 118.06 483.91 103.55 484.06 55.73 484.13 55.2 484.28 102.49 484.35 117.34 484.5 136.28 484.64 148.91 484.79 158.6 485.01 169.73 485.23 178.36 485.45 185.47 485.6 189.73 485.82 195.11 485.96 198.42 486.04 199.72 486.11 201.53 486.18 202.91 487.94 203.42 488.01 156.48 488.09 145.02 488.16 152.29 488.23 195.98 488.23 195.98 488.31 213.51 491.97 203.76 492.04 175.31 492.11 172.15 492.19 188.54 492.19 188.54 492.26 219.15 495.92 233.82 496 199.1 496.07 184.31 496.14 188.8 496.14 188.8 496.22 220.46 496.51 207.41 496.58 197.88 496.58 197.88 496.66 206.35 499.95 234.97 500.02 198.35 500.1 192.45 500.1 192.45 500.17 205.39 500.46 219.32 500.54 194.18 500.61 192.35 500.61 192.35 500.68 210.76 503.98 218.53 504.05 200.04 504.13 201.82 504.13 201.82 504.2 226.36 504.42 232.42 504.49 195.21 504.57 182.29 504.64 188.11 504.64 188.11 504.71 225.68 508.45 207.35 508.52 173.25 508.59 169.02 508.67 183.2 508.67 183.2 508.74 212.67 510.64 202.26 510.79 199.29 511.01 194.26 511.08 191.65 511.16 190.19 511.45 180.73 511.6 175.34 511.82 164.81 511.96 156.09 512.11 144.89 512.26 129.33 512.33 118.25 512.4 102.45 512.48 71.38 512.55 54.85 512.62 57.98 512.77 108.78 512.84 122.5 512.99 140.51 513.13 152.77 513.28 162.19 513.5 173.2 513.65 179.09 513.94 188.71 514.01 190.47 514.09 193.2 514.16 194.47 514.38 199.83 514.45 201.44 514.53 203.49 516.36 212.36 516.43 195.15 516.5 151.28 516.58 143.93 516.65 155.32 516.65 155.32 516.72 202.26 520.39 219.67 520.53 172.8 520.61 173.24 520.68 195.65 520.75 221.38 524.41 249.81 524.49 193.79 524.56 183.52 524.63 191.83 524.63 191.83 524.71 248.64 525 203.88 525.07 198.17 525.07 198.17 525.15 211.1 528.44 221.42 528.52 195.55 528.59 193.37 528.59 193.37 528.66 211.21 528.96 211.14 529.03 192.62 529.1 194.44 529.1 194.44 529.17 219.46 532.47 212.51 532.54 199.1 532.54 199.1 532.62 204.41 532.91 253.15 532.98 191.13 533.06 182.38 533.13 192.23 533.13 192.23 533.2 256.63 536.87 219.01 537.01 171.52 537.08 170.67 537.16 190.8 537.23 216.96 539.58 204.13 539.65 201.24 539.79 197.02 540.01 189.35 540.23 179.66 540.38 171.65 540.53 161.81 540.67 148.17 540.82 127.38 540.89 109.99 540.97 66.57 541.04 54.8 541.11 61.7 541.19 104.03 541.26 123.87 541.33 136.62 541.48 153.92 541.63 165.91 541.85 178.77 542.07 188.94 542.29 196.48 542.43 201.02 542.5 202.93 544.78 213.41 544.85 198.39 545 146.93 545.07 143.43 545.14 159.42 545.21 191.15 545.21 191.15 545.29 206.72 548.88 219.4 548.95 186.26 549.02 171.13 549.1 175.25 549.1 175.25 549.17 206.21 552.91 229.09 552.98 189.82 553.05 183.6 553.13 196.1 553.13 196.1 553.2 235.4 553.42 226.43 553.49 201.49 553.56 199.34 553.56 199.34 553.64 217.26 556.93 212.67 557.01 193.56 557.08 195.01 557.08 195.01 557.15 219.37 557.45 205.13 557.52 191.82 557.59 197.35 557.59 197.35 557.67 233.09 560.96 207.62 561.04 198.56 561.04 198.56 561.11 207.74 561.4 221.09 561.47 187.9 561.55 183.05 561.62 197.32 561.62 197.32 561.69 232.85 565.36 217.54 565.43 187.24 565.5 170.26 565.58 173.07 565.65 200.4 565.72 223.72 568.87 204.72 568.95 197.8 569.02 198.93 569.09 186.79 569.17 180.71 569.24 171.22 569.31 158.63 569.38 139.23 569.46 91.67 569.53 84.04 569.6 95 569.68 143.3 569.75 161.03 569.82 172.94 569.97 190.61 570.04 193.03 570.12 202.15 570.12 202.15 570.19 205.81 573.19 211.83 573.27 201.57 573.34 186.89 573.49 139.45 573.56 139.6 573.71 187.18 573.78 201.78 573.78 201.78 573.85 212.09 577.37 231.93 577.44 180.7 577.51 170.1 577.59 178.07 577.59 178.07 577.66 229.03 581.4 213.32 581.47 186.73 581.54 184.23 581.62 201.52 581.62 201.52 581.69 231 581.91 218.78 581.98 199.8 582.06 201.18 582.06 201.18 582.13 225.69 585.42 206.08 585.5 192.2 585.57 197.42 585.57 197.42 585.64 231.78 585.86 281.07 585.94 200.68 586.01 191.64 586.08 201.09 586.08 201.09 586.16 269.92 589.45 203.92 589.53 198.87 589.53 198.87 589.6 212.45 589.89 209.36 589.97 185.67 590.04 184.5 590.04 184.5 590.11 204.06 593.85 223.39 593.92 181.97 593.99 169.83 594.07 176.39 594.07 176.39 594.14 216.86 597.51 207.82 597.66 196.21 597.73 186.3 597.8 172.77 597.88 150.72 597.95 120.71 598.02 116.9 598.1 132.48 598.17 165.05 598.24 181.12 598.32 192.24 598.39 200.03 598.39 200.03 598.46 220.71 601.54 220.71 601.61 200.03 601.68 192.24 601.76 181.12 601.83 165.05 601.9 132.48 601.98 116.9 602.05 120.71 602.12 150.72 602.2 172.77 602.2 172.77 602.27 186.3"/></g></g></g><g transform="translate(42.7 4)"><g class="svg-plot-group"><line x1="0" x2="-4" y1="75" y2="75" class="svg-plot-tick"/><line x1="0" x2="-4" y1="143.182" y2="143.182" class="svg-plot-tick"/><line x1="0" x2="-4" y1="6.81818" y2="6.81818" class="svg-plot-tick"/><text class="svg-plot-value" style="text-anchor:end" x="-9" y="5.81818">1</text><text class="svg-plot-value" style="text-anchor:end" x="-9" y="142.182">-1</text><text class="svg-plot-value" style="text-anchor:end" x="-9" y="74">0</text></g></g><g transform="translate(42.7 173)"><g class="svg-plot-group"><line x1="0" x2="0" y1="200" y2="204" class="svg-plot-tick"/><line x1="600" x2="600" y1="200" y2="204" class="svg-plot-tick"/><line x1="0" x2="-4" y1="0" y2="0" class="svg-plot-tick"/><line x1="0" x2="-4" y1="46.1538" y2="46.1538" class="svg-plot-tick"/><line x1="0" x2="-4" y1="92.3077" y2="92.3077" class="svg-plot-tick"/><line x1="0" x2="-4" y1="138.462" y2="138.462" class="svg-plot-tick"/><line x1="0" x2="-4" y1="184.615" y2="184.615" class="svg-plot-tick"/><text class="svg-plot-label svg-plot-t" x="0" y="0" transform="rotate(-90) translate(-99 -37.7)">dB</text><text class="svg-plot-value" style="text-anchor:end" x="-9" y="183.615">-120</text><text class="svg-plot-value" style="text-anchor:end" x="-9" y="137.462">-90</text><text class="svg-plot-value" style="text-anchor:end" x="-9" y="91.3077">-60</text><text class="svg-plot-value" style="text-anchor:end" x="-9" y="45.1538">-30</text><text class="svg-plot-value" style="text-anchor:end" x="-9" y="-1">0</text><text class="svg-plot-label svg-plot-t" x="300" y="229">frequency</text><text class="svg-plot-value" x="600" y="213">Nyquist</text><text class="svg-plot-value" x="0" y="213">0</text></g></g><defs><g id="svg-plot-marker0" class="svg-plot-marker"><circle cx="0" cy="0" r="1" stroke="none"/></g><g id="svg-plot-marker1" class="svg-plot-marker"><path d="M0 0.9 -0.9 0 0 -0.9 0.9 0Z" fill="#FFFA" stroke-linejoin="miter" stroke-width="0.5"/></g><g id="svg-plot-marker2" class="svg-plot-marker"><path fill="none" d="M0 -1.2 0 1.2 M -1.2 0 1.2 0" stroke-width="0.6"/></g><g id="svg-plot-marker3" class="svg-plot-marker"><circle cx="0" cy="0" fill="#FFFA" r="0.82" stroke-width="0.55"/></g><g id="svg-plot-marker4" class="svg-plot-marker"><path stroke="none" d="M0 -1.25 1.25 0.9 -1.25 0.9Z"/></g><mask id="svg-plot-hatch1"><rect x="-935" y="-935" width="1870" height="1870" fill="url(#svg-plot-hatch1-pattern)" style="transform:rotate(-50deg)"/></mask><pattern patternUnits="userSpaceOnUse" id="svg-plot-hatch1-pattern" class="svg-plot-hatch" x="0" y="0" width="10" height="3"><line x1="-1" x2="11" y1="1.5" y2="1.5" stroke="#FFF" fill="none"/><rect x="-1" y="-1" width="12" height="12" fill="#FFF2" stroke="none"/></pattern><mask id="svg-plot-hatch2"><rect x="-935" y="-935" width="1870" height="1870" fill="url(#svg-plot-hatch2-pattern)" style="transform:rotate(30deg)"/></mask><pattern patternUnits="userSpaceOnUse" id="svg-plot-hatch2-pattern" class="svg-plot-hatch" x="0" y="0" width="10" height="2.4"><line x1="-1" x2="11" y1="1.2" y2="1.2" stroke="#FFF" fill="none"/><rect x="-1" y="-1" width="12" height="12" fill="#FFF2" stroke="none"/></pattern><mask id="svg-plot-hatch3"><rect x="-935" y="-935" width="1870" height="1870" fill="url(#svg-plot-hatch3-pattern)" style="transform:rotate(8deg)"/><rect x="-935" y="-935" width="1870" height="1870" fill="url(#svg-plot-hatch3-pattern)" style="transform:rotate(93deg)"/></mask><pattern patternUnits="userSpaceOnUse" id="svg-plot-hatch3-pattern" class="svg-plot-hatch" x="0" y="0" width="10" height="3"><line x1="-1" x2="11" y1="1.5" y2="1.5" stroke="#FFF" fill="none"/><rect x="-1" y="-1" width="12" height="12" fill="#FFF2" stroke="none"/></pattern></defs><style>.svg-plot{stroke-linecap:butt;stroke-linejoin:round;}.svg-plot-bg{fill:#FFF;stroke:none;}.svg-plot-axis{stroke:none;fill:#FFFFFFD9;}.svg-plot-legend{stroke:none;fill:#FFFFFFE4;}.svg-plot-line{stroke:blue;fill:none;stroke-width:1.5px;stroke-linejoin:round;}.svg-plot-fill{stroke:none;opacity:0.35;}.svg-plot-major{stroke:#000;stroke-width:1px;stroke-linecap:square;fill:none;}.svg-plot-minor{stroke:#0000004D;stroke-width:0.5px;stroke-dasharray:0.5 1.5;stroke-linecap:round;fill:none;}.svg-plot-tick{stroke:#000;fill:none;stroke-width:1px;stroke-linecap:butt;}.svg-plot-value,.svg-plot-label,.svg-plot-title{font-family:Arial,sans-serif;fill:#000;stroke:#FFFFFF48;stroke-width:2.5px;paint-order:stroke fill;text-anchor:middle;dominant-baseline:central;alignment-baseline:baseline;}.svg-plot-label{font-size:12px;}.svg-plot-value{font-size:10px;}.svg-plot-title{font-size:13px;}.svg-plot-hatch{stroke:#FFF;stroke-width:1px;}.svg-plot-marker{transform:scale(3.25);}.svg-plot-s{stroke:#000;}.svg-plot-f,.svg-plot-t{fill:#000;}.svg-plot-s0{stroke:#007AB0}.svg-plot-f0,.svg-plot-t0{fill:#007AB0}.svg-plot-s1{stroke:#BB102B}.svg-plot-f1,.svg-plot-t1{fill:#BB102B}.svg-plot-s2{stroke:#44A730}.svg-plot-f2,.svg-plot-t2{fill:#44A730}.svg-plot-s3{stroke:#87694F}.svg-plot-f3,.svg-plot-t3{fill:#87694F}.svg-plot-s4{stroke:#EDA720}.svg-plot-f4,.svg-plot-t4{fill:#EDA720}.svg-plot-s5{stroke:#A64D99}.svg-plot-f5,.svg-plot-t5{fill:#A64D99}.svg-plot-d0{stroke-width:1.35px}.svg-plot-d1{stroke-dasharray:1.8 1.8}.svg-plot-d2{stroke-dasharray:4.2 2.4}.svg-plot-d3{stroke-dasharray:7.5 6}.svg-plot-d4{stroke-dasharray:6 1.5 1.5 1.5 1.5 1.5}.svg-plot-d5{stroke-dasharray:15 4.5}.svg-plot-d6{stroke-dasharray:6 3 1.5 3}.svg-plot-h0{opacity:0.175}.svg-plot-h1{mask:url(#svg-plot-hatch1)}.svg-plot-h2{mask:url(#svg-plot-hatch2)}.svg-plot-h3{mask:url(#svg-plot-hatch3)}#svg-plot-hatch2-pattern{stroke-width:0.9px}#svg-plot-hatch3-pattern{stroke-width:0.7px}</style><style>@import"/style/svg-plot/style.css";svg{font-family:"Transport New",Arial,sans-serif;font-weight:300;}.svg-plot-label,.svg-plot-value{font-family:inherit;}.svg-plot-title{font-size:14px;font-family:"PT Sans";opacity:0.65;}.svg-plot-fill:hover{opacity:55%;}.svg-plot-h0{opacity:15%;}.svg-plot-fill.svg-plot-h0:hover{opacity:20%;}.svg-plot-fill.svg-plot-f0{fill:#005AB0;}text.svg-plot-f0{fill:#006AA0;}.svg-plot-fill.svg-plot-f4{fill:#EDB410;}</style><script href="/style/svg-plot/style.js"/></svg> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef SIGNALSMITH_DSP_LINEAR_SIMPLEFFT_H | |
#define SIGNALSMITH_DSP_LINEAR_SIMPLEFFT_H | |
#ifndef M_PI | |
#define M_PI 3.14159265358979323846 | |
#endif | |
#include <complex> | |
#include <vector> | |
namespace signalsmith { namespace linear { | |
/// A self-contained, reasonably fast power-of-2 FFT template | |
template<typename Sample> | |
struct SimpleFFT { | |
using Complex = std::complex<Sample>; | |
SimpleFFT(int maxSize=0) { | |
resize(maxSize); | |
} | |
void resize(int maxSize) { | |
twiddles.resize(maxSize/2); | |
for (int i = 0; i < maxSize/2; ++i) { | |
double twiddlePhase = -2*M_PI*i/maxSize; | |
twiddles[i] = { | |
Sample(std::cos(twiddlePhase)), | |
Sample(std::sin(twiddlePhase)) | |
}; | |
} | |
working.resize(maxSize); | |
} | |
void fft(int size, const Complex *time, Complex *freq) { | |
if (size <= 1) { | |
*freq = *time; | |
return; | |
} | |
fftPass<false>(size, 1, time, freq, working.data()); | |
} | |
void ifft(int size, const Complex *freq, Complex *time) { | |
if (size <= 1) { | |
*time = *freq; | |
return; | |
} | |
fftPass<true>(size, 1, freq, time, working.data()); | |
} | |
private: | |
std::vector<Complex> twiddles; | |
std::vector<Complex> working; | |
// Calculate a [size]-point FFT, where each element is a block of [stride] values | |
template<bool inverse> | |
void fftPass(int size, int stride, const Complex *input, Complex *output, Complex *working) const { | |
if (size > 2) { | |
// Calculate the two half-size FFTs (odd and even) by doubling the stride | |
fftPass<inverse>(size/2, stride*2, input, working, output); | |
combine2<inverse>(size, stride, working, output); | |
} else { | |
// The input can already be considered a 1-point FFT | |
combine2<inverse>(size, stride, input, output); | |
} | |
} | |
// Combine interleaved even/odd results into a single spectrum | |
template<bool inverse> | |
void combine2(int size, int stride, const Complex *input, Complex *output) const { | |
auto twiddleStep = twiddles.size()*2/size; | |
for (int i = 0; i < size/2; ++i) { | |
Complex twiddle = twiddles[i*twiddleStep]; | |
const Complex *inputA = input + 2*i*stride; | |
const Complex *inputB = input + (2*i + 1)*stride; | |
Complex *outputA = output + i*stride; | |
Complex *outputB = output + (i + size/2)*stride; | |
for (int s = 0; s < stride; ++s) { | |
Complex a = inputA[s]; | |
Complex b = inputB[s]*(inverse ? std::conj(twiddle) : twiddle); | |
outputA[s] = a + b; | |
outputB[s] = a - b; | |
} | |
} | |
} | |
}; | |
}} // namespace | |
#endif // include guard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment