Hey their,
I am trying to create a short ultrasonic chirp frequency bound to between 36-44khz. I figured I would do this by creating a 36-44khz chirp and then using a Butterworth bandpass filter to filter out all unwanted frequencies outside of my 36-44khz range. The filter works at filtering out most frequencies however it seems to struggle to filter out 80khz and 10hz. I’m not sure why this is, am I doing it wrong or is this a limitation of the filter in general? Note: the chirp is only 288 samples long at a sample rate of 192khz.
Any help is appreciated!
Thanks
for (int index = 0; index < chirpLengthInSamples; index++) {
const auto output = sin(phaseValue * (2.0 * double_Pi));
//const auto frequency = m_min_f * exp((log(m_max_f / m_min_f) / chirpLengthInSamples) * index); //eponential
const auto frequency = ((((m_max_f - m_min_f) / chirpLengthInSamples)*index)+m_min_f); //linear growth
phaseValue += frequency / sampleRate;
if (phaseValue > 1.0) {
phaseValue -= 1.0;
}
//save value to the chirp array
ChirpSignalArr[index] = output;
}//end chirp generation
IIRFilter bandpassFilter;
IIRCoefficients coefficent;
int rollOffBandPass = 1; //the steapness of the rollof of frequencies outside the desired band
int rollOffWindow = 4;
double middleFrequency = ((m_max_f - m_min_f) / 2.0) + m_min_f; //finds the middle frequency between Fmax and Fmin
double frequencyResponse = sqrt((m_max_f * m_min_f)); //finds the frequency responce
double bandWidth = m_max_f - m_min_f; //calculates the bandwidth
double QFactor = frequencyResponse / bandWidth; //finds the overall Q factor to be used
//Apply the bandpass filter on the calculated signal
bandpassFilter.setCoefficients(coefficent.makeBandPass(currentSampleRate, frequencyResponse, QFactor));
for (int i = 0; i < rollOffBandPass; i++) {
bandpassFilter.processSamples(ChirpSignalArr, chirpLengthInSamples);
}
//apply hamming window
for (int i = 0; i < rollOffWindow; i++) {
window.multiplyWithWindowingTable(ChirpSignalArr, chirpLengthInSamples);
}