The conversion formula for decibels is:
100 + 20./2.302585092994 * log(x), where x is the linear volume or RMS. It looks like analyze() gives you the RMS value so just replace that with x.
I hope that is what you’re looking for.
Hi @hemangi_2810, Can you provide the code that is not working for you? I’m not able to reproduce that problem.
I used your code but changed the draw() method to:
// Using the Power quantities (See Wikipedia reference):
float P = 0.5; // Power measured
float Po = 1; // Using 1 as reference
// Using Math class directly
double dB1 = 10 * Math.log10(P/Po);
println(dB1);
// Using Processing helper function
float dB2 = 10 * log(P/Po)/log(10);
println(dB2);
The example code is for power levels and may need to be modified for field levels.