フィルターのクリア

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

5 ビュー (過去 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^^^^^
Walter Roberson
Walter Roberson 2020 年 11 月 6 日
Ah, I missed the fftshift() before. The effect is to make the algorithm into a low-pass filter instead of a high-pass filter.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by