| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Graphic Equalizer Display Filter (Sound analysis)

Page history last edited by Xavier Falco 12 years, 10 months ago

 

Graphic Equalizer Display Filter - MSGEQ7

 

Description

 

This chip divides the audio spectrum into seven bands - 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz and 16kHz. It then does peak detection and gives the amplitude of each band. This gives a representation of the audio signal you can use to do visualization and other cool stuff.

 

 

The chip

 

View chip layout at http://pressplay.pbworks.com/w/file/41203183/chip.jpg

 

VDDA - that's power (5V)

VSSA - that's ground (0V)

OUT - that's the digital signal representing the amplitude of the signal. call analogRead() on this pin.

STROBE - turning this pin high and then low once moves to the next band in the multiplexer (more on this below)

CKIN - that's the clock pin - you use capacitors to give it the right oscillation (more on this below).

RESET - that pin is used to reset the multiplexer (more on this below)

GND - be careful, that's not the ground in your circuit but a pseudo ground on the chip (about 2.5V)

IN - Signal in, comes from left and right signal

 

The chip acts as a multiplexer - you use the reset pin to reset it to first output, and strobe to go to the next output. In other words, reset low enables the strobe pin. After the first strobe leading edge, 63Hz output is on OUT. Each additional strobe leading edge advances the multiplexor one channel (63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz, 16kHz etc.)

 

Hooking it up

 

Pin (#)
Connect to
VDDA (1)
5V
VDDA (1)
0.1 uF capacitor to ground
VSSA (2)
Ground
OUT (3)
A0 (or a pin that can do analog read)
STROBE (4) 2
IN (5) 0.01 uF capacitor to, in parallel, a 22kOhm resistor to left audio and a 22kOhm resistor to right audio (see diagram)
GND (6) 0.1 uF capacitor to ground
RESET (7) 3
CKIN (8) 200 kOhm to 5V
CKIN (8) 33 pF capacitor to ground (remember, capacitors in parallel add up capacitance)

 

View diagram at http://pressplay.pbworks.com/w/file/41203182/Screen%20shot%202011-06-11%20at%2012.33.25%20AM.png

 

Using it

 

To use the chip, you first pulse the reset pin HIGH then LOW. If you call analogRead() on out you will get the magnitude of the 63Hz band. To progress onto the next output on the multiplexer (i.e. the next band, 160Hz), pulse the strobe high and low - make sure it stays on low at least 30 microseconds (call delayMicroseconds(30)). You can continue pulsing on the strobe pin to cycle through the output. The sample code below keeps on printing the magnitude of the 7 bands:

 

int analogPin = 0; // read from multiplexer using analog input 0
int strobePin = 2; // strobe is attached to digital pin 2
int resetPin = 3; // reset is attached to digital pin 3
int spectrumValue[7]; // to hold a2d values

void setup()
{
  Serial.begin(9600);
  pinMode(analogPin, INPUT);
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);
  analogReference(DEFAULT);

  digitalWrite(resetPin, LOW);
  digitalWrite(strobePin, HIGH);

  Serial.println("MSGEQ7 test by J Skoba");
}

void loop()
{
  digitalWrite(resetPin, HIGH);
  digitalWrite(resetPin, LOW);

  for (int i = 0; i < 7; i++)
  {
    digitalWrite(strobePin, LOW);
    delayMicroseconds(30); // to allow the output to settle
    spectrumValue[i] = analogRead(analogPin);

    // comment out/remove the serial stuff to go faster
    // - its just here for show
    if (spectrumValue[i] < 10)
    {
      Serial.print("    ");
      Serial.print(spectrumValue[i]);
    }
    else if (spectrumValue[i] < 100 )
    {
      Serial.print("   ");
      Serial.print(spectrumValue[i]);
    }
    else
    {
      Serial.print("  ");
      Serial.print(spectrumValue[i]);
    }
    
    digitalWrite(strobePin, HIGH);
  }
  Serial.println();
} 

 

Comments (0)

You don't have permission to comment on this page.