Each project below is tailored to a specific algorithm and scientific question from Chapter 17, with concrete inputs, verifiable numerical outputs, boundary cases, and links to the related lab and pioneer.
Project 1 of 3 · v1-c17-p01Applied · ~30 min
Fourier Frequency Decomposition of Mixed Waves
Lab activity: 1. Look inside a mixed sound · Related code: block-01.js, block-04.js · Pioneer: View profile
Real-World Problem: A microphone records a single combined air-pressure curve even when an entire orchestra plays simultaneously.
Scientific Question: How does the Discrete Fourier Transform (DFT) recover the exact frequencies hidden inside a summed waveform?
Objective: Synthesize a sum of two sine waves (e.g., 440 Hz + 660 Hz), compute DFT magnitudes, and identify the exact spectral peaks.
Hypothesis to Test: Correlating a mixed signal against reference sine/cosine waves yields strong peaks ONLY at the constituent frequencies.
Step-by-Step Implementation
Generate N evenly spaced time samples of two summed sine waves.
Compute real and imaginary DFT components for frequency bins k = 0 .. N/2.
Compute magnitude sqrt(re^2 + im^2) / (N/2) and locate the top two peaks.
Reduce f_s below 2 × 880 Hz (e.g., 1200 Hz) to observe aliasing fold 880 Hz down to 320 Hz!
Concrete Input: N = 256 samples at f_s = 4096 Hz of sin(2π·440t) + 0.5·sin(2π·880t).
Expected Output: DFT peaks cleanly at bin ~27.5 (440 Hz, amp 1.0) and bin ~55 (880 Hz, amp 0.5); all other bins near 0.
Test Cases: f_s=4096, f=440 -> peak at 440 Hz; f_s=1200, f=880 -> aliased peak at 320 Hz.
Boundary Condition: Frequencies not aligned with integer bin k*(f_s/N) exhibit spectral leakage unless windowed.
Common Mistake to Avoid: Forgetting that DFT output is symmetric above N/2 (the Nyquist frequency f_s/2).
Interpreting Results: Joseph Fourier's decomposition turns complex time waveforms into readable frequency recipes.
Show Hint, Extension Challenge & Reflection
Hint: Review the worked example and equation in Chapter 17 before testing the boundary case: Frequencies not aligned with integer bin k*(f_s/N) exhibit spectral leakage unless windowed.
Extension Challenge: Apply a Hann window before the DFT and observe how spectral leakage around non-integer bins shrinks.
Reflection Question: Why does CD audio sample at 44,100 Hz instead of exactly 40,000 Hz?
Test Cases: Clean query -> 100% match; Moderate noise -> true track still #1; Silent clip -> no match.
Boundary Condition: Very heavy noise that drowns out spectral peaks causes missed matches.
Common Mistake to Avoid: Matching raw time-domain amplitude samples directly (a 1-millisecond shift destroys raw correlation).
Interpreting Results: Constellation peak-pair hashing makes acoustic search both shift-invariant and noise-tolerant.
Show Hint, Extension Challenge & Reflection
Hint: Review the worked example and equation in Chapter 17 before testing the boundary case: Very heavy noise that drowns out spectral peaks causes missed matches.
Extension Challenge: Shift the query clip by +2 time frames and verify the matcher still identifies the song.
Reflection Question: Why does fingerprinting store compact spectral landmarks instead of uploading full audio recordings?
Test Cases: phi = Math.PI, A = 1 -> RMS < 1e-12; phi = 0, A = 1 -> RMS doubled.
Boundary Condition: At high frequencies (shorter wavelengths), tiny microsecond latency creates huge phase errors.
Common Mistake to Avoid: Thinking noise-canceling headphones "absorb" sound rather than adding an inverted wave.
Interpreting Results: Wave superposition explains both constructive amplification and destructive noise cancellation.
Show Hint, Extension Challenge & Reflection
Hint: Review the worked example and equation in Chapter 17 before testing the boundary case: At high frequencies (shorter wavelengths), tiny microsecond latency creates huge phase errors.
Extension Challenge: Add a 1 ms processing delay and calculate the highest frequency that still achieves >50% cancellation.
Reflection Question: Why do modern headphones combine passive foam (for high frequencies) with active cancellation (for low hum)?