Filter löschen
Filter löschen

Help with sound function

2 Ansichten (letzte 30 Tage)
David Daminelli
David Daminelli am 1 Jun. 2019
Kommentiert: Walter Roberson am 2 Jun. 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 Kommentar
Walter Roberson
Walter Roberson am 2 Jun. 2019
http://www.earlevel.com/main/1996/10/21/a-question-of-phase/

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by