Go Down

Topic: Another Audio Spectrum Analyzer. (Read 11334 times) previous topic - next topic

ElArtista

Oct 02, 2011, 10:14 pm Last Edit: Oct 11, 2011, 04:20 pm by El Artis Reason: 1
My last project is an audio spectrum analyzer. The work has been done using a MSGEQ7 integrated. The result is shown using an 2X16 LCD display. The bars are built using defined characters.
The chip only gives 7 info of frequency. I've arrived until the 16 bar interpolating values based in the 7 given.

The music you hear is a them I wrote in 2005.

http://www.youtube.com/watch?v=EpLLqgySCD4

http://www.mundosimaginados.com
http://mundosimaginados.blogia.com

robtillaart

Well done and quite responsive,

can you share code & schematics?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Onions

That's pretty cool! You've tempted me to set one up myself some time... I know it is possible to use transistors with a resistor ladder to produce one bar of the EQ thingy (can't think of how to phrase it, so I'll draw the schematic). Do you have any codes? :D




There, badly drawn and missing LED series resistors, but it should work as an EQ thingy. :)

Onions.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

ElArtista

I don't have an schem but you can find here info about how conect: http://nuewire.com/info-archive/msgeq7-by-j-skoba/.

And here is my code:

Code: [Select]
#include <LiquidCrystal.h>

// The LCD is conected to pins 13,12,11,10,9,8

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

byte vumetro[8][8];

float vumetros[16];

// The analog pin 0 is used to read value.
int valor_analogico = 0;
// The 6 & 7 pins are used for control the integrated.
int strobe = 6;
int reset = 7;
int valores_frecuencias[7];

void setup() {
  // Built the characters for bars.
  for (int j=0; j<=7; j++) 
  {
    for (int i=0; i<=7; i++)
    {
      if (i<=j)
      { vumetro[j][7-i] = B01110;}
//      { vumetro[j][7-i] = B01010;}  Uncomment this lines for getting other variants for bars.
//      { vumetro[j][7-i] = B11111;}     
      else
      { vumetro[j][7-i] = 0;}
    }
  } 
  for (int i=0; i<=7;i++)
  {
    lcd.createChar(i, vumetro[i]);
  }

  lcd.begin(16, 2);     
  for (int j=0; j<=7;j++)
  {
    lcd.setCursor(j, 0);
    lcd.write(j);
    lcd.setCursor(j, 1);
    lcd.write(7);   
   
  pinMode(valor_analogico, INPUT);
  pinMode(strobe, OUTPUT);
  pinMode(reset, OUTPUT);
  analogReference(DEFAULT);

  digitalWrite(reset, LOW);
  digitalWrite(strobe, HIGH);
   
  } 

}

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

  // The read of integrated is done by multiplexing.
  for (int i = 0; i < 7; i++)
  {
    digitalWrite(strobe, LOW);
    delayMicroseconds(5);
    valores_frecuencias[i] = analogRead(valor_analogico);
    digitalWrite(strobe, HIGH);
  }

// It's necesary to interpolate for calculating 16 bars having only 7 values read.
for (int k=0; k<=15; k++)
  {
  switch (k)
  {
    case 0:
      vumetros[k]= valores_frecuencias[0]/64;
      break;
   
    case 1:
      vumetros[k]= (valores_frecuencias[0]/64 + valores_frecuencias[1]/64)/2;
      break;

    case 2:
      vumetros[k]= valores_frecuencias[1]/64;
      break;
   
    case 3:
      vumetros[k]= (valores_frecuencias[1]/64 + valores_frecuencias[2]/64)/2;
      break;

    case 4:
      vumetros[k]= valores_frecuencias[2]/64;
      break;
   
    case 5:
      vumetros[k]= (valores_frecuencias[1]/64 + valores_frecuencias[2]/64 + valores_frecuencias[3]/64)/3;
      break;
       
    case 6:
      vumetros[k]= (valores_frecuencias[2]/64 + valores_frecuencias[3]/64 + valores_frecuencias[4]/64)/3;
      break;

    case 7:
      vumetros[k]= random(2)+valores_frecuencias[3]/64;
      break;
     

    case 8:
      vumetros[k]= random(2)+valores_frecuencias[3]/64;
      break;

    case 9:
      vumetros[k]= (valores_frecuencias[2]/64 + valores_frecuencias[3]/64 + valores_frecuencias[4]/64)/3;
      break;

    case 10:
      vumetros[k]= (valores_frecuencias[3]/64 + valores_frecuencias[4]/64 + valores_frecuencias[5]/64)/3;
      break;

    case 11:
      vumetros[k]= valores_frecuencias[4]/64;
      break;

    case 12:
      vumetros[k]= (valores_frecuencias[4]/64 + valores_frecuencias[5]/64)/2;
      break;

    case 13:
      vumetros[k]= valores_frecuencias[5]/64;
      break;

    case 14:
      vumetros[k]= (valores_frecuencias[5]/64 + valores_frecuencias[6]/64)/2;
      break;

    case 15:
      vumetros[k]= valores_frecuencias[6]/64;
      break;
  }

  Dibuja_vumetro(k, vumetros[k]);
  delay(2);
  }
 
}

void Dibuja_vumetro(int posicion, int altura)
{
  if (altura>7)
  {
    lcd.setCursor(posicion, 1);
    lcd.write(7);
    lcd.setCursor(posicion, 0);
    lcd.write(altura-8);   
  }
  else
  {
    lcd.setCursor(posicion, 1);
    lcd.write(altura);
    lcd.setCursor(posicion, 0);
    lcd.write(32);   
  }
}

willnue

Very cool!

I really am glad I had a copy of J Skoba's tutorial saved (for my own benefit) and now since I reposted it even happier to see others benefit as well.

willnue

ElArtista

Thanks you for posting the tutorial. I decided to start my develop seeing the post you saved...

Zyrusthc

http://fritzing.org/projects/msgeq7-audio-equalizer/
http://fritzing.org/projects/sparkfun-spectrum-shield-audio-equalizer-lcd/

Have create on this Thread and http://nuewire.com/info-archive/msgeq7-by-j-skoba/

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy