1
votes

I struggle with this for quite some time now. For an iOS App I am recording some Audio using the device's microphone. I later try to evaluate the recording. I got everything done in Python using SciPy and it works very nice. I used SciPy's butterworth filter implementation.

But when I tried to translate my code into Swift I couldn't find a good way to apply a bandpass filter to my float array.

Could anyone guide me into the right direction or do you have finished code samples? I need a bandpass filter with frequency range from 1100 to 2100 Hz.

1
Maybe this will help github.com/bartolsthoorn/NVDSPalgrid
Thanks. Library worked very good. Although it doesn't give me the sharp edges SciPy's butterworth filter gives. But good enough for my use case.be.buch
Can you promote your update to an answer and accept it? Others have asked the same question, but I can't dupe to this question without an answer.Rob Napier

1 Answers

2
votes

For any future visitors here is the solution:

https://github.com/bartolsthoorn/NVDSP
Thanks to the answer, this library solved it.
I had to create a bridging header for Swift, but that was no big problem. Final code looks like this.

let bandpass: NVBandpassFilter = NVBandpassFilter(samplingRate: fs)
bandpass.centerFrequency = 1600.0
bandpass.q = 1.6
bandpass.filterData(&DATA, numFrames: nsamples, numChannels: 1)

The Q-Value can be calculated like that:

Q = center_frequency / (top_frequency - bottom_frequency)