IPhone aurioTouch example: remove DC

I am considering the iPhone aurioTouch example specifically for the following code:

static OSStatus PerformThru( void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) { aurioTouchAppDelegate *THIS = (aurioTouchAppDelegate *)inRefCon; OSStatus err = AudioUnitRender(THIS->rioUnit, ioActionFlags, inTimeStamp, 1, inNumberFrames, ioData); if (err) { printf("PerformThru: error %d\n", (int)err); return err; } // Remove DC component for(UInt32 i = 0; i < ioData->mNumberBuffers; ++i) THIS->dcFilter[i].InplaceFilter((SInt32*)(ioData->mBuffers[i].mData), inNumberFrames, 1); // ... } 

in the aurioTouchAppDelegate.mm file.

Beginner question: what does the "Remove DC component" do? Any pointer to a training article about this is welcome.

Thanks in advance for your help.

+6
iphone audio
source share
2 answers

Here is the code for the InplaceFilter method:

 void DCRejectionFilter::InplaceFilter(SInt32* ioData, UInt32 numFrames, UInt32 strides) { register SInt32 y1 = mY1, x1 = mX1; for (UInt32 i=0; i < numFrames; i++) { register SInt32 x0, y0; x0 = ioData[i*strides]; y0 = smul32by16(y1, mA1); y1 = smulAdd32by16(x0 - x1, mGain, y0) << 1; ioData[i*strides] = y1; x1 = x0; } mY1 = y1; mX1 = x1; } 

Basically, the code makes a high-pass filter on audio to remove the DC component of the frequency spectrum, which is also referred to as DC offset . The coefficient (alpha in the wikipedia article) for the filter is set by default in the code to 0.975, and typical values ​​for DC removal filters range from 0.9 to 1.0. If you adjust the sampling rate, you can adjust this factor, but I would not worry too much about it.

+8
source share

The DC Deviation Filter here is a high-pass filter. In electrical engineering, a high-pass filter is implemented as an RC circuit, which allows only high-frequency waves to be transmitted. Each high-pass filter has a cutoff frequency, defined as the frequency with which the output energy is -3 dB from the input energy.

The InPlaceFilter method is a digital implementation of the temporary high-pass filter domain. The digital implementation completely organizes all the samples and adjusts the current output based on the previous output. In this implementation, the constant variable alpha is used, the value of which is between 0 and 1. The cutoff frequency of your high-pass filter depends on the value you selected for Alpha (as well as the sampling frequency). Since in AurioTouch, the sampling frequency is 44 thousand. The cutoff frequency can be calculated at about 160 Hz. (note that this does not mean that you are not getting frequencies below 160 Hz. It just means that the energy coming out from frequencies below this frequency is much lower than higher).

I wrote a detailed explanation here http://timdotshi.blogspot.ca/2014/01/dc-rejection-filter-in-objective-c.html .

+2
source share

All Articles