I guess this thread is here as the Blogs remain inactive. But I also suspect there may be a few of the more hardcore set who think that hacking our C code for an audio DSP makes sense...
Well I did, so that makes at least one of us (me)!
The current version of this crossover is solid and stable, but I haven't thrown in some of the more crazy bells and whistles that a "roll your own" in software allows.
The thing looks like this:
By my standards, tidy enough that I am happy - but not a thing of beuaty and wonder.
What is it? What is going on in that box?
The heart of the thing is the PIC32MZ2048:
This is a generic PIC32MZ pcb that I use for all my projects. It comprises the PIC32, EEPROM, regs and headers for LCD and general I/O.
Running this 2 way crossover with 4th order slopes, and two parametric EQ's the memort is like 5%, RAM 7% and CPU load about 40% from what I see at 49,218ksps.
Huh? 49,218...
The reason for this is that this is an integer divisor of the 252MHz PIC clock, meaning the MCLK and LRCLK and BCLK are all nicely locked together without jitter.
In an embedded DSP, sticking to "normal" clock rates might look nice when you write the number down, but is actually meaningless. Unless you want to process digital data from external. Then I'd need to do a SRC... This clock rate works really nicely for the hardware...
The DSP has two "things" going on:
- The entire SPI read, DSP processing and SPI output occurs in an ISR that is triggered by the SPI buffer being half empty. Meaning this is rock steady on timing for keeping the SPI full for / from the ADC and DACS.
- The user interface is run when the ISR is not keeping things busy...
Other things in the box are the power supply and header breakout for the ADC and DACS...
Not a lot to say here, supplies power and stops cables getting too out of control. Again I sent this PCB off to the fab, as I tend to do a bunch of audio stuff from the PIC, eg my signal generator uses this, as does my PC based distortion meter.
The ADC plugs onto the power supply PCB. Samples data rns across the ribbon cable (every second wire earth) to the power supply board, then back to the PIC.
The PIc sends SPI / I2S to the DACS, two of them in this case, again via the power supply PCB.
The user interface is on a 128 by 64 LCD, and is about as pretty as an engineer is likely to make it...
Volume control, with bar graph. In this case I am doing volume digitally. The tests I did against analogue volume chips showed that a CS4398 generates less distortion (if you can measure either of them). Its not that the analog chips are bad, but that the CS4398 is really good!
If you look on the right you might see the unloaded spot for the volume chips...
Save,Load config, Set up crossover, PArametrics.

Select crossover slopes etc.
And delay.
The parametric is similar, choose your CF, Q and gain and off you go.
Things I ponder adding are compressors, limiters and suchlike. These would be a complete doddle to add, as it really is just peak tracking and comparisons - but the audiophile in me always stops me at the last minute.
With about 60% processing spare, I could add an extra channel or two, or a bunch more parametrics.
All audio processing in this is:
- 24 bit SPI / I2S in and out
- Converted to 32 bit data
- With 64 bit accumulator for all DSP functions which is shifted back to 32 bit for storage
By doing all this in integer things really click along, so there is great lattitude for other things. I am pondering effects eg for guitar.
This is all coded in C32, microchips free compiler, which at times frustrates the hell out of me. I am not really a programmer so relearn every time I do these things, and their documentation is - lets say - complicated.
So whats it cost me?
- The PICS cost less than a burger
- The breakout board has more in value in LM317s than the PIC I suspect...
- The ADC and DAC are the expensive bits...
- CS4398's are probably US$10
- CS5381 are a touch expensive, I have lots of these as I was using them for my distortion meter. Perhaps a CS5361 at US$10ish would be more sensible - their performance is not far off the CS5381.
As you can see those boards are home made - the input and output op amps are either NE5532 or LM4562, which in this implementation I cannot tell the difference between even using fancy test gear.
All up this is probably $200 of stuff from my shelves, and a ton of time.
If you would like to play with this, or the code, feel free to drop a line and I can copy it to you.
By the way, the code is close on identical to the code that controls my ADAU DSP crossover, but the DSP ISR (plus SPI/I2S interface) replaces the external ADAU chip...