Convert Mic Sound to dB SPL

edited March 2014 in How To...

Hi! I would like to know how I can convert the incoming volume from the Mic to a dB SPL range (i.e. ranging from 0 to 100 dB appr.). I am looking for the formula that will give me the values. So far I have tried this, but with no good results:

float db = (20. * log(10)) * (incomingLevel / 5.);

Tagged:

Answers

  • You can't really do that. It needs to be calibrated. The values you get from the microphone are arbitrary. You need a real dB meter, and check which values correspond to what levels.

  • And what about the formula? Will the above work? Or shall I make a table of values that are mapped according to meter readings?

  • edited March 2014 Answer ✓

    I'm not sure. Do you know if incomingLevel is already logarithmic? You just need to find two parameters, a and b: dB = a * incomingLevel + b, supposing incomingLevel is logarithmic. If it isn't, you need dB = a * log(incomingLevel) + b.

    I have no idea what the best way is to determine those parameters in Processing. Normally I'd create a dataset and then linearly interpolate the values in a statistics program. You can do this with, for example, Microsoft Excel. Have the incomingLevel values in one column and the appropriate dB levels from the meter in another. Select both columns and create a graph. If the points are on a nice line, incomingLevel is logarithmic. If the line is curved, it isn't. Then add a trendline and display the equation in the graph. There you get the values you want.

    http://office.microsoft.com/en-001/excel-help/add-change-or-remove-a-trendline-in-a-chart-HP010342158.aspx?CTT=1#BMdisplaytrendlineequation

  • I saw a friend use a java app that can work with mic levels once callibrated. It had data logging and several modes (dBa, min and max peak, average, ...). Might be worth searching for such an app instead of reinventing the wheel. You still need a calibrated meter though.

Sign In or Register to comment.