clear, clc, close all
% load an audio file
[x, fs] = audioread('track.wav'); % load an audio file
x = x(:, 1); % get the first channel
% define analysis parameters
% wlen = 1024; % window length (recomended to be power of 2)
hop = wlen/4; % hop size (recomended to be power of 2)
nfft = 4096; % number of fft points (recomended to be power of 2)
% perform STFT
win = blackman(wlen, 'periodic');
[S, f, t] = stft(x, win, hop, nfft, fs);
% calculate the coherent amplification of the window
C = sum(win)/wlen;
% take the amplitude of fft(x) and scale it, so not to be a
% function of the length of the window and its coherent amplification
S