4

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:

enter image description here

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.

enter image description here

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!

Nuthinking
  • 1,211
  • 2
  • 13
  • 32

0 Answers0