I am trying to use a AVAudioUnitEQ to remove some frequencies from an audio file. I only want to preserve the frequencies between 100 and 150 hertz. Using the code below looks all frequencies have been affected, some more than others, but still:
let engine = AVAudioEngine()
let player = AVAudioPlayerNode()
engine.attach(player)
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
engine.connect(player, to: eq, format: format!)
engine.connect(eq, to: engine.mainMixerNode, format: format!)
Am I doing anything wrong? How can I achieve what I need otherwise? Thanks!