Audio processing

Interesting, I am endeavouring to perform a similar task (although mine will output to an LCD panel.....mebby) and was wondering where to put the calibration for +0dB. Doing it in software seems the sensible option as it offers the most flexibility.

Cant wait for my hardware to arrive, its kind of frustrating developing even simple test code without something to test it against :slight_smile:

See, I did not get to the point with the Db calibration. The reason I did not is due to the math function and the way you would have to use a logarithmic scale for that voltage. If you get any further on that, let me know.

Apologies if this derails the thread, but at least you have the option of calibrating your meters.

The other problem is how dB relates to impedance and amperage, but I think most of us take the engineers route of good enough.

http://www.daycounter.com/Calculators/RMS-Calculator.phtml

For the Peak to Peak RMS calculation from the raw analog input.

Coversion table: Volts-to-dBm has a lookup table (if you wish to go that route) and some fairly simple (in the grand scheme of maths) algorithms.

The one I am looking at is =20LOG10(Volts_peak_to_peak/SQRT(0.008Z))

Once I can actually test my code I shall ensure it makes it here.

Don't suppose anyone knows the impedance across the analogue input pins do they?

Where do you plan to get the Vpp? Just from the analog in. The other question that I have is how are you going to set up your cuttoffs.

Vpp would have to be calculated from the data, the cutoffs depend on the signal type, if its line level it "should" be 1.0 Vpp at 0dB most European audio kit goes uo to +6dB (around 2.2V) and US kit usually hangs around the +4dB level or 1.7Vpp.

Obviously amplified levels such as those from a typical MP3 players headphone output can go wherever the hell the manufacturer wants (but mostly top out at 4v). Conversely Mic inputs are waaaaay lower.

What could happen is to rectify and smooth the input to the Vpp pins and leave the signal as merely rectified, combining the two. But I think that's an unnecessary over complication.

One thing I have seen mentioned but haven't looked at yet is resetting the voltage range that represents 0-1023 samples.

What kind of audio in are you going to use?

For the kind of stuff I do its all line level balanced (not a problem) audio until it hits the amp racks.

For stage 1 I will just attach the rectifier (http://sound.westhost.com/appnotes/an001.htm) to one of the analog inputs and see what happens.

I can generate a known 1Vpp 1K tone and use that to calibrate my inputs either within software or with a preamp circuit of some description.

Thankfully subjective audio quality is irrelevant, its power I intend to measure so the input stage can be reallllly cheap and nasty :slight_smile: Or The Easy Way - http://www.electronics-tutorials.ws/diode/diode_6.html as I like to call it. The forward voltage drop will need to be addressed though.

Quick braindump for a VU meter that I have whizzed up this afternoon since I received my hardware.

It's quick and its dirty because I haven't received the components to build my rectifier circuits yet.

It makes use of desinger2k2's work on speeding up the LCD display - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1240088162/0 (although I had to do additional work to make my screen+buttons shield to work)

#include <LCD4Bit_fast.h>

LCD4Bit_fast lcd = LCD4Bit_fast(2); 

void setup() {
  
  
  lcd.init();                             //Inits the LCD

}

void loop() {  

  //int i=(analogRead(1)/64); //readin Analog 1 (Left) calibrate for screen
  //int j=(analogRead(2)/64); //readin Analog 2 (Right) calibrate for screen
  
  int i=random(2,14);       //simulated input
  int j=i+(random(-2,2));   //simulated input
  int x=0;
  int y=0;
 
  lcd.clear();

 lcd.commandWrite(0x80+11); //Place cursor at row 1 col 0 and add i to the col
 lcd.printIn("|"); //fill character with ]
  lcd.commandWrite(0xC0+11); //Place cursor at row 1 col 0 and add i to the col
 lcd.printIn("|"); //fill character with ]
  
 while (x <= i)
  {
    lcd.commandWrite(0x80+x); //Place cursor at row 1 col 0 and add x to the col
    if (x > 11) 
    { 
      lcd.print(255);
    }
    else
    {
    lcd.printIn("="); //fill character with white
    }
    x++;
  }
 
  while (y <= j)
  {
    lcd.commandWrite(0xC0+y); //Place cursor at row 2 col 0 and add y to the col
    if (y > 11) 
    { 
      lcd.print(255);
    }
    else
    {
    lcd.printIn("="); //fill character with white
    }
    y++;
  } 
   
  delay(120);
  
}