Active crossovers are a popular diyAudio topic, however only a few hobbyists managed to build a home-brew digital crossover on a kitchen table, for less than $99 all inclusive, software included.
This is going to change with the recent arrival of the PIC32MX1/MX2 family (twin I2S), and the NXP LPC4330 (twin I2S and possibly more through the SGPIO). I2S stands for Inter-IC Sound, Integrated Interchip Sound, or IIS. This is different from SPI and I2C. I2S is a 20 year-old standard, still widely in use, for connecting a µC on an audio ADC, DAC or Codec. On top of this, the PIC32 and ARM Cortex chips feature a fast 32-bit x 32-bit multiplier delivering a 64-bit result. This enables computing audio with a 192 dB dynamic range, about 50 dB more than the best available ADCs and DACs. Quite a headroom would you say.
The PIC32MX1/MX2 has Flash memory and runs at 40 MHz. This is a nice single chip µC, easy to use. Like all PIC32 chips, there is a MIPS M4K core inside, 32-bit of course. The PIC32MX1/MX2 is fully supported by Microchip MPLAB ICD3 programmer and debugger. Call it a one-stop-shop solution. The PIC32MX1/MX2 is a nice recent addition (early 2012) to a mature µC architecture. We need experimenting with the PIC32MX1/MX2 in first place. Back in 2008 most µC programmers got intimidated by 32-bit µC, thinking they were expensive, complex, requiring C for programming, and always short of RAM with Linux as background. Lucio Di Jasio from Microchip did a great job in optimally introducing the PIC32 to people having started their carrier more than 25 years ago, writing firmware for 8-bit µC like the Intel MCS51 one-chips or Motorola 68K CPUs back in those times.
Lucio Di Jasio showed that a 32-bit µC doesn’t require Linux. He showed that a 32-bit µC like the PIC32 supports and benefits from assembly-coded software. What made the PIC32′s life difficult, is the internal competition from Microchip dsPICs (16-bit) good for hard disks and motor control, however insufficient for quality audio where 24-bit is considered as the bare minimum.
The MIPS M4K core retains advantages over the ARM Cortex-M0 and Cortex-M3 cores, especially the shadow register enabling ultra-fast context switches. The peripheral set of the newly introduced PIC32MX1/MX2 features a pin multiplex scheme and twin I2S. ARM reacted on this, introducing the ARM Cortex-M4 (one year before the PIC32MX1/MX2) and Cortex-M0 Plus (not yet launched). Google is currently working for enabling Android Tablets equipped with the MIPS architecture, instead of being equipped with the ARM architecture.
Aren’t supposed we to deal about audio crossovers here ? Why am I disserting so long about microcontrollers ? Well, here is a friendly advice. If you feel no pleasure in dealing with all this, you better buy a miniDSP stereo 2-way XO for $99 plus software. This is an effective solution, however limited in flexibility. With miniDSP, flexibility will never be total as miniDSP business owners need to make money on the application software. Do not expect miniDSP to give away the keys for writing your own audio DSP software. Do not expect miniDSP to entertain you by telling you absolutely everything they do inside the chip.
They could do it by allowing people to publish miniDSP applications on a miniDSP app store, like in the Apple App Store. Or Android Play Store. In such case they’ll need to pay you a 70% commission on each download, and retain the remaining 30%. Deal ? Don’t know if it will come. Could be they are running a bulk-licenced version of Analog Devices SigmaStudio Graphical Development Tool.
If this is the case, why don’t they allow to graphically draw a signal flow, compile it, and get it running on the ADAU14xx chip ? Is that too good for DIY Audio ?
What the world needs now, is a smart solution for graphically designing a signal flow on LTspiceIV, and get it executed by a PIC32MX1/MX2.
So, what’s an Audio crossover ? Let’s ask Russ Riley and Siegfried Linkwitz.
They got famous in 1976, publishing an industry-changing communication in the Journal of Audio Engineering Society.
You can expect solid conclusions from HP people. Actually it started as a hobby for Siegfried H. Linkwitz, dismantling multiway speakers in order to explain why most were ill-sounding at home, especially off-axis, incredibly dependent of the listening room ceiling or floor acoustic qualities. It became scientific when Russ Riley, his colleague at HP, came with maths about phase shifting, not the global phase shift which is considered to remain inaudible, but the inter-driver relative phase shift which is governing the polar radiation diagram. This explains how and why at certain frequencies, the main lobe angle may become offset and irregular. At certain frequencies, you’re not listening at your speakers anymore. You’re listening at your (hard or soft) ceiling (or floor), bouncing the sound back to you.
The 1976 Linkwitz AES publication delivers important conclusions.
There will be no relative phase shifts if the lowpass and highpass functions are each, a Butterworth (LR2) or double Butterworths (LR4, LR6, LR8 etc). On his personal website, Siegfried H. Linkwitz allows us to read the corresponding table:
Make sure you read the footnote. As per today, Siegfried H. Linkwitz remains careful and doesn’t recommend high-order LR crossovers because of the increased global phase distortion. Which means that over time, an audio expert of his stature is maintaining a preference for linear-phase systems, even if it is generally believed that phase distortion can’t be heard.
In a nutshell, he is advising the LR2 and the LR4.
A LR2 XO consits on a Butterworth lowpass and a Butterworth highpass, not forgetting to inverse the polarity of the tweeter.
A LR4 Xo consists on two Butterworth lowpass in series for the lowpass, and two Butterworth highpass in series for the highpass, without needing to fiddle with the tweeter polarity.
Designing My First LR4 XO
Let us implement a LR4 XO by cascading DF2 (Direct Form II) 2nd-order IIRs (also known as BiQuads).
We thus created the delay line, as subcircuit, to be used in each DF2 subcircuit.
Note the checkpoint in DF2 sub-circuit. It allows us to check the amplification caused by the resonant part of the BiQuad. This way we know if saturation occurs for a 0 dB input signal level.
Such DF2 subcircuit to be used this way in the LR4 XO schematic.
This is a mono 2-way DF2 LR4 XO @ 3400 Hz running on the PIC32MX2 Breakout Board and mikroE WM8731 Codec Board. Why 3400 Hz ? Because the subcircuit instances got loaded with the corresponding coefficients. We got them from the RBJ Cookbook, translated on an Excel spreadsheet.
Pay attention to the numeric format. LTspice needs a dot decimal point, why french-speaking Excel delivers a comma. Let’s run an .ac (sweep) analysis and plot the Magnitudes using LTspice.
Looks nice, as expected. The crossover frequency is accurate, the crossing occurs at a -6 dB amplitude (proof that there is no relative phase shift), and both slopes are 24 dB per octave. What about the DF2 issues, like saturation ? Need to investigate the checkpoint within the DF2 sub-circuit. LTspice enables this. Need to check the box entitled Save Subcircuit Node Voltage.
Here are the complete results, accessing the checkpoint, and graphing the outputs sum.
Looks good : the sum of the two outputs is flat in magnitude.
Looks good : the lowpass and the highpass exhibit the exact same phase response. Actually this is the group delay, not the phase, and as Siegfried mentioned, there is a significant bump around the crossover frequency. This is thus conform.
Now the bad news, and this isn’t Linkwitz fault. We face saturation, as the red curve shows. This is DF2 checkpoint. There is a gain over there, approx. 16 dB. The circuit cannot handle a signal stronger than -16 dB. The fix is to put a digital 16 dB attenuation at the XO input, and a 16 dB digital amplification just before the XO output. This is not a practical issue on a 32-bit system like the PIC32, providing a digital dynamic range of 192 dB. After the waste, there will remain a digital dynamic range of 176 dB, a highly respectable value beating any audio ADC or DAC by at least 30 dB. Most designers would set the digital attenuation to 1/256 (shift by 8 bits) for guaranteeing a 24-bit resolution (144 dB dynamic range) with 48 dB on top of this, allocated to the internal DF2 checkpoint gains.
The Corresponding SPICE Netlist
Let’s have a look to the SPICE netlist corresponding to the above LTspice schematic.
Only four lines to process.
One need to remember this is a netlist, not a signal flow. The information gets sorted on the blocks.
There are only four main blocks XX1 to XX4. The other lines define the subcircuit prototypes. In a simple application like we are targeting, not multi-level schematic, we only need to read the names of the 1st-level subcircuit. In lines 1 to 4 it is explicitely written that XX1 to XX4 are DF2v instances. For each instance we have the associated parameters. These are the IIR coefficients.
The only intelligence to deploy for interpreting those four lines, is about the interconnect. What’s an input, what’s an output. The parser would start locating all the occurrences of mike_in (we know by advance this is the only physical input) for knowing what to connect on. Here there are two occurrences : XX1 and XX3 respectively outputting N001 and N002. Those are two different nets. Let’s concentrate on N001 first. Same game as above : let’s determine the elements connected on N001. We get XX2. And it reads that XX2 has left_phones_out connected at its output (we know by advance this is a physical output). Job done. Let’s continue with N002. Same game, this time it is about XX4 delivering the right_phones_out. Job done.
Refining the LR4 XO
Basing on this, it would be feasible to edit the schematic, add the input attenuator, add the output amplifier, add two or four DF2 stages for making a LR6 or LR8 XO, and get the DSP code automatically compiled for the PIC32MX2. There could be delay lines added for time-aligning the speaker drivers. There could be more DF2 added for linearizing each speaker driver acoustic response. For better linearizing the drivers phases, there could be FIRs needed.
Experimenting Without Programming Allows More
Now you start understanding why a DIY Audio XO must rely on a graphical audio DSP compiler. Everybody having played with subwoofers, multiway speakers, speaker cabinet design and crossover knows that the above curves are meant to be acoustic curves. You need to be LR2 or LR4 at the acoustic level. Consequently, at the electric level, due to box resonance, highpass cutoff, baffle step, cone resonance, cone breakup etc you need to equalize each speaker driver. The many DF2 you’ll stack over there are not going to be simple lowpass or highpass. There will be shelving correctors, controlled notches, phase shapers (allpass), delay lines, etc. Clever Math will be needed, optimally combining the linearizing transfer function with the required LR2 or LR4 transfer function, for minimizing the correction gains. Combining a few DF2 followed by a 32-tap FIR may bring more flexibility. Philips did it in 1993 (about 20 years ago) with the DSS930 series. They added a progressive highpass filter driven by the volume setting, for protecting the bass speaker.
Time to experiment all this in a structured form, at a do-it-yourself cost.
Any diyAudio design, especially digital, is by definition shareware, tweakware and blogware.