如何理解短时傅里叶变换(Short Time Fourier Transform, STFT)

因为最近一直在学习语音信号的处理,看了Haytham Fayek的一篇博客后关于什么是傅里叶变换感到很迷惑,所以就专门写下一篇文章,整理一下我从网页上搜集的内容。

短时傅里叶变换(Short Time Fourier Transform, STFT) 是一个用于语音信号处理的通用工具.它定义了一个非常有用的时间和频率分布类, 其指定了任意信号随时间和频率变化的复数幅度. 实际上,计算短时傅里叶变换的过程是把一个较长的时间信号分成相同长度的更短的段, 在每个更短的段上计算傅里叶变换, 即傅里叶频谱。

实现时, 短时傅里叶变换被计算为一系列加窗数据帧的快速傅里叶变换 (Fast Fourier Transform, FFT),其中窗口随时间 “滑动” (slide) 或“跳跃” (hop) 。

  • 傅立叶变换可以将时间0~t内采集的信号(时域,横轴时间、纵轴大小)分解为不同频率上的信号分量(频域,横轴频率、纵轴大小)。
  • 短时傅立叶采用滑动窗口机制,设定窗口大小和步长,让窗口在时域信号上滑动,分别计算每个窗口的傅立叶变换,形成了不同时间窗口对应的频域信号,拼接起来就成为了频率随时间变化的数据(时频信号)。

 

  • 7
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
function [S, f, t] = stft(x, fs, window, nfft, noverlap) % STFT - Short-time Fourier Transform % [S, f, t] = stft(x, fs, window, nfft, noverlap) % x: input signal % fs: sampling frequency % window: window function (default: hamming) % nfft: number of FFT points (default: length of window) % noverlap: number of samples overlapped between adjacent frames (default: 0) % S: STFT matrix (nfft/2+1 x nframes) % f: frequency vector % t: time vector % Example: % [x, fs] = audioread('speech.wav'); % [S, f, t] = stft(x, fs, hamming(512), 512, 256); % imagesc(t, f, 20*log10(abs(S))); % axis xy; colormap(jet); colorbar; xlabel('Time (s)'); ylabel('Frequency (Hz)'); % Written by Yuancheng Zhu (yzhu@nd.edu) % Last update: 2021/9/9 % Check inputs narginchk(2, 5); if nargin < 3 || isempty(window) window = hamming(256); end if nargin < 4 || isempty(nfft) nfft = length(window); end if nargin < 5 || isempty(noverlap) noverlap = 0; end if ~isvector(window) || ~isnumeric(window) error('Window function must be a numeric vector.'); end if ~isscalar(fs) || ~isnumeric(fs) || fs <= 0 error('Sampling frequency must be a positive scalar.'); end if ~isscalar(nfft) || ~isnumeric(nfft) || nfft <= 0 error('Number of FFT points must be a positive scalar.'); end if ~isscalar(noverlap) || ~isnumeric(noverlap) || noverlap < 0 error('Number of overlapped samples must be a non-negative scalar.'); end if noverlap >= length(window) error('Number of overlapped samples must be less than the window length.'); end % Calculate STFT parameters nframes = fix((length(x)-noverlap)/(length(window)-noverlap)); if nframes < 1 error('Signal is too short for STFT with the given parameters.'); end x = x(:); window = window(:); S = zeros(nfft/2+1, nframes); t = (nfft/2:nfft/2+nframes-1) / fs; % Compute STFT for i = 1:nframes idx = (1:length(window)) + (i-1)*(length(window)-noverlap); if idx(end) > length(x) idx = idx(idx <= length(x)); xw = [x(idx); zeros(length(window)-length(idx), 1)]; else xw = x(idx) .* window; end X = fft(xw, nfft); S(:, i) = X(1:nfft/2+1); end f = (0:nfft/2)' / nfft * fs; end

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值