clear;
[s, fs] = audioread('furelise.wav');   % Read audio signal
s = s(1:5*fs);                         % Extract first 5 seconds
L = length(s);                         % Compute its length in samples
Win = % INSERT CODE HERE - use round() % Specify analysis window: 40 ms
S = % INSERT CODE HERE - use round()   % Specify step size: 10 ms
N = % INSERT CODE HERE - use round()   % How many overlapping frames do we have?
dt = 1/fs;                             % Time step
f = linspace(0, fs/2, 1024);           % Frequency axis (1024 points for f > 0)
t_frame = 0:1/fs:Win/fs - 1/fs;        % Time axis for a frame
M = % INSERT CODE HERE                 % Fourier matrix for a frame (the usual)

% Iterate over frames
for i = 1:N
  disp(i)                      % Just to make sure it runs
  seg = % INSERT CODE HERE     % Extract 40ms audio chunk (use i, S, Win)
                               % that 75%-overlaps with the next one 
  X(:,i) = dt*seg.'*M.';       % Each frame's F.T. stored in a
                               % 2D array's columns
end

% Plots and visualizations
times = (1:S:L-Win)/fs;           % Overall time axis
SM = abs(X)/max(max(abs(X)));     % Normalize magnitude so that max is 0 dB.
SM = max(SM, 10^(-40/10));        % Clip below -40 dB.
SM = min(SM, 10^(-3/10));         % Clip above -3 dB.
imagesc(times, f, 20*log10(SM));  % Plot Fourier 2D array as an image!
set (gca, "ydir", "normal");      % Put the 'y' direction upwards
xlabel('Time (s)');               % x-axis info
ylabel('Frequency (Hz)');         % y-axis info