# MATH310S26 Day 20 - Spectrograms and Signal Processing **Date:** March 4, 2026 **Topics:** Spectrograms, Sound Analysis, RC Filtering Introduction ## Administrative Notes - Presentation today on whale songs and targeted movement by senior students - Low-stakes feedback via form with PDF attachment - Next work day Monday (March 9) - Narrative project outlines due Friday-Monday ## Recall: Fourier Transform Pair The fundamental relationship: $\hat{F}(\omega) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} f(t) e^{-i\omega t} dt$ $f(t) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} \hat{F}(\omega) e^{i\omega t} d\omega$ ### Physical Interpretation - **For each ω**: Think of a [simple harmonic oscillator](https://en.wikipedia.org/wiki/Harmonic_oscillator) - **Energy**: $E \propto |\hat{F}(\omega)|^2 = \hat{F}(\omega) \cdot \hat{F}^*(\omega)$ - **Total energy**: $\int_{-\infty}^{\infty} |\hat{F}(\omega)|^2 d\omega = ||\hat{F}||^2_{\mathbb{R}}$ (norm in [Hilbert space](https://en.wikipedia.org/wiki/Hilbert_space)) ## Example: Rectangle Function Transform Recall from [[MATH310S26-Day15-Notes]]: - Rectangle function → $\hat{F}(\omega) = \frac{1}{\sqrt{2\pi}} \cdot \frac{\sin(\omega L)}{\omega L}$ ([sinc function](https://en.wikipedia.org/wiki/Sinc_function)) ### Squaring the Transform When we look at $|\hat{F}(\omega)|^2$: 1. Peak at ω = 0 gets amplified (2 → 4) 2. Values between 0 and 1 get smaller 3. Negative regions become positive 4. Overall decay is faster **Physical analogy**: Looking at intensity pattern from above - Bright center (maximum at ω = 0) - Alternating bright/dark regions (nodes) - Decreasing brightness with distance This is exactly what we observe in [diffraction patterns](https://en.wikipedia.org/wiki/Diffraction)! ## Sound Analysis and Spectrograms ### Pure Tones vs. Complex Waveforms **Pure sine wave**: - Single spike in frequency domain - Sounds "artificial" or "weird" - Electronically generated **Square wave**: - Fundamental frequency plus harmonics - Significant energy in harmonics → harsh sound - Used in 8-bit video game music **Triangle wave**: - Fundamental plus harmonics - Rapid decay in harmonic amplitudes → softer sound - Less harsh than square wave ### Spectrograms: Time-Frequency Analysis A [spectrogram](https://en.wikipedia.org/wiki/Spectrogram) shows frequency content over time: - **x-axis**: Time - **y-axis**: Frequency - **Color/intensity**: Amplitude (energy) This is computed using the [Short-Time Fourier Transform (STFT)](https://en.wikipedia.org/wiki/Short-time_Fourier_transform): 1. Divide signal into time windows 2. Compute Fourier transform of each window 3. Display as 2D plot or 3D surface ### Applications **Shazam** (music recognition): 1. Records audio snippet 2. Computes spectrogram 3. Identifies peaks (fingerprint) 4. Database lookup for matching patterns ## Human Voice Examples ### Overtone Singing [Polyphonic overtone singing](https://en.wikipedia.org/wiki/Overtone_singing): One person produces two distinct pitches simultaneously - Fundamental tone (constant) - Overtone (variable) - Visible as separate frequency bands in spectrogram ### Voice Techniques Observed 1. **Deep bass**: Fundamental and harmonics all descending 2. **Yodeling**: Rapid frequency jumps visible as discontinuous bands 3. **Controlled overtones**: Steady fundamental with moving harmonic emphasis ## Mathematical Tools: Fourier Transform Properties ### Transform of Derivatives - Full Derivation We want to find $\mathcal{F}\{f'(t)\}$. Starting with integration by parts: $\mathcal{F}\{f'(t)\} = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} f'(t) e^{-i\omega t} dt$ Let $u = e^{-i\omega t}$ and $dv = f'(t)dt$ Then $du = -i\omega e^{-i\omega t}dt$ and $v = f(t)$ By integration by parts: $= \frac{1}{\sqrt{2\pi}} \left[ f(t)e^{-i\omega t} \Big|_{-\infty}^{\infty} - \int_{-\infty}^{\infty} f(t)(-i\omega e^{-i\omega t}) dt \right]$ Assuming $f(t) \to 0$ as $t \to \pm\infty$: $= \frac{1}{\sqrt{2\pi}} \left[ 0 + i\omega \int_{-\infty}^{\infty} f(t)e^{-i\omega t} dt \right]$ $= i\omega \cdot \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} f(t)e^{-i\omega t} dt$ $\boxed{\mathcal{F}\{f'(t)\} = i\omega \hat{f}(\omega)}$ This converts differentiation in time domain to multiplication by $i\omega$ in frequency domain. ### Transform of Step Function with Exponential Decay - Full Derivation Consider the signal $u(t-a)e^{-t/\tau}$ where $u(t-a)$ is the [Heaviside step function](https://en.wikipedia.org/wiki/Heaviside_step_function): $\mathcal{F}\{u(t-a)e^{-t/\tau}\} = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} u(t-a)e^{-t/\tau} e^{-i\omega t} dt$ Since $u(t-a) = 0$ for $t < a$ and $u(t-a) = 1$ for $t \geq a$: $= \frac{1}{\sqrt{2\pi}} \int_a^{\infty} e^{-t/\tau} e^{-i\omega t} dt$ $= \frac{1}{\sqrt{2\pi}} \int_a^{\infty} e^{-t(\frac{1}{\tau} + i\omega)} dt$ Let $s = \frac{1}{\tau} + i\omega$, then: $= \frac{1}{\sqrt{2\pi}} \int_a^{\infty} e^{-st} dt$ $= \frac{1}{\sqrt{2\pi}} \left[ -\frac{1}{s}e^{-st} \right]_a^{\infty}$ $= \frac{1}{\sqrt{2\pi}} \left[ 0 - \left(-\frac{1}{s}e^{-sa}\right) \right]$ $= \frac{1}{\sqrt{2\pi}} \cdot \frac{e^{-sa}}{s}$ Substituting back $s = \frac{1}{\tau} + i\omega$: $\boxed{\mathcal{F}\{u(t-a)e^{-t/\tau}\} = \frac{1}{\sqrt{2\pi}} \cdot \frac{e^{-a(\frac{1}{\tau} + i\omega)}}{\frac{1}{\tau} + i\omega}}$ ## Introduction to Convolution ### Convolution Definition and Derivation The [convolution](https://en.wikipedia.org/wiki/Convolution) of two functions $f$ and $g$ is defined as: $(f * g)(t) = \int_{-\infty}^{\infty} f(t-p)g(p) dp$ To find its Fourier transform, we start with: $\mathcal{F}\{f * g\} = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} \left( \int_{-\infty}^{\infty} f(t-p)g(p) dp \right) e^{-i\omega t} dt$ Changing the order of integration: $= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} g(p) \left( \int_{-\infty}^{\infty} f(t-p) e^{-i\omega t} dt \right) dp$ Let $u = t - p$, so $t = u + p$ and $dt = du$: $= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} g(p) \left( \int_{-\infty}^{\infty} f(u) e^{-i\omega(u+p)} du \right) dp$ $= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} g(p) e^{-i\omega p} \left( \int_{-\infty}^{\infty} f(u) e^{-i\omega u} du \right) dp$ The inner integral is $\sqrt{2\pi} \hat{f}(\omega)$: $= \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} g(p) e^{-i\omega p} \cdot \sqrt{2\pi} \hat{f}(\omega) dp$ $= \hat{f}(\omega) \int_{-\infty}^{\infty} g(p) e^{-i\omega p} dp$ $= \hat{f}(\omega) \cdot \sqrt{2\pi} \hat{g}(\omega)$ $\boxed{\mathcal{F}\{f * g\} = \sqrt{2\pi} \cdot \hat{f}(\omega) \cdot \hat{g}(\omega)}$ This is the [convolution theorem](https://en.wikipedia.org/wiki/Convolution_theorem): convolution in time domain becomes multiplication in frequency domain. ## Signal Filtering with RC Circuits ### RC Circuit as Filter Consider the differential equation for an [RC circuit](https://en.wikipedia.org/wiki/RC_circuit): $R\frac{dQ}{dt} + \frac{1}{C}Q = V(t)$ Where: - $R$ = resistance - $C$ = capacitance - $Q$ = charge - $V(t)$ = input voltage (signal) ### Fourier Domain Analysis Taking the Fourier transform using the derivative property: $i\omega R \hat{Q}(\omega) + \frac{1}{C}\hat{Q}(\omega) = \hat{V}(\omega)$ Solving for $\hat{Q}(\omega)$: $\hat{Q}(\omega) = \frac{\hat{V}(\omega)}{i\omega R + \frac{1}{C}} = \frac{\hat{V}(\omega) \cdot C}{1 + i\omega RC}$ ### Transfer Function The transfer function $H(\omega) = \frac{1}{1 + i\omega RC}$ shows frequency-dependent behavior: **Magnitude**: $|H(\omega)| = \frac{1}{\sqrt{1 + (\omega RC)^2}}$ - For small ω (low frequencies): $|H(\omega)| \approx 1$ (signal passes through) - For large ω (high frequencies): $|H(\omega)| \approx \frac{1}{\omega RC}$ (signal attenuated) This is a **[low-pass filter](https://en.wikipedia.org/wiki/Low-pass_filter)**: - Cutoff frequency: $\omega_c = \frac{1}{RC}$ - Allows frequencies below $\omega_c$ to pass - Attenuates frequencies above $\omega_c$ - In audio: Reduces treble, preserves bass ## Check Your Understanding (Not for LSF) 1. **Spectrogram Interpretation**: Given a spectrogram with horizontal bands at different frequencies, what type of sound would this represent? 2. **Energy Distribution**: If $\hat{F}(\omega)$ has most of its energy concentrated near ω = 0, what does this tell you about the original signal $f(t)$? 3. **Filter Design**: An RC circuit with time constant τ = RC acts as a low-pass filter. What happens to the cutoff frequency if we double the capacitance? ## Key Takeaways 1. **Fourier transforms reveal frequency structure** that's hidden in time-domain signals 2. **Spectrograms** provide time-frequency analysis for non-stationary signals 3. **Energy in frequency space** $|\hat{F}(\omega)|^2$ has direct physical interpretation 4. **RC circuits** naturally implement frequency filtering through their transfer functions 5. **Human perception** of sound quality relates to harmonic content and decay rates ## Mathematical Connections - [[MATH310S26-Day7-Notes]]: Introduction to Fourier series - [[MATH310S26-Day11-Notes]]: Fourier transform derivation - [[MATH310S26-Day15-Notes]]: Rectangle function and sinc - [[MATH310S26-Day19-WorkdayMaterials (Convolution theorem and RC filtering)]]: Detailed RC circuit analysis - Upcoming: Convolution theorem connects filtering to multiplication in frequency domain