Giter Site home page Giter Site logo

har-in-air / fpga_stereo_crossover Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 1.0 4.53 MB

Stereo digital 2-way crossover filters processing I2S audio (16bit or 24bit) streams

VHDL 5.93% C++ 87.77% C 6.30%
fpga esp32 crossover-filter i2s biquad-filter iir cyclone4 sipeed tang primer altera anlogic linkwitz-riley

fpga_stereo_crossover's Introduction

FPGA_STEREO_CROSSOVER

  • ESP32 reads .wav / .mp3 files on a micro-SD card and generates a I2S digital stereo audio stream (16-bit, 44.1kHz or 48kHz) as a master driving MCK, BCK and WS clocks.
  • FPGA implements an I2S slave interface and stereo 2-way crossover filters. It generates two I2S data output streams that drive low-pass and high-pass channels on two TAS5753MD stereo I2S power amplifiers.
  • Implemented in VHDL on Altera Cyclone IV EP4CE6E22 (WaveShare Cyclone CoreEP4CE6 board)
  • Also implemented in Verilog and tested on Anlogic EG4S20BG256 (Sipeed Tang Primer board)
  • Crossover filters are 4th order Linkwitz-Riley, implemented as cascaded identical 2nd order Butterworth filters. For Linkwitz-Riley filters, the sum of the low pass and high pass outputs is flat across the crossover frequency.
  • The cascaded filters do not have to be identical. There is coefficient memory storage for four unique biquad filters, so we can implement equalization if necessary.
  • Using Octave to compute 2nd order butterworth filter coefficients

  • Implementation in direct form I to avoid overflow issues, at cost of more delay element memory usage.

  • FPGA audio processing modules are clocked by the external MCK from the ESP32 board. This will vary depending on the audio source sample rate and data packaging.
  • Top level, slave SPI interface and coefficient loader modules use the on-board system clock (50MHz for the Waveshare Cyclone IV board, 24MHz for the Sipeed Tang Primer).
  • Audio samples are max 24bits. The I2S receiver can handle 16/16 and 24/32 bit packaging.
  • Filter coefficients are 40bit (4.36) 2's complement. The 4 integer bits give us some headroom for equalization, and I want to be able to use the crossover filters at lower fc/fs values, e.g. for a sub-woofer crossover at 340Hz. In this case some of the filter coefficients are small enough to benefit from the 36bits of fractional resolution.

Filter coefficients @ Fc = 3400Hz

Filter coefficients @ Fc = 340Hz

  • Altera Cyclone IV EP4CE6 resource usage

  • ESP32 calculates the biquad filter coefficients based on the sample-rate of the audio file being played and updates the FPGA via an SPI interface.

Software development platform

  • Intel Quartus Prime Lite 19.1 (Linux), for Altera FPGA
  • Arduino 1.8.13 with arduino-ESP32 1.04 package
  • Ubuntu 20.04 amdx64

Constraints

  • The FPGA modules can handle I2S 16/16 or 24/32 data packaging, with sample rate 44.1kHz or 48kHz. The ESP32 code only reads wav/mp3 files encoded with 16bit data at 44.1kHz or 48kHz.

Credits

Useful links

Prototype

Top side of prototype board

  • ESP32 breakout board
  • Micro-SD breakout board
  • KY-040 Rotary encoder with button for volume control and next track
  • LCD 1602 (ST7032) with SPI interface
  • Stacked TAS5753MD I2S power amplifier modules. Schematic and PCB layout
  • The TAS5753MD power amplifier is rated for max 26V power supply. Tested with a 19.5V 4.7A laptop power brick.

Bottom side of prototype board

  • Waveshare Core EP4CE6 FPGA development board.
  • MP2307 dc-dc module (5V supply for FPGA board, max 24V input)
  • AMS1117 LDO voltage regulator (3.3V supply for micro-SD and TAS5753MD)

Three-way speakers with 7" sub-woofer, 4" mid-woofer and ribbon tweeter.

When testing the crossover at fc = 3400Hz, the TAS5753MD amplifiers drive the mid-woofers and tweeters. The sub-woofers are disconnected.

When testing the crossover at fc = 340Hz, a passive 2-way 2nd order LC crossover circuit (fc = 3400Hz) drives the mid-woofer and tweeters. The TAS5753MD amplifiers drive the sub-woofers and LC crossover inputs.

fpga_stereo_crossover's People

Contributors

har-in-air avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

xinghuaman

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.