Firtha
Electrical
- Oct 6, 2009
- 1
Hello!
I'm writing a phase vocoder in MATLAB, with synthesis of sum of sinusoids. As the for loop is very slow in MATLAB, to process a 10 seconds long wav it takes 6 secs with "for" loop, while with a matrix operation it's only 0.3 secs. The problem is that with matrix operation the output is just some noise, the original sound is almost unrecognizable.
The part of the code is the following:
With for loop:
for k=1:step_size
r0 = r0+delta_r;
psi = psi+delta_psi;
res(k) = r0'*cos(psi);
end
with matrix op.:
res=(r0 + (1:step_size)*delta_r).*cos(psi + (1:step_size)*delta_psi);
psi=psi+step_size*delta_psi;
I've tried out the codes, and they seem to give the completely same result, that's why it's misterious why it doesn't work.
The whole .m file is attached, I'd be very pleased if anyone could tell me what the problem is, it'd be quite important.
I'm writing a phase vocoder in MATLAB, with synthesis of sum of sinusoids. As the for loop is very slow in MATLAB, to process a 10 seconds long wav it takes 6 secs with "for" loop, while with a matrix operation it's only 0.3 secs. The problem is that with matrix operation the output is just some noise, the original sound is almost unrecognizable.
The part of the code is the following:
With for loop:
for k=1:step_size
r0 = r0+delta_r;
psi = psi+delta_psi;
res(k) = r0'*cos(psi);
end
with matrix op.:
res=(r0 + (1:step_size)*delta_r).*cos(psi + (1:step_size)*delta_psi);
psi=psi+step_size*delta_psi;
I've tried out the codes, and they seem to give the completely same result, that's why it's misterious why it doesn't work.
The whole .m file is attached, I'd be very pleased if anyone could tell me what the problem is, it'd be quite important.