%[x, fs] = audioread('SunshineSquare.wav');
load handel.mat
audiowrite("handel.wav", y, Fs);
[x, fs] = audioread('handel.wav');
X = fft(x);
f = linspace(0, fs/2, length(X)/2);
[~, f0] = max(abs(X(1:length(X)/2)));
f = (f0-1)/fs; % the corresponding freq for index f0
notchFilter_spec = fdesign.notch('N,F0,Q', 100, f, 10, fs/2); %
notchFilter = design(notchFilter_spec, 'Systemobject', true)
% fvtool(notchFilter)
y = notchFilter(x);
%y = filter(b, 1, x);
% sound(x, fs);
subplot(211); plot(x);
subplot(212); plot(y)