• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CoreAudio and equalization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreAudio and equalization


  • Subject: Re: CoreAudio and equalization
  • From: Paul Russell <email@hidden>
  • Date: Wed, 26 Jun 2002 22:13:18 -0700

// in a loop the size of the buffer using i

z = realBuffer[i];
v = imagBuffer[i];

// calculate decAdjustment here

intensity = sqrt(z * z + v * v);
thetaValue = (z == 0.0) ? 0.0 : atan2(z, v);

intensity *= decAdjustment;
z = intensity * cos(thetaValue);
v = intensity * sin(thetaValue);

realBuffer[i] = z;
imagBuffer[i] = v;


In addition to the issue of having to do overlap-add or overlap-save, appropriate zero padding, windowing, etc, there's a big inefficiency in the code above where you are multiplying the complex FFT bins by a real scalar amplitude. There is no need to extract the phase using atan, only to convert it back to real/imaginary components using cos and sin. You can just scale the real and imaginary components by decAdjustment directly, i.e. the above code can be reduced to just two lines:

realBuffer[i] *= decAdjustment;
imagBuffer[i] *= decAdjustment;

which equates to 2 loads, 2 multiplies and 2 stores, compared with 3 very expensive function calls and a bunch of other unnecessary stuff in the original code.

Good luck,

Paul

--
| Paul Russell email@hidden |
| ARC Software Ltd http://www.arc-software.com |
| Santa Cruz, CA |
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

References: 
 >CoreAudio and equalization (From: john <email@hidden>)

  • Prev by Date: Re: CoreAudio rewrite of SndPlayDoubleBuffer
  • Next by Date: Re: Gain difference from Mac OS 9 to Mac OS X
  • Previous by thread: Re: CoreAudio and equalization
  • Next by thread: Re: CoreAudio and equalization
  • Index(es):
    • Date
    • Thread