Skip to content

Repository files navigation

FPGA Audio Processor

A real-time stereo audio effects processor implemented in SystemVerilog for the Terasic DE1-SoC FPGA. The design takes stereo audio from the board's audio codec, processes each sample through a configurable set of hardware effects, and sends the processed audio back to the codec. Effects are controlled using the DE1-SoC switches, while the red LEDs are used as a VU meter for the incoming audio level.

The project targets the Cyclone V 5CSEMA5F31C6 and includes the Quartus project, audio codec interface, simulation testbenches, and scripts for testing the processor with WAV files.

Effects

  • Mute silences both audio channels.
  • Distortion applies nonlinear clipping/compression with two selectable threshold levels.
  • Echo adds delayed feedback to the audio signal.
  • Pitch Shifter changes the pitch of the incoming audio.
  • Vinyl adds noise and occasional pops/crackle to simulate a vinyl record.
  • VU Meter displays the incoming audio level using the DE1-SoC's red LEDs.

Controls

Control Function
SW[0] Master mute
SW[1] Enable distortion
SW[2] Select distortion threshold
SW[3] Enable echo
SW[4] Enable pitch shifting
SW[7:5] Select pitch ratio
SW[8] Enable vinyl effect
SW[9] Unused
KEY[0] Reset

The pitch ratios selected by SW[7:5] are:

SW[7:5] Ratio
000 0.50x
001 0.75x
010 1.00x
011 1.25x
100 1.33x
101 1.50x
110 1.75x
111 2.00x

Usage

You will need a Terasic DE1-SoC, Intel Quartus Prime, an audio source, headphones or speakers, and a USB-Blaster connection for programming the FPGA.

Clone the repository:

git clone https://github.com/tandr3w/fpga-audio-processor.git
cd fpga-audio-processor

Open IC_Hackathon_Audio.qpf in Quartus Prime, compile the project, and program the DE1-SoC using the generated programming file.

Connect an audio source to the board's audio input and headphones or speakers to the audio output. The switches can then be used to enable and combine the different effects in real time.

Testing

The main automated testbench is test/tb.sv. It feeds stereo audio samples into the design, changes the effect controls, and checks that the resulting output matches the expected behavior.

The tests cover clean audio passthrough, mute, positive and negative distortion, echo, vinyl noise, combined effects, maximum and minimum 32-bit sample values, zero-valued samples, effect switching, independent left/right processing, sequential samples, and unused switch behavior.

The test suite is run automatically through GitHub Actions on pushes to main and on pull requests. The simulation generates a VCD waveform at:

sim_out/wave.vcd

The GitHub Actions workflow also stores simulation artifacts under .github/outputs/, including:

sim.log
wave.vcd
wave.json
wave.svg

The VCD waveform can be opened in a waveform viewer such as GTKWave or Surfer to inspect the signals produced during the test suite.

Testing with WAV Files

test/quartus_tb.sv can be used to process real audio files through simulation. The helper script scripts/audio_converter.py converts WAV files into the hexadecimal sample format used by the testbench and converts the processed samples back into audio afterward.

Install the Python dependencies:

python3 -m pip install numpy scipy

Place an input file at scripts/test_input.wav and convert it with:

python3 scripts/audio_converter.py w2h

This generates scripts/input.txt, containing the audio samples used by the simulation. Run test/quartus_tb.sv in the Quartus/Questa simulation environment, changing the effect switches in the testbench to select the effects you want to apply.

The simulation writes the processed samples to:

scripts/output.txt

Convert them back into a WAV file with:

python3 scripts/audio_converter.py h2w

The processed audio is written to:

scripts/processed_output.wav

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages