I am trying to use AVAudioEngine to remove offline some frequencies from an audio file. I would like to keep only the frequencies between 100 and 150 hertz.
In JavaScript I do:
var lowpass = offlineContext.createBiquadFilter();
lowpass.type = "lowpass";
lowpass.frequency.setValueAtTime(150, 0);
lowpass.Q.setValueAtTime(1, 0);
var highpass = offlineContext.createBiquadFilter();
highpass.type = "highpass";
highpass.frequency.setValueAtTime(100, 0);
highpass.Q.setValueAtTime(1, 0);
And some frequencies in the resulting audio look indeed not affected:
In Swift I am trying:
let eq = AVAudioUnitEQ(numberOfBands: 2)
engine.attach(eq)
let lowPass = eq.bands[0]
lowPass.filterType = .lowPass
lowPass.frequency = 150.0
lowPass.bypass = false
let highPass = eq.bands[1]
highPass.filterType = .highPass
highPass.frequency = 100.0
highPass.bypass = false
But looks like the compression is applied to all the frequencies. The difference between peaks and the rest is lower.
I can see that each bands has the gain
and bandwidth
but I am not sure how to use them. Would be nice to understand how these bands work. Thanks!