PDA

View Full Version : Determine loudness of input sound? QAudioInput



Terreox
29th February 2012, 21:35
Hi there
i am working at one part of my program where i need to get an audioinput from a microphone.
i think that is not the most difficult but how can i determine how loud this soundsignal is? i have to tell the program that if the input volume is a defined time beneath a specific soundlevel it shall execute another function.
How can i solve this? I am not a sound professional so how does the program know how loud a signal is?

Greetz

roxton
29th February 2012, 22:51
In digitial sound, you can measure the sound level by sample values (usually in floating point format) or decibells (with 0 dB as a louder sound level).
To convert normalized "float" value to dB, try this:

inline float float2db (float v)
{
if (v == 0)
return 0;

if (v > 0)
return (float) 20 * log10 (v / 1.0);

return (float) 20 * log10 (v / -1.0);
}