Skip to main content
100%

FFT of sine waves

✓ Published2🌍 Public
DDonald Bagwell
Last edited Jul 1, 2024
Created on Jul 1, 2024

This example visualizes the discrete Fourier transform (FFT) of combined sine waves, showing the magnitude spectrum of three superimposed signals at frequencies 5, 8, and 15 Hz sampled at 120 Hz. Three sine waves are generated with a custom `sineGenerator` function, summed, and processed through a radix-4 FFT implementation. The resulting magnitude values are plotted as a line chart using D3.js, with scales and axes handled via `scaleLinear` and the `@drbagwell/responsive-viz-axes` library, alongside a custom `viz` function that renders the plot within an SVG container.

AI-generated description

Overview Time to dabble with the infamous FFT in javascript. Starting with a simple script to generate sine waves for testing.

export const sineGenerator = (freq, dInSeconds, sRate) => { // Parameters for the sine wave const frequency = freq; const durationInSeconds = dInSeconds; const sampleRate = sRate;

Discrete Fourier Transform - Simple Step by Step https://www.youtube.com/watch?v=mkGsMWi_j4Q

Understanding the Discrete Fourier Transform and the FFT https://www.youtube.com/watch?v=QmgJmh2I3Fw&t=3s

MIT Licensed

Similar vizzes