Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % part 1
- [y, f] = audioread('file.wav');
- y = y(1:1024*161);
- % p = audioplayer(y,f);
- % play(p)
- Ya = fft(y);
- Y = fftshift(abs(Ya));
- N = length(Y);
- w = -f/2+f/N:f/N:f/2;
- figure(1)
- plot(w,Y)
- % part 2
- Y1 = Ya((N/4):(3*N/4));
- % part 3
- y = ifft(Y1);
- player = audioplayer(y,f);
- play(player)
- % part 1:
- [y, f] = audioread('C:path to your wav file');
- y = y(1:1024*64); % select a portion of it.
- Ya = fftshift(fft(y)); % Compute DFT Ya[k] and SHIFT it
- N = length(Ya); % Length of DFT Ya[k]
- figure,plot(-f/2+f/N:f/N:f/2 , abs(Ya)) % plot the DFT magnitude.
- % part 2:
- Yr = zeros(1,N); % Yr[k] of length N!
- Yr((N/4)+1:(3*N/4)) = Ya((N/4)+1:(3*N/4)); % Assign nonzero coefficients
- % part 3:
- yr = real(ifft(fftshift(Yr))); % RECONSTRUCT the filtered signal.
- % Take REAL part for convenience.
- figure,plot(-f/2+f/N:f/N:f/2, abs((Yr)));
- % part 4:
- sound(yr,f,16); % Listen to the reconstrcusted audio
Add Comment
Please, Sign In to add comment