## Allpass filter calculator?

**Moderator:** frank

### Allpass filter calculator?

I want to run a modified version of the linear pitch shifter program on a FV1 clocked at 40KHz. In order to retain the same frequency response from the dome filter I would need to adjust all the filter coefficients. Is there a simple formula for calculating the coefficient taking [sample rate], [number of delay samples] and [desired frequency] as parameters? I can't wrap my head around the math over in the Allpass filter wikipedia article

Link to the linear pitch shifter code for reference:

http://www.j8268.com/knowledge_base/pitch_sft.html

Link to the linear pitch shifter code for reference:

http://www.j8268.com/knowledge_base/pitch_sft.html

### Re: Allpass filter calculator?

Yes, the equations are ugly, typically an AP is specified where the given frequency has a phase shift of 180 degrees. Assuming that is how Keith did it, he did put the frequencies in the comments, you can do it by experimentation. Make a simple all-pass program, put the signal into the all pass and add it to the dry inside the FV-1, adjust the coefficient till they cancel. So you will need a function generator and scope to do this but your option is to deal with Euler's identity (e^jwT = cos(wt)+jsin(wT)) and solve the ugly equations.

Frank Thomson

Experimental Noize

Experimental Noize

### Re: Allpass filter calculator?

Hey There I just posted a thread on information about waveform generation and saw your post. I created what you want as an exel spreadsheet. If you would like to get it...go to the link below, which is my design blog.I designed it specifically to create cascaded all pass filters to phase shift a given bandwidth 90 degrees but you can adapt it to your application.

https://circuitsalad.com/2015/06/19/com ... -required/

https://circuitsalad.com/2015/06/19/com ... -required/

### Re: Allpass filter calculator?

Hey

Would be very interesting! But I can't find the exel spreadsheet calculator you mention. Just this link:

http://www.gj3rax.com/apf.htm

EDIT : Nevermind I just found it. Would the -3dB freq @ 90 deg = 1/(2*Pi*RC) where RC is the lowpass/highpass pair in the opamp allpass filter?

Is that what you are referring to? Do I understand it correctly that you have a calculator that takes the RC time constant of an analog allpass filter and produces the coefficient for a digital allpass filter (RDA/WRAP pair) for a given sample rate?

Currently looking at recreating the response of the Jurgen Haible dome filter which uses 6 cascaded allpass filters each for the sine and cosine outputs. For anyone interested the RC time constants are as follows:

Would be very interesting! But I can't find the exel spreadsheet calculator you mention. Just this link:

http://www.gj3rax.com/apf.htm

EDIT : Nevermind I just found it. Would the -3dB freq @ 90 deg = 1/(2*Pi*RC) where RC is the lowpass/highpass pair in the opamp allpass filter?

Is that what you are referring to? Do I understand it correctly that you have a calculator that takes the RC time constant of an analog allpass filter and produces the coefficient for a digital allpass filter (RDA/WRAP pair) for a given sample rate?

Currently looking at recreating the response of the Jurgen Haible dome filter which uses 6 cascaded allpass filters each for the sine and cosine outputs. For anyone interested the RC time constants are as follows:

Code: Select all

```
A1 : 29.4ms
A2 : 3.87ms
A3 : 951us
A4 : 237us
A5 : 59.1us
A6 : 13.3us
B1 : 8.47ms
B2 : 1.91ms
B3 : 475us
B4 : 118us
B5 : 29.1us
B6 : 3.83us
```

### Re: Allpass filter calculator?

With your calculator I'm getting the following relationships @ 32768 Hz samplerate. Are negative constants problematic?

Code: Select all

```
Freq W' Constant
5,4 0,000518 0,99897
41,1 0,003940 0,99215
167,4 0,016049 0,96841
671,5 0,064379 0,87903
2693 0,258188 0,58959
11966,5 1,147273 -0,06859
18,8 0,001802 0,99640
83,3 0,007986 0,98415
335,1 0,032127 0,93775
1348,8 0,129314 0,77099
5469,2 0,524353 0,31203
41554,9 3,984023 -0,59872
```

### Re: Allpass filter calculator?

Came across this chapter in the knowledge base section of the website ("Programming the FV-1"):

viewtopic.php?t=267

Will do some testing of the stability of the transposed form allpass at low frequencies and report my findings.

Edit: Below is a Transposed Form II Allpass filter using a register for the 1 sample delay. From reading Costellos comments on the topic this approach has the benefits of better coefficient resolution and less internal gain. Temp1 and temp2 can be subbed with ADCL and DACL for instance.

