I'm working on a project which deals with filtering audio signals with a Low Pass Filter and amplifying the output. Currently, we are solving this using the TLV320AIC3111 audio codec by Texas Instruments, controlled by an STM32L476RG.
Using TI's proprietary software PurePath Studio, I've coded this filter below.
Our test setup is described below
Function Generator -> External Class D Amp -> External Speaker -> Microphone(codec input) -> Codec -> Speaker(codec output) -> External Microphone -> Oscilloscope
Using basic python code, we plotted the frequency response graph as below.
However, when we directly connect the frequency generator to the codec and the speaker output to the oscilloscope, we get a much better response as below.
When I connect the external speaker to the external microphone directly, (with no codec in between) we get a response as below.
Due to the similarity between images 2 and 3, I think the setup is not appropriate as external speaker and microphone are interfering with response.
However, when we use the same setup with an active analog filter with op-amps and similar filter specifications we get a proper response with none of the spikes observed in either of the aforementioned images.
I am having trouble figuring out why there would be such a difference between analog filter and codec filter. Can anyone guide me on this matter?