Help with sound function

4 次查看(过去 30 天)
David Daminelli
David Daminelli 2019-6-1
Hello!
I'm working on a project, and my ideia is shows that human ear cannot differentiate phase. I've alreay seen someone making this using matlab, and I'm tryng to replicate it, But somehow it's not working as I expected.
Here is my code:
load train;
X = y; % X is now the traun sound
Fs = 8192; %Sampling frequency, same as the loaded sound
T = 1/Fs; %Sampling period
L = length(X); %Lenght of signal
t = (0:L-1)*T; %Time vector
Y = fft(X); %
randY = rand_angle(Y); %Here i use a function that i have created to randomly change the angle, but not change the absolute
Y1 = ifft(Y);
Y2 = ifft(randY);
Here is the rand_angle function:
function y = rand_angle(x)
vetor = x;
n = length(vetor);
vetor1 = zeros([n,1]);
for j = 1:(n/2)
if j == 1
vetor1(j) = vetor(j);
vetor1(n/2 + 1) = vetor(n/2 + 1);
else
k = rand * 2 * pi;
vetor1(j) = abs( vetor(j) )* exp( 1i * k );
vetor1(n + 2 - j) = abs( vetor(j) ) * exp(-1i * k );
end
end
y = vetor1;
Ok, now when I try
sound(Y)
sound(Y1)
sound(Y2)
I expected that the 3 functions results on the same sound, but its not what is happening. I dont know if my premise that "human ear cant differenciate phase" is wrong, or if there is something wrong on my code. Hope someone can help. Thanks!
  1 个评论
Walter Roberson
Walter Roberson 2019-6-2
http://www.earlevel.com/main/1996/10/21/a-question-of-phase/

请先登录,再进行评论。

回答(0 个)

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by