Guest User

Untitled

a guest
Nov 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. % part 1
  2. [y, f] = audioread('file.wav');
  3. y = y(1:1024*161);
  4. % p = audioplayer(y,f);
  5. % play(p)
  6. Ya = fft(y);
  7. Y = fftshift(abs(Ya));
  8. N = length(Y);
  9. w = -f/2+f/N:f/N:f/2;
  10. figure(1)
  11. plot(w,Y)
  12. % part 2
  13. Y1 = Ya((N/4):(3*N/4));
  14. % part 3
  15. y = ifft(Y1);
  16. player = audioplayer(y,f);
  17. play(player)
  18.  
  19. % part 1:
  20. [y, f] = audioread('C:path to your wav file');
  21. y = y(1:1024*64); % select a portion of it.
  22.  
  23. Ya = fftshift(fft(y)); % Compute DFT Ya[k] and SHIFT it
  24. N = length(Ya); % Length of DFT Ya[k]
  25.  
  26. figure,plot(-f/2+f/N:f/N:f/2 , abs(Ya)) % plot the DFT magnitude.
  27.  
  28. % part 2:
  29. Yr = zeros(1,N); % Yr[k] of length N!
  30. Yr((N/4)+1:(3*N/4)) = Ya((N/4)+1:(3*N/4)); % Assign nonzero coefficients
  31.  
  32. % part 3:
  33. yr = real(ifft(fftshift(Yr))); % RECONSTRUCT the filtered signal.
  34. % Take REAL part for convenience.
  35. figure,plot(-f/2+f/N:f/N:f/2, abs((Yr)));
  36.  
  37. % part 4:
  38. sound(yr,f,16); % Listen to the reconstrcusted audio
Add Comment
Please, Sign In to add comment