I am doing sampling and filtering for a 17KHz sine audio wave signal, the Nyquist frequency is about 20.8889KHz. I found the fact that this audio signal's amplitude decreased dramatically after it went through an FIR bandpass filter( pass band 16.8khz-17.2khz), the amplitude also decreased after an FIR highpass filter(cutoff frequency 17khz). I think that's because the audio signal frequency is kinda close to Nyquist frequency, am I right? Is there a filter can preserve the original amplitude of the audio signal within the frequency I want? Shown below is a pic consists of 2 signals before and after filtering(highpass filter) Thank you in advance
As per Peter K. recommendation, I will reformulate my comment as an answer, instead of starting by asking:
I think the fact that the cutoff frequency of your HPF is 17KHz (your tone frequency) can perfectly explain why your signal is being attenuated.
I would recommend you to try to move down the cutoff frequency of the High Pass Filter in order to avoid attenuating your tone.
Well, a cutoff frequency of 17kHz and a signal frequency of 17kHz don't really match well. The cutoff needs to be above the signal frequency.
The good news is that close to the Nyquist frequency, it is pretty easy to realize sharp cutoffs with digital filters (though IIR ones) due to frequency warping of the bilinear transform.
The bad news is that when your signal frequency is 17kHz and your Nyquist frequency is about 21kHz, you'll need darn good antialiasing filters to get a useful digital signal in the first place. This won't likely work without significant oversampling and lowpass filtering in the digital domain before downsampling to the processing rate. Good audio converters do that kind of stuff internally, but ordinary A/D converters do nothing of that kind. So it is pretty important that you are working with high quality oversampling audio converters to start with.
To reproduce amplitude as a signal increases in frequency towards Nyquist, the length of a FIR filter has to increase in length by roughly in inverse proportion to the distance to the Nyquist Fs/2 frequency. So one possibility is that your filters are too short.