Re: CoreAudio and equalization
Re: CoreAudio and equalization
- Subject: Re: CoreAudio and equalization
- From: Steve Bird <email@hidden>
- Date: Wed, 26 Jun 2002 20:31:57 -0400
On Wednesday, June 26, 2002, at 07:44 PM, john wrote:
Hello,
I'm not sure if this is appropriate for the typical type of question on
this list, so forgive if it is not.
I'm trying to alter the audio data given in the recordIOProc in the
frequency domain. The code does an FFT transform (using Don Cross's
source), then uses this:
// 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;
Now doing this causes there to be static/fuzz in the audio. Looking
around on the web I see that a windowing function may be needed to
"smooth the edges" between alterations to the data in the frequency
domain.
However, using the hamming window (or hanning or blackman) even without
the EQ modifications causes the audio to sound weird!
Does anyone have any experience with this stuff that could help? Thanks!
IF
you do an FFT on a data block of size N
AND
the signal is not periodic with respect to N, i.e. the head (sample
0) and the tail (sample N-1) do not match.
THEN
the FFT will show high-frequency artifacts, due to the head-tail
"transition" (FFT assumes periodicity between head and tail)
BUT
an inverse FFT of that spectrum will reproduce the exact same data
block.
SO
if you're doing simple multipliers, this has no effect on you.
BECAUSE
you are not changing the relative amplitudes by multiplying by a
constant "decAjustment.
THINGS TO CHECK:
1... Are you converting the spectrum back into time-domain (inverse FFT)?
Listening to a spectrum is not pretty.
2... Are you sure about that ATAN2 call? IIRC, it's atan2(y,x) in your
case, that's atan2 (v, z) Reverse those arguments and you get a garbage
angle.
3... Why are you converting from rectangular (real & imag) to polar (mag &
angle) and back just to multiply??? It's easier (not to mention faster)
to multiply real[i] * gain and imag[i] * gain.
4... If "decAdjustment" is a constant, you have a simple amplifier (you
don't need to do FFTs for that). If you move to a freq-dependent
adjustment, there might be issues relating to connections between blocks.
----------------------------------------------------------------
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175
_______________________________________________
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.