diff options
| author | Marin Ivanov <[email protected]> | 2025-07-25 10:17:14 +0300 |
|---|---|---|
| committer | Marin Ivanov <[email protected]> | 2026-01-18 20:09:26 +0200 |
| commit | 0168586485e6310c598713c911b1dec5618d61a1 (patch) | |
| tree | 6aabc2a12ef8fef70683f5389bea00f948015f77 /octave/diff_fft_mag.m | |
* codec2 cut-down version 1.2.0
* Remove codebook and generation of sources
* remove c2dec c2enc binaries
* prepare for emscripten
Diffstat (limited to 'octave/diff_fft_mag.m')
| -rw-r--r-- | octave/diff_fft_mag.m | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/octave/diff_fft_mag.m b/octave/diff_fft_mag.m new file mode 100644 index 0000000..005be70 --- /dev/null +++ b/octave/diff_fft_mag.m @@ -0,0 +1,27 @@ +% Compare the magnitude spectrum of two int16 raw files +function diff_fft_mag(filename1, filename2, threshdB = -40, ignore=1000) + % load samples and ignore any start up transients + s1 = load_raw(filename1)'; + s1 = s1(ignore:end); + s2 = load_raw(filename2)'; + s2 = s2(ignore:end); + + len = min([length(s1) length(s2)]); + s1 = s1(1:len); s2 = s2(1:len); + + S1 = abs(fft(s1.*hanning(length(s1))')); + S2 = abs(fft(s2.*hanning(length(s2))')); + + figure(1): clf; + plot(20*log10(S1)); hold on; plot(20*log10(S2)); plot(20*log10(abs(S1-S2)),'r'); hold off; + error = S1 - S2; + error_energy = error*error'; + ratio = error_energy/(S1*S1'); + ratio_dB = 10*log10(ratio); + printf("ratio_dB: %4.2f\n", ratio_dB); + if ratio_dB < threshdB + printf('PASS\n'); + else + printf('FAIL\n'); + end +endfunction |
