Example Code

myRIO Equilizer: How to Acquire and Process Audio Waveforms

Code and Documents

Attachment

myAudioEquilizer.

This myRIO application is a simple, 3-band audio equalizer. It allows you to control the amplitude of bass, midtone and treble components from any audio track.

myRIO Real Time Audio Streaming and Processing.JPG

PRIMARY GOAL: Models of Computation

The primary aim of this demo is to showcase LabVIEW’s support for multiple programming interfaces. This simple graphic equaliser performs audio filtering using either...

  • G (native graphical programming in LabVIEW)
  • MathScript (textual mathematics using the MathScript node)

...this application allows you to quickly switch between filters implemented using these two different models of computation. The processed waveform is the same, regardless of which approach you select.

Block Diagram.jpg

Although we have implemented the same processing algorithms using two different programming interfaces, by using LabVIEW the ability to interact with the real world (and deploy to embedded processors) is clean and simple.

SECONDARY GOAL: FPGA for Audio Streaming

The default FPGA personality used with myRIO supports point-by-point data acquisition. While this is perfect for many applications, certain projects (such as audio processing applications) require waveform acquisition. This project uses a custom FPGA VI (and several DMA channels) to handle the streaming of left/right audio waveforms to/from the myRIO’s real-time processor.

I have also created some easy-to-use functions (subVIs) for controlling and interacting with this custom FPGA – meaning that you should be able to reuse this code for your own audio processing projects!

The Custom FPGA VI

Capture.JPG

REQUIREMENTS

  • LabVIEW 2013
    • LabVIEW Real Time
    • LabVIEW FPGA
    • MathScript RT
  • myRIO (software and hardware)

OPERATING INSTRUCTIONS

  1. Download attached zip file and extract contents
  2. Open RT Audio Filter.lvproj
  3. Right-click the myRIO target within the project, and select Properties. Ensure that the IP address matches your myRIO.
  4. Open RT Audio Filter.vi from the project
  5. Ensure that you have an audio source (laptop, microphone, mp3 player, smart phone) connected to the myRIO’s audio input. Also ensure that you have connected a loud speaker or headphones to the myRIO’s audio output
  6. Click run (the code should now depluy to your myRIO)
  7. NOTE: At this point, you may need to recompile the FPGA code the first time you run this application.
  8. Adjust the Bass/Midtone/Treble sliders and notice the music and spectral graph updates accordingly (note: the red plot is the raw audio spectrum... the blue plot is the filtered/processed audio spectrum)
  9. Switch to the block diagram. Notice that the filtering is implemented using LabVIEW’s out-of-the-box filter functions AND a MathScript node.
  10. Click the Mode Select button to change the implementation of the filtering.
  11. Notice that the myRIO LEDs turn on when MathScript is selected, yet the music sounds exactly the same as the native LabVIEW filtering.

Audio Equilizer Front Panel

Front Panel.jpg

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
llenpau
Member
Member
on

Your program has been of much utility to capture and process audio signals. I would enter an audio signal by an MXP entry. Could you give me a hand with this? Thank you so much!

John_Peng
Member
Member
on

Thanks for the submission.

I'm hearing a 2 Hz clicking sound when I run it. Is that to be expected?

John_Peng
Member
Member
on

I found the problem. It's the filter states not being kept between buffers. Here's the fix for the graphical operation:

Equalizer Fix.PNG

Contributors