Improving the MSGEQ7 audio input circuit

Hi Guys,
I've been looking at the best way to connect an audio jack to a MSGEQ7. This is for an arduino music reactive lighting project.

This is how the MSGEQ7 datasheet recommends doing it

I have tried this out and it works ok but its very reliant on the input volume being at the right level to get the right amount of response from the noise detection algorithm.

I can see an envelope follower circuit like this would be good if i was connecting directly the arduino but i am not sure if the same circuit should be used when connecting to the cinput.

Is there a better way to connect a stereo audio jack to a MSGEQ7 other than whats shown in the datasheet?

On the other hand the MAX9814 far outperforms using the audio jack in terms of responsiveness with its inbuilt AGC. I just connected it directly to the MSGEQ7 with one series capacitor. It will pick up and adjust to any room sounds at any volume quite well.
MAX9814 Datasheet

My ideal end goal would be to have some sort of AGC with the audio input jack going into the MSGEQ7 . If anyone can direct me to any good info on doing this that would be great. So far i haven't found anything useful.

The envelope follower won't work because it throws-away all of the frequency information... You no longer have an audio waveform.

You can do something like automatic gain control in software by multiplying the "counts" by a factor of greater or less than one, and for low-level signals you can switch to the 1.1V ADC reference.

I've never used the MSGEQ7 but I've done that with an envelope follower... I take a "loudness sample" once per second and I save it in a 20-second circular array (like the Smoothing Example) to get an average and I use that to set a reference or threshold. Or, for some of my lighting effects I use the "peak" from the 20-second array. When the levels in the array are low, I switch to the 1.1V reference and re-scale everything in the buffer.

My ideal end goal would be to have some sort of AGC with the audio input jack going into the MSGEQ7 .

Is that not what that chip you linked to does?
Can’t see why that will not work.

When using the MESGEQ7 chip with an audio output signal from various MP3 players like iPad and iPod I found you need a x5 to 10 amplifier on the front end to ensure the audio device is not going at maximum volume.

DVDdoug:
You can do something like automatic gain control in software by multiplying the "counts" by a factor of greater or less than one, and for low-level signals you can switch to the 1.1V ADC reference.

I've never used the MSGEQ7 but I've done that with an envelope follower... I take a "loudness sample" once per second and I save it in a 20-second circular array (like the Smoothing Example) to get an average and I use that to set a reference or threshold. Or, for some of my lighting effects I use the "peak" from the 20-second array. When the levels in the array are low, I switch to the 1.1V reference and re-scale everything in the buffer.

Sounds like software AGC can be implemented with very low performance overhead. So you just get the average of the last 20 samples over 20 seconds then use that to determine the multiplication factor? Would it be worth taking samples over a shorter time to make it more responsive to sudden changes in volume?

Grumpy_Mike:
Is that not what that chip you linked to does?
Can’t see why that will not work.

The MAX9814 does but it's an already made device with builtin mic. The datasheet seems to refer to both the device and its main chip as the MAX9814. I can't seem to find any information on how to find and use the same chip for a standard audio jack input. Such a thing would make it more volume independent with the output signal from the phone/mp3 device.

Grumpy_Mike:
When using the MESGEQ7 chip with an audio output signal from various MP3 players like iPad and iPod I found you need a x5 to 10 amplifier on the front end to ensure the audio device is not going at maximum volume.

By front end do mean the signal into the MSGEQ7? So you apply 5-10x amplification on the input signal?

Sounds like software AGC can be implemented with very low performance overhead. So you just get the average of the last 20 samples over 20 seconds then use that to determine the multiplication factor? Would it be worth taking samples over a shorter time to make it more responsive to sudden changes in volume?

You don't want the AGC too "responsive"... 20 seconds is the amount of time it takes the "AGC" to completely-adjust... That's just the time I chose. It's fast-enough to adjust to quiet & loud songs, but slow enough that it doesn't get messed-up by the silence (or fade) between songs.

I assume the MAX9814 board is set for faster AGC time because 20 seconds is slow for a "normal" microphone (for recording, etc.). If you have silence the gain gets turned-up to maximum. Then when sound comes-along you (usually) get distortion until the AGC adjusts, so you want a fast attack time (and a slower release time).

Your LEDs can respond "instantly".

For example, the maximum ADC value is 1023, so I assume your software is "tuned" for peaks around 1023... Let's say the maximum value in your 20-second array is 200, so your readings are on the low-side. You can multiply all of your readings by 5 (or by 1023/200).

Or, if your readings are consistently below 225 you switch to the [u]optional 1.1V reference[/u] and you'll get higher readings. (I do that.) The only tricky thing is if you automatically switch to the lower reference while the effect is running you have to scale-up the old-lower values in the array by a factor of 4.5 (5/1.1).

...Depending on how you do it, the maximum value in the array may not be THE peak, it might be A peak which you happen to save. (I just "save" a reading once per second so what's in the array it's not necessarily the highest peak.)

With the MSGEQ7 you've got 7 readings to deal with so you could make 7 arrays, or average them all together, or just choose a middle frequency-band, etc... Whatever you want to do or whatever works best for you.

In my application I'm not actually multiplying the readings, I'm adjusting the sensitivity by changing the digital reference. For example I have an effect that flashes the light on when the signal is above average and off when below average (the average is my reference). And I have a "VU Meter" effect where the "top" of the meter is the peak value saved in the 20-second delay (the peak is my reference).

...I've got some limits in my algorithm so it doesn't go "totally crazy" when there's no signal.

Either way, you are loosing resolution when you multiply the readings or lower the digital reference level, but it's an effect so accuracy/resolution are not important... You want lot's of LED/lighting action. (And, you have zero accuracy with anything like AGC or variable sensitivity). If you switch to the 1.1V analog reference you are gaining resolution.

The MAX9814 does but it's an already made device with builtin mic. The datasheet seems to refer to both the device and its main chip as the MAX9814. I can't seem to find any information on how to find and use the same chip for a standard audio jack input.

[u]Here is the datasheet for the chip[/u]. It has a minimal (nominal) gain of 40dB (100) so you'd have to attenuate the signal by about 40dB, which is sort-of "Mickey Mouse". (You can attenuate with a voltage divider, 2 resistors.)

You can probably find an AGC chip/circuit for line-level audio signals and lower nominal gain.

By front end do mean the signal into the MSGEQ7

Yes.

So you apply 5-10x amplification on the input signal?

Yes that is what I thought I said.

The MAX9814 does but it's an already made device with builtin mic.

As they say round here “is it thump” or no what ever gave you that idea.

The datasheet seems to refer to both the device and its main chip as the MAX9814.

No it doesn’t.

can't seem to find any information on how to find and use the same chip for a standard audio jack input.

This is a data sheet for grownups, it is not a tutorial for beginners. What do you think it should say? Yes just connect the output to your filter chip.

What I did with it:-

See the free to download magazines stated in the video for full software and design.

I have used that chip, it is a switched capacitor second order filter. I very much doubt that the AGC idea will work because of the noise on the output.

I see now i have misunderstood what the Max9814 actually is. Googling Max9814 will basically just show you the small mic amp board which utilises the chip.

Grumpy_Mike:
See the free to download magazines stated in the video for full software and design.

This was a great read and answers my original post. For anyone interested issue 46 may 2016 page 61 shows the amplifier circuit, it's worth reading the whole article.

Grumpy_Mike:
As they say round here “is it thump” or no what ever gave you that idea.

I'm not sure what this is supposed to mean but ok yes i gave a dumb answer.

Grumpy_Mike:
This is a data sheet for grownups, it is not a tutorial for beginners. What do you think it should say? Yes just connect the output to your filter chip.

I wasn't expecting the datasheet itself to say how to run output from a audio jack into it. I meant i can't find anything anywhere on the net. Since it's a mic amplifier i'm guessing it's not suited for that anyway.

DVDdoug:
In my application I'm not actually multiplying the readings, I'm adjusting the sensitivity by changing the digital reference. For example I have an effect that flashes the light on when the signal is above average and off when below average (the average is my reference). And I have a "VU Meter" effect where the "top" of the meter is the peak value saved in the 20-second delay (the peak is my reference).

I might have to do some tests. Right now i have averages taken of a few hundred samples per second and put into a circular array. Not sure if this will get around the issue of the MSGEQ7 noise Mike pointed out.

Not sure if this will get around the issue of the MSGEQ7

No.
The decay of the signal output from the chip is proportional to how often you read the samples. The more you read it the mode the output from the filters drop. So repeated reading will give you less and less signal each time, which is exactly what you don't want.

I'm not sure what this is supposed to mean

It is a north of England expression meaning. No, or "will it heck".

Googling Max9814 will basically just show you the small mic amp board which utilises the chip.

It is just a chip, sadly Google picks up people's ignorance and throws it back at you. What you are finding is a "Max9814 break out board". Their is nothing to stop you unsoldering the microphone from that and adding your own.

Since it's a mic amplifier i'm guessing it's not suited for that anyway.

Yes it is. Look at the data sheet, it will give you typically 1.4V peak to peak output. If you want any more then just follow by the amplifier in the article.

Here is a schematic so far based on what was done in the magazine.
The main difference being is that both channels are combined with just one amplifier used.
Does this look right?

Grumpy_Mike:
The decay of the signal output from the chip is proportional to how often you read the samples. The more you read it the mode the output from the filters drop. So repeated reading will give you less and less signal each time, which is exactly what you don't want.

I noticed the datasheet mentions a 10% decay per read. Would this mean there's an maximum reads that should be taken from the MSGEQ7? I noticed there's a 4ms wait before getting a reading from each channel in the magazines Spectrum code.

Does this look right?

Looks OK.

I noticed the datasheet mentions a 10% decay per read. Would this mean there's an maximum reads that should be taken from the MSGEQ7?

There not a maximum as such because a reduction of 10% is always possible to do forever. In theory this never reaches zero. But this is a digital world so things like integers and noise come into play.

I noticed there's a 4ms wait before getting a reading from each channel in the magazines Spectrum code.

Yes this is to hold the peak readings a little bit longer to make a display that is more like the volume meters you see in the audio world. There is no point in reading the chip faster than its results can be displayed, because the peaks would not look very good visually. How often you read it is a compromise between a quickly reactive display, and one that shows the peaks you are looking for. That is why averaging readings is not a very good technique to use here.

Grumpy_Mike:
There is no point in reading the chip faster than its results can be displayed, because the peaks would not look very good visually. How often you read it is a compromise between a quickly reactive display, and one that shows the peaks you are looking for. That is why averaging readings is not a very good technique to use here.

So i'm guessing that given the MSGEQ7 was made with graphic eq displays in mind, the decay is there by design. The trade of being that lower levels straight after peaks can get missed as the band level would still be high in it's decaying state. So as you say averaging readings is not a very good technique because allot of the samples taken with the ADC would just be the decaying levels.

The code i have averages blocks of readings from the MSGEQ7, so not ideal. Ideally what i'd need is the decay to not be there at all and to always get the actual level when taking a reading. I'm not sure if there is a similar chip to the MSGEQ7 without the decay but software solutions such as fast fourier transform are rather slow on an arduino which is what brought me to use the MSGEQ7 in the first place.

So i'm guessing that given the MSGEQ7 was made with graphic eq displays in mind, the decay is there by design.

Correct.
The decay is also part of the envelope follower design, it is provided by the discharge resistor value.

Ideally what i'd need is the decay to not be there at all and to always get the actual level when taking a reading.

I don't think that is possible, even theoretically using the concept of feeding a signal into a number of tuned filters. The filters produce an AC signal which you want to measure the peak of. That detection of a peak is always going to be subject to a delay using an envelope follower. You could tailor that delay to the individual frequency band, and hence minimised, if you were to make the equivalent circuit from separate switched capacitor filters.

You haven't said what your application is, and why you need there to be no holding of peaks.

Grumpy_Mike:
You haven't said what your application is, and why you need there to be no holding of peaks.

I have adapted a beat detection algorithm that originally would read a wav file and 'detect' where the beats are. The average peak for a block of samples is calculated and is used to determine if there was a beat. With the peaks being held and the 10% decay, the algorithm still works but not as effectively as it did in early tests when i just had MAX9814 breakout board feed straight into the ADC. I may just have to try and adapt the code for the MSGEQ7 if it's still my best option for frequency splitting.

Sorry for the delay in getting back to this..

the algorithm still works but not as effectively as it did in early tests when i just had MAX9814 breakout board feed straight into the ADC.

So if you just want to detect low frequencies then put a second order band pass filter between the MAX9814 breakout board and the ADC. Then you can control the decay by simply adjusting the biasing resistors total value.

Grumpy_Mike:
So if you just want to detect low frequencies then put a second order band pass filter between the MAX9814 breakout board and the ADC. Then you can control the decay by simply adjusting the biasing resistors total value.

So this could be an alternative to using the MSGEQ7? I'm also using the higher frequencies so that top end beats/hits are also detected. Could using active filters for different frequencies instead of having a MSGEQ7 mean the decay can be controlled and not be the fixed like it is on the MSGEQ7?

With the input signal amp circuit used in the magazine article. I have implemented it exactly as shown in my schematic at post #10. Obviously i have found if the volume is set extremely high on the source device, all 7 bands will peak out. The beat detection will then stop working as it will no longer see any variance.
Given my application perhaps i could go for a lower amplification instead of the 10x i currently have?

I may have to try and see what the optimal amount of amplification is where it's the most resilient to high input volume but still has enough to serve it's main purpose. Would replacing R4 in my schematic with a potentiometer be a good way to test this?

It comes down to the question of is it worth looking into something more complex such as AGC on the input to combat peaking or is that just overkill and with the right amount of amplification it will only peak if the source device is set at a unrealistic/unobtainable volume?

Thanks

Could using active filters for different frequencies instead of having a MSGEQ7 mean the decay can be controlled and not be the fixed like it is on the MSGEQ7?

Yes.

Given my application perhaps i could go for a lower amplification instead of the 10x i currently have?

Yes or put a pot in the circuit so the signal into your A/D is continuous variable.

It comes down to the question of is it worth looking into something more complex such as AGC on the input to combat peaking

Well it would give you a greater dynamic range for your input.

Yes R4 is the feedback resistor making it variable will allow you to adjust the gain.

Grumpy_Mike:
Well it would give you a greater dynamic range for your input.

Having this would be ideal and was originally what i had in mind.

DVDdoug said there might be AGC chips or circuits for this but i just haven't found anything.

DVDdoug:
You can probably find an AGC chip/circuit for line-level audio signals and lower nominal gain.

Correct me if i'm wrong but according to yourself the MAX9814 can theoretically be used with line level audio. If this is the case i haven't worked out how to do it yet. Every resource i find just treats it as a mic breakout board. The 1.4V peak to peak should be fine for what i'm doing since the normal mic breakout board itself has always worked well.

Grumpy_Mike:
Yes it is. Look at the data sheet, it will give you typically 1.4V peak to peak output. If you want any more then just follow by the amplifier in the article.

the MAX9814 can theoretically be used with line level audio. If this is the case i haven't worked out how to do it yet

Simply put a pot on the front end. Feed the line output to the two ends of the pot and the wiper to the input of the chip.