|
Hi All,
I had an audio wav file. I am supposed to use data in the audio to create visual animated plot.
So far, I am able to create an animated surf plot using the below code. I would like to link the frequency variation of the audio to the amplitude of the plot so that when the audio finishes playing, the surf plot should stop animating. Can anyone help me? Any suggestions to create visually animated plots of anything with regards to audio signal is also appreciated.
[x,fs]=wavread('Equalized_all.wav');
Fs=fs/(1024*1024);
temp = [0.5*Fs, 0.9*Fs, 2*Fs^2, ...
1.5*Fs, 4*Fs, 5*Fs, 6*Fs, ...
5*Fs^2, 5*Fs^2, 7*Fs, 8*Fs, 9*Fs];
% Eigenfunctions
for k = 1:12
L{k} = membrane(k);
end
% Get coefficients from eigenfunctions.
for k = 1:12
c(k) = L{k}(25,23)/3;
end
% Set graphics parameters.
fig = figure;
set(fig,'color','white')
x = (-15:15)/15;
L{1}(L{1}==0)=NaN;
h = surf(x,x,L{1});
[a,e] = view;
view(a+90,e);
axis([-1 1 -1 1 -1 1]);
caxis(26.9*[-1.5 1]);
colormap hsv;
axis on
% Run
t = 0;
dt = 0.025;
set(fig,'userdata',dt)
while ishandle(fig)
% Coefficients
dt = get(fig,'userdata');
t = t + dt;
s = c.*sin(sqrt(temp)*t);
% Amplitude
A = zeros(size(L{1}));
for k = 1:12
A = (A + s(k)*L{k})-Fs;
end
% Velocity
s = temp .*s;
V = zeros(size(L{1}));
for k = 1:12
V = V + s(k)*L{k};
end
V(16:31,1:15) = NaN;
% Surface plot of height, colored by velocity.
set(h,'zdata',A,'cdata',V);
drawnow
|