Pages: [1]   Go Down
Author Topic: Another Audio Spectrum Analyzer.  (Read 8769 times)
0 Members and 1 Guest are viewing this topic.
Spain
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.mundosimaginados.com
http://mundosimaginados.blogia.com
« Last Edit: October 11, 2011, 09:20:05 am by El Artis » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12483
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well done and quite responsive,

can you share code & schematics?
Logged

Rob Tillaart

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

Newcastle, England
Offline Offline
Sr. Member
****
Karma: 2
Posts: 489
Always learning!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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? smiley-grin




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

Onions.
Logged

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

Spain
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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);   
  }
}
Logged

USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
I’m no expert, but I play one on the Internet…
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Spain
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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/
Logged

Pages: [1]   Go Up
Jump to: