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

9 次查看(过去 30 天)
%%%%%%%%%%%%%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 个评论
Rakesh
Rakesh 2022-12-22
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 2022-12-22
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.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2020-11-1
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 个评论
divya reddy
divya reddy 2020-11-6
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^^^^^

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by