NEED EXPLANATION FOR A MATLAB AUDIO COMPRESSION URGENTLY PLEASE. I WOULD BE VERY GRATFUL
조회 수: 10 (최근 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
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
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
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
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 Exchange에서 Simulation, Tuning, and Visualization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!