Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% spectrum
- clear;
- clc;
- audioSpectrumLow = 20; % 20 hz
- audioSpectrumHigh = 20000; % 20 khz
- [input Fs] = audioread('sample.wav');
- %sound(input,Fs)
- N = length(input); %% get the length of the audio signal
- spectra = abs(fft(input, N)); %% do the fast fourrier transformaiton
- spectra = spectra(1:N/2 + 1); %%
- freqs = (Fs / N) * (0 : N/2);
- stem(freqs, spectra);
- figure
- ylabel('amplitude');
- xlabel('f(hz)')
- %xlim([audioSpectrumLow audioSpectrumHigh]);
- % noise frequency = 6000hz
- cutoffFrequency = 3000; %noise frequency /2
- T = 1./Fs;
- t = 1./(2.*pi.*cutoffFrequency); % tau
- output = zeros(N,1);
- for n = 2:N
- output(n) = output(n-1).*exp(-T/t) + input(n-1).*(1-exp(-T/t));
- end
- %sound(output,Fs);
- %plot spectrum
- spectra = abs(fft(input, N)); %% do the fast fourrier transformaiton
- spectra = spectra(1:N/2 + 1); %%
- freqs = (Fs / N) * (0 : N/2);
- stem(freqs, spectra);
- audiowrite('output.wav',output,Fs);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement