MSGEQ7 Tutorial 02: MSGEQ7 Decay Rate

Featured_Image-1-31

Pretty much every single product page out there, and consequently every tutorial, always quote the “readout is 10% decay” statistic from the datasheet, but no one ever bothers to explain it. Well, let me correct that.

MSGEQ7 Decay Rate Definition

The MSGEQ7 decay rate is the speed with which the output representing a particular frequency band will drop, if the peak detector determines that the current value is lower than the previous value — it’s like climbing a ladder quickly to the top of a platform then taking the stairs down. The decay rate determines how steep those stairs are.

The MSGEQ7 datasheet says that the value decays 10% per read. It’s not clearly expressed anywhere in the datasheet exactly what value is being used to calculate the 10% reduction. If your highest level as read by the ADC is 1000, then you would expect the next reading to be 900. But what about the next one, would it be the original 10% again, 100, or 10% of 900, 90. My bet is that’s its a running 90% value, just decaying whatever the most recently provided value was… in that example, 90.

So, in essence, what we would expect to see would be something like this, assuming we max out the value to 5V to achieve a 1023 reading on the ADC, and also achieve exact 10% decay per subsequent reading…

MSGEQ7 Ideal Decay Rate Graph
MSGEQ7 Ideal Decay Rate Graph

So how do we test this assumption?

MSGEQ7 Decay Rate Test Code

What I’m doing is connecting the chip to my Arduino, just as I did in the first MSGEQ7 tutorial, only this time, I’m also connecting a debounced button to use as a trigger for the Arduino, telling it to go and grab the current reading for me, instead of just simply streaming it back.

MSGEQ7 Decay Rate Schematic
MSGEQ7 Decay Rate Schematic

Here’s the test methodology…

  1. Prepare the code to listen to one specific frequency channel, I chose 400Hz, the third band.
  2. Find a crisp 400Hz signal. YouTube has one easily used: https://www.youtube.com/watch?v=33qV3d3U0q4
  3. Upload the code and launch the serial monitor. Press the button to take a few samples with nothing playing to establish a baseline. You are expecting a value below 100. If not, make sure no other audio sources are playing on your PC.
  4. Launch the clear 400Hz tone. Press the button to take another sample. You are expecting a reading close to 1023. If not, try turning the volume of your PC up. You won’t damage the MSGEQ7.
  5. Stop the 400Hz tone.
  6. With the 400Hz band essentially quiet now, press the button several more times to gather values on a quiet channel, immediately after a maxed channel.

Here’s the code.

After uploading the code and following the methodology, here is what the actual returned values where.

MSGEQ7 Actual Decay Rate Graph
MSGEQ7 Actual Decay Rate Graph

Pretty close to our original graph!

This is used to give the very nice “staggered return” to zero on a graphic equalizer display, where the audio peaks, but you see the LED bar graph crawl back to the bottom instead of just immediately falling.