The need for a different approach for low frequency allpass is understandable as the necessary recursive gain would require heavy attenuation in order to avoid clipping (as seen in the "Pitch Shift Code Sample"). I wonder if the "less efficient" allpass solution could be theThe opcode set has been optimized to execute subsets of code for various common audio tasks; the all-pass filter for example, is executed by only 2 operations, but must do this from delay memory with the RDA and WRAP operations. When used in a reverb, where perhaps a dozen all-pass filters may be required, this is very efficient. If however, you wish to implement an all-pass filter with a delay of only 1 sample, the RDA/WRAP scheme could be used, but only if thecoefficients in the all-pass are not too extreme. Coding low frequency all-pass filters will require a less efficient set of operations using registers for storage.

*Transposed Direct Form II*allpass which Sean Costello mentions in this thread:viewtopic.php?t=267

Will do some testing of the stability of the transposed form allpass at low frequencies and report my findings.

Edit: Below is a Transposed Form II Allpass filter using a register for the 1 sample delay. From reading Costellos comments on the topic this approach has the benefits of better coefficient resolution and less internal gain. Temp1 and temp2 can be subbed with ADCL and DACL for instance.

Code: Select all

```
rdax temp1, -k
rdax ap1, 1
wrax temp2, k
rdax temp1, 1
wrax ap1, 0
```

### Re: Allpass filter calculator?

OK so my experience with this so far is that the Transposed Form II allpass filters oscillate way easier, thus requiring even more downscaling in order to yield stable operation. I'm a bit puzzled by this, but can't find any clear errors in the filter implementation.

I'll be sticking with the RDA/WRAP approach for now. Sorry for the rambling monologue-thread

I'll be sticking with the RDA/WRAP approach for now. Sorry for the rambling monologue-thread

### Re: Allpass filter calculator?

Hey

sorry about the late response...First negative coefficients mean your sampling rate is too low. I use 48 KHz for my stuff.

With regard to relating RC values to coefficients, What I am about to state I am just saying to clarify(you may understand all of this)The worksheet is intended to have two broadband chains of allpass filters, providing 90deg of total phase shift between two signals. Each chain contributes 45 deg over the frequency range of interest for each signal path.

In the analog form you would choose a set of three(or more) frequency points that will overlap the responses to maximise uniformity in phase response over a range. The RC values are chosen such that XC = R at the frequency point chosen for a given stage. The XC = R is the point where gain is down 3dB(power) or 6dB (voltage). It is also the frequency where the phase shift is 45 deg. My spreadsheet has you input the frequency desired for the 45 deg shift point. Working backwards if you had a stage with RC values of 174k and 10nF. the XC would equal 10k at 91.5Hz.... where F = 1/2PiRC

added note: a single pole RC filter only gets to 90 deg phase shift for low pass as frequency goes to infinity and as frequency goes to 0 for high pass. The 3dB point of attenuation is the point where there is 45 deg phase shift

does this help?

sorry about the late response...First negative coefficients mean your sampling rate is too low. I use 48 KHz for my stuff.

With regard to relating RC values to coefficients, What I am about to state I am just saying to clarify(you may understand all of this)The worksheet is intended to have two broadband chains of allpass filters, providing 90deg of total phase shift between two signals. Each chain contributes 45 deg over the frequency range of interest for each signal path.

In the analog form you would choose a set of three(or more) frequency points that will overlap the responses to maximise uniformity in phase response over a range. The RC values are chosen such that XC = R at the frequency point chosen for a given stage. The XC = R is the point where gain is down 3dB(power) or 6dB (voltage). It is also the frequency where the phase shift is 45 deg. My spreadsheet has you input the frequency desired for the 45 deg shift point. Working backwards if you had a stage with RC values of 174k and 10nF. the XC would equal 10k at 91.5Hz.... where F = 1/2PiRC

added note: a single pole RC filter only gets to 90 deg phase shift for low pass as frequency goes to infinity and as frequency goes to 0 for high pass. The 3dB point of attenuation is the point where there is 45 deg phase shift

does this help?

### Re: Allpass filter calculator?

Yes that is how I went about setting the APF coefficients. Thanks so much for the tool/calculator! I found that the system would way too easily start self-oscillating for filters with very low shift frequencies (big coefficients). This regardless of what APF type used.RRing wrote: ↑Sun Sep 13, 2020 7:35 amIn the analog form you would choose a set of three(or more) frequency points that will overlap the responses to maximise uniformity in phase response over a range. The RC values are chosen such that XC = R at the frequency point chosen for a given stage. The XC = R is the point where gain is down 3dB(power) or 6dB (voltage). It is also the frequency where the phase shift is 45 deg. My spreadsheet has you input the frequency desired for the 45 deg shift point. Working backwards if you had a stage with RC values of 174k and 10nF. the XC would equal 10k at 91.5Hz.... where F = 1/2PiRC

does this help?