Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
% Audio spectrum display. To exit, close the figure.
%
fs = 22050; % sample rate, hertz
N = 1024; % duration, samples
window = blackman(N); % weighting
window = window / mean(window); % normalize it
gca; % open the figure
while get(0,'CurrentFigure') % while figure still open
y = wavrecord(N, fs); % acquire some signal
h = fft(y .* window); % transform
plot(fs*(0:N/2)/N, 20*log10(max(2/N*abs(h(1:N/2+1)), 1e-10)));
ylim([-160 20]); xlabel('Hertz'); ylabel('dB');
drawnow; % allow figure to update
end