{ "cells": [ { "cell_type": "markdown", "id": "c000", "metadata": {}, "source": [ "# 03. The DFT, windows and leakage\n", "\n", "The discrete Fourier transform (DFT) converts a block of samples into amplitudes and phases at\n", "evenly spaced frequencies. Most of the later notebooks (spectrograms, mel features, pitch,\n", "filtering by FFT) depend on it. This notebook covers exactly what it returns, why a pure tone often\n", "spreads over many bins (leakage), and what a window can and cannot do about that.\n", "\n", "**Learning outcomes.** After working through this notebook you can\n", "\n", "* state the DFT convention used by `audio_samples` (and NumPy), and read amplitudes off its\n", " output;\n", "* compute bin frequencies and explain spectral leakage;\n", "* compare windows by coherent gain, ENBW, scalloping loss and side-lobe level;\n", "* explain why zero padding does not improve frequency resolution, and choose $N$ to resolve two\n", " tones." ] }, { "cell_type": "code", "execution_count": null, "id": "c001", "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import scipy.signal as ss\n", "\n", "import audio_samples as aus\n", "\n", "rng = np.random.default_rng(seed=2026)\n", "F64 = np.dtype(\"float64\")\n", "WT = aus.WindowType" ] }, { "cell_type": "markdown", "id": "c002", "metadata": {}, "source": [ "## Concept\n", "\n", "**Definition.** For a block of $N$ samples $x[n]$, $n = 0, \\dots, N-1$:\n", "\n", "$$X[k] = \\sum_{n=0}^{N-1} x[n] \\, e^{-j 2\\pi k n / N}$$\n", "\n", "where $k$ is the integer bin index, $j = \\sqrt{-1}$ and $X[k]$ is a complex number in the units\n", "of $x$ (here: full scale) times samples. The exponent is **negative** and there is **no** $1/N$\n", "factor (the same as `numpy.fft.fft`).\n", "\n", "**Bin frequencies.** Bin $k$ sits at\n", "\n", "$$f_k = \\frac{k f_s}{N}, \\qquad \\Delta f = \\frac{f_s}{N}$$\n", "\n", "where $f_s$ is the sample rate in Hz and $\\Delta f$ the bin spacing in Hz. For real $x$,\n", "$X[N-k] = \\overline{X[k]}$, so only bins $0 \\dots \\lfloor N/2\\rfloor$ carry information; the\n", "library returns exactly those $\\lfloor N/2\\rfloor + 1$.\n", "\n", "**A tone on a bin.** For $x[n] = A\\cos(2\\pi k_0 n/N)$, $X[k_0] = A N/2$ (real); for\n", "$A\\sin(\\cdot)$, $X[k_0] = -jAN/2$. With a window $w[n]$ applied first, the peak becomes\n", "$A \\sum_n w[n] / 2$.\n", "\n", "**Leakage.** The DFT treats the block as one period of a periodic signal. If the tone does not\n", "complete a whole number of cycles in the block, the implied periodic signal has a jump at the\n", "block edge, and the energy spreads over all bins. Multiplying by a window that tapers to zero\n", "removes the jump, at the cost of a wider main lobe. A window $w[n]$ is summarised by:\n", "\n", "$$\\mathrm{CG} = \\frac{1}{N}\\sum_n w[n], \\qquad \\mathrm{ENBW} = \\frac{N \\sum_n w^2[n]}{\\left(\\sum_n w[n]\\right)^2}$$\n", "\n", "where the coherent gain CG (dimensionless) scales the peak of a bin-centred tone relative to no\n", "window, and the equivalent noise bandwidth ENBW (in bins) is how much broadband noise each bin\n", "collects. Two more figures are read off the window's spectrum $W(f)$ (with $f$ in bins): the\n", "**scalloping loss** $-20\\log_{10}|W(1/2)/W(0)|$ in dB, the worst-case peak drop for a tone halfway\n", "between bins, and the **peak side-lobe level** (PSL), the highest lobe outside the main lobe in\n", "dB relative to $W(0)$.\n", "\n", "The library's `WindowType.hanning` is the **symmetric** Hann window\n", "\n", "$$w[n] = 0.5 - 0.5\\cos\\!\\left(\\frac{2\\pi n}{N-1}\\right)$$\n", "\n", "(denominator $N-1$, so $w[0] = w[N-1] = 0$), i.e. SciPy's `scipy.signal.windows.hann(N, sym=True)`,\n", "not the periodic one (denominator $N$) that `scipy.signal.get_window('hann', N)` gives.\n", "\n", "**Zero padding** (appending zeros before the DFT) samples the same spectrum on a finer grid. It\n", "does **not** narrow the main lobe; only a longer stretch of signal does." ] }, { "cell_type": "markdown", "id": "c003", "metadata": {}, "source": [ "## With the library\n", "\n", "`AudioSamples.fft(n_fft)` returns the complex non-negative-frequency bins and\n", "`AudioSamples.rfft(n_fft)` their **magnitudes** (NumPy's `rfft` returns complex values). Both are\n", "shaped `(channels, n_fft // 2 + 1)`." ] }, { "cell_type": "code", "execution_count": null, "id": "c004", "metadata": {}, "outputs": [], "source": [ "# 64 samples: 0.25 (DC) + sin at bin 4 + 0.5 cos at bin 9.\n", "t = np.arange(64) / 64\n", "x = 0.25 + np.sin(2 * np.pi * 4 * t) + 0.5 * np.cos(2 * np.pi * 9 * t)\n", "audio = aus.AudioSamples.new_mono(x, sample_rate=16_000)\n", "\n", "spec = audio.fft(64)\n", "assert spec.shape == (1, 33) # N/2 + 1 bins\n", "assert abs(spec[0, 0] - 16.0) < 1e-9 # N x 0.25\n", "assert abs(spec[0, 4] - (-32.0j)) < 1e-9 # -j A N / 2: negative exponent\n", "assert abs(spec[0, 9] - 16.0) < 1e-9 # 0.5 N / 2\n", "\n", "mags = audio.rfft(64)\n", "assert mags.dtype == np.float64 # real numbers ...\n", "assert abs(mags[0, 4] - 32.0) < 1e-9 # ... equal to |X[4]|" ] }, { "cell_type": "markdown", "id": "c005", "metadata": {}, "source": [ "Measuring leakage: at $f_s = 16$ kHz and $N = 512$, $\\Delta f = 31.25$ Hz, so 1000 Hz is bin 32\n", "and 1015.625 Hz is bin 32.5, the worst case. Window the tone with `AudioSamples.apply_window` and\n", "coefficients from `WindowType.make_hanning` (the rectangular window is `np.ones`):" ] }, { "cell_type": "code", "execution_count": null, "id": "c006", "metadata": {}, "outputs": [], "source": [ "def windowed_spectrum(f, window):\n", " tone = aus.sine_wave(f, 0.032, sample_rate=16_000, dtype=F64) # 512 samples\n", " return tone.apply_window(window).rfft(512)[0]\n", "\n", "db = lambda r: 20 * np.log10(r)\n", "assert 16_000 / 512 == 31.25 and 1000 / 31.25 == 32 and 1015.625 / 31.25 == 32.5\n", "\n", "rect, hann = np.ones(512), WT.make_hanning(512)\n", "on, off = windowed_spectrum(1000.0, rect), windowed_spectrum(1015.625, rect)\n", "drop_rect, leak_rect = db(on.max() / off.max()), db(off[52] / off.max())\n", "on_h, off_h = windowed_spectrum(1000.0, hann), windowed_spectrum(1015.625, hann)\n", "drop_hann, leak_hann = db(on_h.max() / off_h.max()), db(off_h[52] / off_h.max())\n", "print(f\"rectangular: off-bin peak drop {drop_rect:.2f} dB, 19.5 bins away {leak_rect:.1f} dB\")\n", "print(f\"Hann: off-bin peak drop {drop_hann:.2f} dB, 19.5 bins away {leak_hann:.1f} dB\")\n", "# Rectangular: peak drops 3.86 dB off-bin, and 19.5 bins away the leakage is still only 34 dB down.\n", "assert abs(drop_rect - 3.86) < 0.01 and abs(leak_rect + 34.0) < 0.1\n", "# Hann: the peak drops only 1.42 dB, and 19.5 bins away the leakage is 86 dB down.\n", "assert abs(drop_hann - 1.42) < 0.01 and abs(leak_hann + 86.0) < 0.1" ] }, { "cell_type": "code", "execution_count": null, "id": "c007", "metadata": {}, "outputs": [], "source": [ "f_axis = np.arange(257) * 31.25\n", "fig, ax = plt.subplots(figsize=(8, 3))\n", "ax.plot(f_axis, db(off / off.max()), label=\"rectangular, 1015.625 Hz\")\n", "ax.plot(f_axis, db(off_h / off_h.max()), label=\"Hann, 1015.625 Hz\")\n", "ax.set(xlabel=\"Frequency (Hz)\", ylabel=\"Level re peak (dB)\", xlim=(0, 4000), ylim=(-120, 5),\n", " title=\"A tone halfway between bins (N = 512, fs = 16 kHz)\")\n", "ax.legend()\n", "plt.show()" ] }, { "cell_type": "markdown", "id": "c008", "metadata": {}, "source": [ "(The rectangular drop of 3.86 dB is slightly less than the window's 3.92 dB scalloping loss\n", "because a real sine also has a negative-frequency image whose leakage adds to the bins near the\n", "peak.)\n", "\n", "Zero padding versus a longer signal: two tones 20 Hz apart, Hann window." ] }, { "cell_type": "code", "execution_count": null, "id": "c009", "metadata": {}, "outputs": [], "source": [ "def peaks_near(m, n_fft, lo_hz, hi_hz):\n", " # Count local maxima above half the largest one between lo_hz and hi_hz.\n", " bin_hz = 16_000 / n_fft\n", " lo, hi = int(lo_hz / bin_hz), int(hi_hz / bin_hz)\n", " top = m[lo:hi].max()\n", " return sum(1 for i in range(lo, hi) if m[i] > m[i - 1] and m[i] >= m[i + 1] and m[i] > 0.5 * top)\n", "\n", "def two_tones_hann(n_samples, n_fft, f1=1000.0, f2=1020.0):\n", " t = np.arange(n_samples) / 16_000\n", " v = np.sin(2 * np.pi * f1 * t) + np.sin(2 * np.pi * f2 * t)\n", " a = aus.AudioSamples.new_mono(v, sample_rate=16_000).apply_window(WT.make_hanning(n_samples))\n", " return a.rfft(n_fft)[0]\n", "\n", "assert peaks_near(two_tones_hann(512, 512), 512, 900, 1120) == 1 # 32 ms\n", "assert peaks_near(two_tones_hann(512, 8192), 8192, 900, 1120) == 1 # zero-padded: still 1\n", "assert peaks_near(two_tones_hann(4096, 8192), 8192, 900, 1120) == 2 # 256 ms: resolved" ] }, { "cell_type": "code", "execution_count": null, "id": "c010", "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(8, 3))\n", "for n_samples, n_fft, lab in [(512, 512, \"512 samples\"), (512, 8192, \"512 samples, zero-padded to 8192\"),\n", " (4096, 8192, \"4096 samples, padded to 8192\")]:\n", " m = two_tones_hann(n_samples, n_fft)\n", " fa = np.arange(m.size) * 16_000 / n_fft\n", " ax.plot(fa, db(m / m.max()), marker=\".\" if n_fft == 512 else None, label=lab)\n", "ax.set(xlabel=\"Frequency (Hz)\", ylabel=\"Level re peak (dB)\", xlim=(850, 1170), ylim=(-40, 3),\n", " title=\"1000 Hz + 1020 Hz, Hann window\")\n", "ax.legend(fontsize=7)\n", "plt.show()" ] }, { "cell_type": "markdown", "id": "c011", "metadata": {}, "source": [ "## How it works\n", "\n", "This section re-derives four results: the DFT itself, the window coefficients, the symmetric-Hann figures in\n", "closed form, and the rectangular window's scalloping loss and Hann's side-lobe level." ] }, { "cell_type": "code", "execution_count": null, "id": "c012", "metadata": {}, "outputs": [], "source": [ "# 1. The DFT as a matrix product, against the library's FFT and NumPy's.\n", "x = (np.arange(64) * 7 % 13 - 6.0) / 6.0\n", "n = np.arange(64)\n", "k = np.arange(33)[:, None]\n", "naive = (x * np.exp(-2j * np.pi * k * n / 64)).sum(axis=1)\n", "lib = aus.AudioSamples.new_mono(x, sample_rate=16_000).fft(64)[0]\n", "# 64-term sums of O(1) values: rounding of order 1e-14.\n", "assert np.allclose(lib, naive, atol=1e-12)\n", "assert np.allclose(lib, np.fft.rfft(x), atol=1e-12)\n", "assert np.allclose(np.abs(lib), aus.AudioSamples.new_mono(x, sample_rate=16_000).rfft(64)[0], atol=1e-12)" ] }, { "cell_type": "code", "execution_count": null, "id": "c013", "metadata": {}, "outputs": [], "source": [ "# 2. The library's windows are SciPy's *symmetric* windows (fftbins=False), to rounding.\n", "for name, scipy_name in [(\"hanning\", \"hann\"), (\"hamming\", \"hamming\"), (\"blackman\", \"blackman\")]:\n", " w = getattr(WT, \"make_\" + name)(512)\n", " assert np.allclose(w, ss.get_window(scipy_name, 512, fftbins=False), rtol=0, atol=1e-14)\n", "# ... and differ from the periodic default by up to half a percent of full scale.\n", "periodic_gap = np.max(np.abs(WT.make_hanning(512) - ss.get_window(\"hann\", 512)))\n", "print(f\"max |symmetric - periodic| Hann, N=512: {periodic_gap:.4f}\")\n", "assert 0.004 < periodic_gap < 0.005\n", "\n", "# 3. Symmetric Hann: sum w = (N-1)/2 and sum w^2 = 3(N-1)/8, so CG = (N-1)/(2N) and\n", "# ENBW = 1.5 N/(N-1). For N = 512: 0.4990 and 1.5029.\n", "N = 512\n", "w = WT.make_hanning(N)\n", "cg = w.sum() / N\n", "enbw = N * np.sum(w ** 2) / w.sum() ** 2\n", "assert abs(cg - (N - 1) / (2 * N)) < 1e-12 and abs(enbw - 1.5 * N / (N - 1)) < 1e-12\n", "assert abs(cg - 0.4990) < 1e-4 and abs(enbw - 1.5029) < 1e-4\n", "assert w[0] == 0.0 and abs(w[-1]) < 1e-15 # symmetric: zero at both ends,\n", "assert abs(w[256] - 0.999991) < 1e-6 # and no sample exactly at 1.0" ] }, { "cell_type": "code", "execution_count": null, "id": "c014", "metadata": {}, "outputs": [], "source": [ "# 4a. Rectangular window: |W(f)| = |sin(pi f) / sin(pi f / N)|, so half a bin off,\n", "# |W(1/2)/W(0)| = 1 / (N sin(pi / 2N)), i.e. 3.92 dB.\n", "loss_rect = -20 * np.log10(1 / (N * np.sin(np.pi / (2 * N))))\n", "assert abs(loss_rect - 3.92) < 0.01\n", "\n", "# 4b. Hann's peak side-lobe level from a heavily zero-padded spectrum of the window itself:\n", "# the first local minimum marks the end of the main lobe; the PSL is the largest value after it.\n", "Wf = np.abs(np.fft.rfft(w, 64 * N))\n", "Wdb = 20 * np.log10(Wf / Wf[0] + 1e-300)\n", "first_null = np.argmax(np.diff(Wdb) > 0) # first index where the curve turns upwards\n", "psl_hann = Wdb[first_null:].max()\n", "print(f\"Hann PSL from the spectrum: {psl_hann:.2f} dB; first null at {first_null / 64:.2f} bins\")\n", "assert abs(psl_hann - (-31.47)) < 0.01\n", "assert abs(first_null / 64 - 2.0) < 0.02 # main lobe +-2 bins wide" ] }, { "cell_type": "markdown", "id": "c015", "metadata": {}, "source": [ "The same comparison holds for the Kaiser window across small and large $\\beta$." ] }, { "cell_type": "code", "execution_count": null, "id": "c016", "metadata": {}, "outputs": [], "source": [ "for beta in [2.0, 3.75, 4.0, 8.0]:\n", " gap = np.max(np.abs(WT.make_kaiser(64, beta) - ss.windows.kaiser(64, beta, sym=True)))\n", " print(f\"beta = {beta:4.2f}: max |library - scipy| = {gap:.2e}\")\n", " assert gap < 1e-6" ] }, { "cell_type": "markdown", "id": "c017", "metadata": {}, "source": [ "## Ask the library to explain\n", "\n", "`aus.explain.dft` explains bin spacing and the mirror symmetry; `aus.explain.window` (or\n", "`aus.explain.explain(window_type, n_fft=..., sample_rate=...)`) measures the window figures from\n", "the actual coefficients the STFT uses:" ] }, { "cell_type": "code", "execution_count": null, "id": "c018", "metadata": {}, "outputs": [], "source": [ "dft_doc = aus.explain.dft(512, 16_000.0)\n", "assert dft_doc.quantity(\"Bin spacing\") == 31.25\n", "assert dft_doc.quantity(\"Non-redundant bins\") == 257\n", "\n", "hann_doc = aus.explain.window(WT.hanning, 512, 16_000.0)\n", "assert abs(hann_doc.quantity(\"Coherent gain\") - cg) < 1e-12\n", "assert abs(hann_doc.quantity(\"Equivalent noise bandwidth\") - enbw) < 1e-12\n", "assert abs(hann_doc.quantity(\"Peak side-lobe level\") - psl_hann) < 0.01\n", "assert abs(hann_doc.quantity(\"Scalloping loss\") - 1.42) < 0.01\n", "rect_doc = aus.explain.window(WT.rectangular, 512, 16_000.0)\n", "assert abs(rect_doc.quantity(\"Scalloping loss\") - loss_rect) < 0.01\n", "\n", "# (window, coherent gain, ENBW in bins, peak side-lobe level in dB), N = 512\n", "rows = []\n", "for wt, cg_, enbw_, psl_ in [\n", " (WT.rectangular, 1.0, 1.0, -13.26),\n", " (WT.hanning, 0.4990, 1.5029, -31.47),\n", " (WT.hamming, 0.5391, 1.3647, -42.67),\n", " (WT.blackman, 0.4192, 1.7301, -58.11),\n", "]:\n", " d = aus.explain.explain(wt, n_fft=512, sample_rate=16_000.0)\n", " got = (d.quantity(\"Coherent gain\"), d.quantity(\"Equivalent noise bandwidth\"), d.quantity(\"Peak side-lobe level\"))\n", " rows.append((str(wt), *got))\n", " assert abs(got[0] - cg_) < 1e-4 and abs(got[1] - enbw_) < 1e-4 and abs(got[2] - psl_) < 0.01\n", "for r in rows:\n", " print(\"{:12s} CG {:.4f} ENBW {:.4f} bins PSL {:7.2f} dB\".format(*r))" ] }, { "cell_type": "code", "execution_count": null, "id": "c019", "metadata": {}, "outputs": [], "source": [ "doc = aus.explain.explain(WT.hanning, n_fft=512, sample_rate=16_000.0)\n", "assert doc.has_warning_containing(\"symmetric\")\n", "doc" ] }, { "cell_type": "markdown", "id": "c020", "metadata": {}, "source": [ "The table shows the standard trade-off: lower side lobes (less leakage from loud components into\n", "quiet ones) cost a wider main lobe and more noise per bin.\n", "\n", "## Exercises\n", "\n", "1. At $f_s = 44.1$ kHz with $N = 4096$, which bin is nearest to 440 Hz? Store the bin index in\n", " `answer`, compute its centre frequency, and check that a Hann-windowed 440 Hz tone peaks there." ] }, { "cell_type": "code", "execution_count": null, "id": "c021", "metadata": {}, "outputs": [], "source": [ "answer = None # TODO" ] }, { "cell_type": "code", "execution_count": null, "id": "c022", "metadata": { "tags": [ "solution" ] }, "outputs": [], "source": [ "# Solution\n", "answer = round(440 * 4096 / 44_100) # round(40.87) = 41\n", "assert answer == 41\n", "assert abs(answer * 44_100 / 4096 - 441.43) < 0.01\n", "tone = np.sin(2 * np.pi * 440 * np.arange(4096) / 44_100)\n", "m = aus.AudioSamples.new_mono(tone, sample_rate=44_100).apply_window(WT.make_hanning(4096)).rfft(4096)[0]\n", "assert np.argmax(m) == answer" ] }, { "cell_type": "markdown", "id": "c023", "metadata": {}, "source": [ "2. A sine of amplitude 0.5 lies exactly on a bin, Hann window, $N = 1024$. Predict $|X[k]|$ at the\n", " peak, then measure." ] }, { "cell_type": "code", "execution_count": null, "id": "c024", "metadata": {}, "outputs": [], "source": [ "answer = None # TODO" ] }, { "cell_type": "code", "execution_count": null, "id": "c025", "metadata": { "tags": [ "solution" ] }, "outputs": [], "source": [ "# Solution\n", "answer = 0.5 * WT.make_hanning(1024).sum() / 2 # A * sum(w) / 2 = 0.5 * 511.5 / 2\n", "assert abs(answer - 127.875) < 1e-9 # sum of a symmetric Hann is (N-1)/2\n", "x = aus.sine_wave(1000.0, 0.064, sample_rate=16_000, amplitude=0.5, dtype=F64) # 1024 samples, bin 64\n", "m = x.apply_window(WT.make_hanning(1024)).rfft(1024)[0]\n", "# The tone's negative-frequency image leaks a little into bin 64: allow 1e-3.\n", "assert abs(m[64] - answer) < 1e-3" ] }, { "cell_type": "markdown", "id": "c026", "metadata": {}, "source": [ "3. With a Hann window (main lobe about 2 bins wide at $-6$ dB), what is the smallest $N$ that\n", " should separate two tones 10 Hz apart at 16 kHz? Check that the next power of two separates\n", " 1000 Hz and 1010 Hz, and that $N = 1024$ does not." ] }, { "cell_type": "code", "execution_count": null, "id": "c027", "metadata": {}, "outputs": [], "source": [ "answer = None # TODO" ] }, { "cell_type": "code", "execution_count": null, "id": "c028", "metadata": { "tags": [ "solution" ] }, "outputs": [], "source": [ "# Solution\n", "answer = 2 * 16_000 / 10 # main lobe 2 fs / N <= 10 Hz => N >= 3200\n", "assert answer == 3200\n", "assert abs(aus.explain.window(WT.hanning, 4096, 16_000.0).quantity(\"Main-lobe width (-6 dB)\") - 2.0) < 0.01\n", "assert peaks_near(two_tones_hann(4096, 4096, 1000.0, 1010.0), 4096, 950, 1060) == 2\n", "assert peaks_near(two_tones_hann(1024, 1024, 1000.0, 1010.0), 1024, 950, 1060) == 1" ] }, { "cell_type": "markdown", "id": "c029", "metadata": {}, "source": [ "## Common pitfalls\n", "\n", "* `AudioSamples.rfft` returns **magnitudes**, not NumPy's complex `rfft`; use\n", " `AudioSamples.fft` for phase.\n", "* Neither transform normalises: a full-scale bin-centred sine gives $N/2$, not 1 or 0.5. Divide\n", " by $\\sum w / 2$ to read amplitudes.\n", "* `n_fft` must be **at least** the signal length (shorter signals are zero-padded; longer ones\n", " raise `AudioSpectrogramError`, they are not truncated).\n", "* `WindowType.hanning` is the **symmetric** Hann; `scipy.signal.get_window('hann', N)` gives\n", " the periodic one. Values differ by up to about 0.005; build the window yourself\n", " (`scipy.signal.get_window`) and use `WindowType.custom` to match them exactly.\n", "* Zero padding makes plots smoother; it does not improve resolution.\n", "\n", "## See also\n", "\n", "* Rust guide chapter: [03. The DFT, windows and leakage](https://docs.rs/audio_samples/latest/audio_samples/guide/c03_dft_windows/index.html) (available from the next release; until then build the docs locally with `cargo doc --features educational,full_no_plotting --open`)\n", " and the lab `examples/tutorial_03_dft_windows.rs`.\n", "* Python API: `AudioSamples.fft`, `AudioSamples.rfft`, `AudioSamples.apply_window`,\n", " `WindowType`, `audio_samples.utils.fft_frequencies`, `aus.explain.dft`, `aus.explain.window`\n", " ([API reference](../api/audio_samples.rst)).\n", "* Previous: [02. Quantisation and dither](02_quantisation_dither.ipynb).\n", " Next: [04. STFT and spectrograms](04_stft_spectrograms.ipynb)." ] }, { "cell_type": "markdown", "id": "references", "metadata": {}, "source": [ "## References\n", "\n", "* Harris, F. J. (1978). On the use of windows for harmonic analysis with the discrete Fourier transform. *Proceedings of the IEEE*, 66(1), 51-83. The window figures of merit (coherent gain, ENBW, scalloping loss, highest side lobe) reproduced in this notebook.\n", "* Oppenheim, A. V. and Schafer, R. W. (2010). *Discrete-Time Signal Processing*, 3rd ed. Pearson. Chapters 8 and 10 (the DFT; Fourier analysis with windows)." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }