Effacer les filtres
Effacer les filtres

Help with sound function

2 vues (au cours des 30 derniers jours)
David Daminelli
David Daminelli le 1 Juin 2019
Commenté : Walter Roberson le 2 Juin 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 commentaire
Walter Roberson
Walter Roberson le 2 Juin 2019
http://www.earlevel.com/main/1996/10/21/a-question-of-phase/

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Audio I/O and Waveform Generation dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by