Skip to content

Instantly share code, notes, and snippets.

@PabRod
Forked from Enchufa2/chirp.m
Created April 19, 2016 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PabRod/44c358a96b080e1d249a14e869d57be8 to your computer and use it in GitHub Desktop.
Save PabRod/44c358a96b080e1d249a14e869d57be8 to your computer and use it in GitHub Desktop.
Simulation of the chirp echo created in the staircases of Mesoamerican pyramids
clap = audioread('clap.wav');
fs = 96e3; % sampling frequency
N = 40; % steps
ssize = 0.15; % step size
delay = ssize * 2 / 340;
samples = round(delay * fs);
stairs = zeros(samples * N + length(clap) + N, N);
for i = 1:N
samples = samples + 1;
indexes = (i-1)*samples+1 : length(clap)+(i-1)*samples;
stairs(indexes, i) = clap;
end
stairs = sum(stairs, 2);
audioplayer(clap, fs).play();
audioplayer(stairs, fs).play();
figure;
ax1(1) = subplot(2, 2, 1);
plot((1:length(clap))/fs, clap);
ax2(1) = subplot(2, 2, 2);
periodogram(clap);
ax1(2) = subplot(2, 2, 3);
plot((1:length(stairs))/fs, stairs);
ax2(2) = subplot(2, 2, 4);
periodogram(stairs);
set(ax2, 'xscale', 'log');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment