6

The only effect AudioUnit on iOS is the "iTunes EQ", which only lets you use EQ pre-sets. I would like to use a customized eq in my audio graph

I came across this question on the subject and saw an answer suggesting using this DSP code in the render callback. This looks promising and people seem to be using this effectively on various platforms. However, my implementation has a ton of noise even with a flat eq.

Here's my 20 line integration into the "MixerHostAudio" class of Apple's "MixerHost" example application (all in one commit):

https://github.com/tassock/mixerhost/commit/4b8b87028bfffe352ed67609f747858059a3e89b

Any ideas on how I could get this working? Any other strategies for integrating an EQ?

Edit: Here's an example of the distortion I'm experiencing (with the eq flat): http://www.youtube.com/watch?v=W_6JaNUvUjA

Community
  • 1
  • 1
tassock
  • 1,633
  • 1
  • 17
  • 32
  • 1
    Noise can be caused by many reasons - numerical instability, wrong arithmetic, wrong buffer read/write... Did you try to implement a 'do nothing' EQ, just copy input to output? (that's not the same as a flat EQ) – Itamar Katz Mar 16 '11 at 09:36
  • Thanks for the suggestion. I tried returning the given sample from EQ3Band's "do_3band" method and got a sound without distortion. This must mean the noise originates from do_3band's logic, no? Here's what EQ3Band looks like: https://github.com/tassock/mixerhost/blob/master/Classes/EQ3Band.c – tassock Mar 18 '11 at 18:19
  • As a professional audio producer I can tell you that the problem you seems to have is with the stream buffer, however, I couldn't find any issue on my setup (macpro, rme fireface400, iPhone 3GS). – EladG Oct 20 '11 at 06:29

2 Answers2

0

In the code in EQ3Band.c, the filter coefficients are used without being initialized. The init_3band_state method initialize just the gains and frequencies, but the coefficients themselves - es->f1p0 etc. are not initialized, and therefore contain some garbage values. That might be the reason for the bad output.

Itamar Katz
  • 9,544
  • 5
  • 42
  • 74
  • Good point, thanks for the suggestion. Unfortunately, I'm still having bad output after ensuring my filter coefficients are not being set to garbage values: https://github.com/tassock/mixerhost/commit/d24a671ed079c8ef5902c59877dc13f54db351a2 – tassock Mar 20 '11 at 17:57
0

This code seems wrong in more then one way.

A digital filter is normally represented by the filter coefficients, which are constant, the filter inner state history (since in most cases the output depends on history) and the filter topology, which is the arithmetic used to calculate the output given the input and the filter (coeffs + state history). In most cases, and of course when filtering audio data, you expect to get 0's at the output if you feed 0's to the input.

The problems in the code you linked to:

  • The filter coefficients are changed in each call to the processing method:

    es->f1p0 += (es->lf * (sample - es->f1p0)) + vsa;

  • The input sample is usually multiplied by the filter coefficients, not added to them. It doesn't make any physical sense - the sample and the filter coeffs don't even have the same physical units.

  • If you feed in 0's, you do not get 0's at the output, just some values which do not make any sense.

I suggest you look for another code - the other option is debugging it, and it would be harder.

In addition, you'd benefit from reading about digital filters:

http://en.wikipedia.org/wiki/Digital_filter

https://ccrma.stanford.edu/~jos/filters/

Community
  • 1
  • 1
Itamar Katz
  • 9,544
  • 5
  • 42
  • 74