Skip to content

Commit cc98378

Browse files
authored
Update README snippet to 48kHz and Cheby2 comparison (#27)
* feat: update README and graphs to 48kHz and Butterworth vs Chebyshev II comparison * fix: update generate_graphs.py to use 48kHz for signal decomposition plot
1 parent 0e1a538 commit cc98378

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed
10.9 KB
Loading

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,23 +287,23 @@ import numpy as np
287287
from pyoctaveband import octavefilter
288288

289289
# 1. Generate a signal (Sum of 250Hz and 1000Hz)
290-
fs = 8000
291-
t = np.linspace(0, 0.5, fs // 2, endpoint=False)
290+
fs = 48000
291+
t = np.linspace(0, 0.5, int(fs * 0.5), endpoint=False)
292292
y = np.sin(2 * np.pi * 250 * t) + np.sin(2 * np.pi * 1000 * t)
293293

294-
# 2. Compare architectures (Butterworth vs Chebyshev I)
294+
# 2. Compare architectures (Butterworth vs Chebyshev II)
295295
# Filter with Butterworth (default)
296296
spl_b, freq, xb_butter = octavefilter(y, fs=fs, fraction=1, sigbands=True, filter_type='butter')
297297

298-
# Filter with Chebyshev I (ripples in passband, steeper roll-off)
299-
spl_c, _, xb_cheby = octavefilter(y, fs=fs, fraction=1, sigbands=True, filter_type='cheby1')
298+
# Filter with Chebyshev II (flat passband, ripples in stopband)
299+
spl_c2, _, xb_cheby2 = octavefilter(y, fs=fs, fraction=1, sigbands=True, filter_type='cheby2')
300300

301-
# 'xb_butter' and 'xb_cheby' contain the time-domain signals per band
301+
# 'xb_butter' and 'xb_cheby2' contain the time-domain signals per band
302302
```
303303

304304
<img src="https://raw.githubusercontent.com/jmrplens/PyOctaveBand/main/.github/images/signal_decomposition.png" width="80%"></img>
305305

306-
*The plot compares the **Butterworth** (solid blue) and **Chebyshev I** (dashed red) responses. The bottom plot shows the **Impulse Response**, highlighting the differences in stability and decay.*
306+
*The plot compares the **Butterworth** (solid blue) and **Chebyshev II** (dashed red) responses. The bottom plot shows the **Impulse Response**, highlighting the differences in stability and transient decay.*
307307

308308
---
309309

generate_graphs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ def generate_multichannel_response(output_dir: str) -> None:
241241

242242
def generate_decomposition_plot(output_dir: str) -> None:
243243
"""Generate time-domain decomposition plot comparing two filter types (Butterworth vs Chebyshev II)."""
244-
print("Generating signal_decomposition.png with comparison (Butter vs Cheby2)...")
245-
fs = 8000
244+
print("Generating signal_decomposition.png with comparison (Butter vs Cheby2) @ 48kHz...")
245+
fs = 48000
246246
duration = 0.5
247247
t = np.linspace(0, duration, int(fs * duration), endpoint=False)
248248

@@ -265,7 +265,7 @@ def generate_decomposition_plot(output_dir: str) -> None:
265265

266266
# 1. Original Signal
267267
axes[0].plot(t, y, color="black", linewidth=1.5)
268-
axes[0].set_title("Original Signal (250 Hz + 1000 Hz Sum)", fontweight="bold")
268+
axes[0].set_title("Original Signal (250 Hz + 1000 Hz Sum) @ 48 kHz", fontweight="bold")
269269
axes[0].set_ylim(y_lim)
270270
axes[0].set_xlim(0, 0.04)
271271

0 commit comments

Comments
 (0)