Borrar filtros
Borrar filtros

NEED EXPLANATION FOR A MATLAB AUDIO COMPRESSION URGENTLY PLEASE. I WOULD BE VERY GRATFUL

9 visualizaciones (últimos 30 días)
%%%%%%%%%%%%%TASK 1%%%%%%%%%%%%%%%%
[x,fs]=audioread('sample.wav');
N=length(x);
vlcplayer=audioplayer(x,fs);
vlcplayer.play
%%%%%%%%%%%% task 2%%%%%%%%%%%
t=fft(x,N);
X=fftshift(t)
f=-fs/2:fs/N:(fs/2-fs/N);
figure(1)
plot(f,abs(X))
title('original audio signal')
%%%%%%%%%%%%%% TASK 2 AND 4%%%%%%%%%
Xr=zeros(1,N);
Xr((N/4)+1:(3*N/4))= X((N/4)+1:(3*N/4)); %%FORMULA
figure(2)
plot(f, abs((Xr)));
xr= real(ifft(fftshift(Xr))); %%reconstruction
audiowrite('50% compressed.wav',xr,fs);
title('50% compressed audio')
xlabel('freq(hq)');ylabel('magnitude');
%%change ratio to 60,70,80,90,95% compression ....just change FORMULA
%Xr((N*((60/100)/2))+1 : N*(1-(60/100)/2)) = X((N*((60/100)/2))+1 : N*(1-(60/100)/2));
%Xr((N*((70/100)/2))+1 : N*(1-(60/100)/2)) = X((N*((60/100)/2))+1 : N*(1-(60/100)/2));
%Xr((N*((80/100)/2))+1 : N*(1-(60/100)/2)) = X((N*((60/100)/2))+1 : N*(1-(60/100)/2));
%Xr((N*((90/100)/2))+1 : N*(1-(60/100)/2)) = X((N*((60/100)/2))+1 : N*(1-(60/100)/2));
%Xr((N*((95/100)/2))+1 : N*(1-(60/100)/2)) = X((N*((60/100)/2))+1 : N*(1-(60/100)/2));
%%PLAYING THE OUTPUT
%audiowrite('60% compressed.wav',xr,fs);
%audiowrite('70% compressed.wav',xr,fs);
%audiowrite('80% compressed.wav',xr,fs);
%audiowrite('90% compressed.wav',xr,fs);
%audiowrite('95% compressed.wav',xr,fs);
  5 comentarios
Rakesh
Rakesh el 22 de Dic. de 2022
could you please forward the information about this code in pdf format like its abstract,introduction,references,theoritical analysis,etc.....like these
Walter Roberson
Walter Roberson el 22 de Dic. de 2022
Rakesh, you are assuming that someone has already written those out for this code, which is not at all certain. What you are asking for sounds quite a bit like what a student would be expected to write for an assignment; if someone had already written such a thing up, that would disqualify a second student from using the results in their own assignment because of academic integrity concerns.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 1 de Nov. de 2020
It is a high-pass filter. When you fft() the coefficients for the low frequencies come first, and increasing frequencies after that in the result until you get to the middle and then they reduce again. Middle is highest frequency, next to that on both sides is second highest frequency, and so on.
When you copy the middle of the results out to zeroes around it, then you are zeroing the lower frequencies, which is a high pass filter.
  8 comentarios
divya reddy
divya reddy el 6 de Nov. de 2020
X=fftshift(t)
xr= real(ifft(fftshift(Xr))); %%reconstruction
@walter thank you so so much!!!! :)
last doubt,
can you explain what role these two lines play in the code^^^^^
Walter Roberson
Walter Roberson el 6 de Nov. de 2020
Ah, I missed the fftshift() before. The effect is to make the algorithm into a low-pass filter instead of a high-pass filter.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by