Help with sound function

4 visualizaciones (últimos 30 días)
David Daminelli
David Daminelli el 1 de Jun. de 2019
Comentada: Walter Roberson el 2 de Jun. de 2019
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 comentario
Walter Roberson
Walter Roberson el 2 de Jun. de 2019
http://www.earlevel.com/main/1996/10/21/a-question-of-phase/

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by