Last active
April 14, 2020 00:01
-
-
Save mattgaidica/c3a7fec31b3782a4bb3713b2150bdb88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
close all | |
files = {'/Users/matt/Downloads/Addison_XC31160 - Red-tailed Hawk - Buteo jamaicensis.mp3',... | |
'/Users/matt/Downloads/Chartier_XC401311 - Red-tailed Hawk - Buteo jamaicensis.mp3',... | |
'/Users/matt/Downloads/Wilson_XC53797 - Red-tailed Hawk - Buteo jamaicensis.mp3'}; | |
fileTitles = {'Addison Hawk','Chartier Hawk','Wilson Hawk'}; | |
rows = 3; | |
cols = 4; | |
figure('position',[0,0,1500,900]); | |
for iFile = 1:3 | |
[x, fs] = audioread(files{iFile}); | |
x = x(:, 1); | |
N = length(x); | |
t = (0:N-1)/fs; | |
subplot(rows,cols,prc(cols,[iFile,1])); | |
plot(t, x, 'r') | |
xlim([0 max(t)]) | |
grid on | |
xlabel('Time, s') | |
ylabel('Amplitude') | |
ylim([-1 1]); | |
title([fileTitles{iFile},' time domain']) | |
subplot(rows,cols,prc(cols,[iFile,2])); | |
spectrogram(x, 1024, 3/4*1024, [], fs, 'yaxis') | |
box on | |
xlabel('Time, s') | |
ylabel('Frequency, kHz') | |
caxis([-160 -30]); | |
title('Spectrogram') | |
h = colorbar; | |
set(h, 'FontName', 'Times New Roman', 'FontSize', 14) | |
ylabel(h, 'Magnitude, dB') | |
w = hanning(N, 'periodic'); | |
[X, f] = periodogram(x, w, N, fs, 'power'); | |
X = 20*log10(sqrt(X)*sqrt(2)); | |
subplot(rows,cols,prc(cols,[iFile,3])); | |
semilogx(f, X, 'r') | |
xlim([0 fs/2]) | |
grid on | |
title('Amplitude spectrum') | |
xlabel('Frequency, Hz') | |
ylim([-160 -30]); | |
ylabel('Magnitude, dB') | |
subplot(rows,cols,prc(cols,[iFile,4])); | |
histogram(x) | |
grid on | |
xlabel('Signal amplitude') | |
ylabel('Number of samples') | |
title('Probability distribution') | |
xlim([-0.25 0.25]); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment