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/plot_specgram.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/plot_specgram.m')
| -rw-r--r-- | octave/plot_specgram.m | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/octave/plot_specgram.m b/octave/plot_specgram.m new file mode 100644 index 0000000..7b9e3a6 --- /dev/null +++ b/octave/plot_specgram.m @@ -0,0 +1,22 @@ +% plot_specgram.m +% David Rowe May 2017 +% +% As the name suggests..... + +function S = plot_specgram(x, Fs=8000, fmin, fmax) + + step = fix(20*Fs/1000); # one spectral slice every 5 ms + window = fix(160*Fs/1000); # 40 ms data window + fftn = 2^nextpow2(window); # next highest power of 2 + [S, f, t] = specgram(x, fftn, Fs, window, window-step); + S = abs(S(2:fftn/2,:)); # magnitude in range 0<f<=Fs/2 Hz. + S = S/max(S(:)); # normalize magnitude so that max is 0 dB. + S = max(S, 10^(-20/10)); # clip below -20 dB. + S = min(S, 10^(-3/10)); # clip above -3 dB. + imagesc (t, f, log(S)); # display in log scale + set (gca, "ydir", "normal"); # put the 'y' direction in the correct direction + if nargin > 2 + axis([0 max(t) fmin fmax]) + end + xlabel('Time (s)'); ylabel('Freq (Hz)'); +endfunction |
