ΣSigmaStudio Ask AI Русский Log in

1st order All Pass Filter formula for phase adjustment

SigmaDSP & SigmaStudio Davids Jan 10, 2023 00:00 6 replies Original on forum ↗
Thread Summary

Thread Summary

The user sought a formula for a 1st order all-pass filter to achieve precise phase adjustments. The final answer provided the formula for phase lag p = 2 arctan(f/fo) and how to calculate the cutoff frequency fo = f / tan(p/2) for a desired phase shift. The user successfully implemented this in their code and verified it in Sigma Studio. The user also asked about achieving specific phase shifts like 15 or 30 degrees, which can be done using the same formula. The applicability to second-order all-pass filters and achieving a full 0° to 360° phase lag across the sound field was questioned but not addressed in the final answer.
AI Generated Content
Subscribe
Davids Question
Jan 10, 2023 00:00

Hello,

Since I want to use 1st order All Pass Filter to build the adjustable phase function,

the old post has the other way to get 0/90/180/270 degree, but what I want is more precisely so I search the forum, the 1st order all pass filter will generate the 90 degree phase change, if I want 180 degree, I only cascade two block to get the answer.

I refer the KJBob calculation excel, but I don't see the all pass filter 1st order formula.

If I want to use IIR block to implement the adjustable phase(frequency by frequency adjust) by the 1st order all pass filter, I need to know how to calculate it.

Anyone can help me? What is the correct formula for the 1st order all pass filter?

Thank you!

Alvis.

Audio Signal Processors

software

microcontroller

1st order all pass filter

SigmaDSP Audio Processors

adau1761

4.6

phase

Show More

KJBob Reply
Jan 15, 2023 00:00

Hello Alvis,

It's been a long time since I've been on, since nowadays most all the questions here go over my head. Yet since you kindly mentioned me, I'll try to help.

The attached spreadsheet has the First Order All-Pass Filter coefficients added. I also reworked the order and name of the coefficients to match SigmaStudio's nomenclature as seen in the IIR Coefficient type-in box. As always, flip the signs of the A coefficients when loading them into your DSP. I made the example below by entering 1 KHz as the filter's "cutoff" frequency into the spreadsheet, then typing the resulting coefficients into the General Second-Order IIR Coefficient filter (setting its B2 and A2 coefficients to zero makes it first-order):

The revised spreadsheet is attached.

5811.1st-2nd-Order_IIR_Coefficient_Calculator.zip

Best regards,

Bob

First-Order-IIR-Coeiff_sch.png
First-Order-IIR-Coeiff_sch.png
Davids Reply
Jan 15, 2023 00:00

Hello Bob,

Thank you for your kindly reply!!

This spreadsheet really help me a lot!!

I will try and integrate in to mine code!

Thank you again!

Best Regards,

Alvis.

Davids Reply
Jan 16, 2023 00:00

Hello KJBob ,

The all pass filter formula really help me a lot!

I have another question, if I want to use 1st order all pass filter to get other degree phase adjustment, how should I do?

Like 15 or 30 degree with 1st order all pass filter, does it have another formula for the 1st order all pass filter?

Regards,

Alvis.

KJBob Reply
Jan 16, 2023 00:00

Hello Alvis,

As you can see from the response graph above, the filter's phase shift varies with frequency. The formula for calculating the phase lag p of a first-order allpass filter of cutoff frequency fo with an input of frequency f is:

p = 2 arctan (f/fo)

To design a filter that gives a desired phase lag p at frequency f, we can work this formula backwards and obtain the needed fo for this filter:

fo = f / tan (p/2) Note: the tangent function needs to match your units (degrees or radians)

For example, to get a filter having a phase lag of 30 degrees at 100 Hz, make this filter:

fo = 100 / tan (30/2) = 373.21 Hz

Once you have fo, use the spreadsheet formulas to get your coefficients.

Best regards,

Bob

Davids Reply
Jan 17, 2023 00:00

Hello Bob,

Thank you!

I have add the formula into the spreadsheet and verify in sigma studio, it works perfectly!!

Thank you again!

Regards,

Alvis.

chenxuezong509@126.com Reply
Jun 29, 2023 00:00

Hello Bob,

Is your above algorithm also applicable to the second-order All-pass filter?

Can the All-pass filter make the signal phase of the whole sound field lag (0 °~360 °)?

Best regards,

Gavin