Trying to get microphone volume using getTunerVolume()

I’ve been trying to detect the volume of a person’s voice using the built-in tuner functions. I’m able to accurately record and determine pitch, but anytime I try to detect volume it just gives me random long numbers between 0.5 and 0.6.

I’ve been searching high and low for any documentation on this other than what’s available in the Reference API (it’s under Multimedia). Does anyone have any experience with this? My App is pretty much dead in the water without it. [import]uid: 8975 topic_id: 2030 reply_id: 302030[/import]

Hi davelandry,

We will be giving this feature our full attention in the very near future now that 2.0 is out. (Logged as FB#519)

Thanks for your patience!

Alix [import]uid: 6787 topic_id: 2030 reply_id: 6142[/import]

I’d like to second this request. I want to use the tuner frequency and volume for my application. The frequency seems to work, but the volume is constantly fluctuating between 0.45 and 0.6 (on iOS devices).

Snarla, could you give us more details about the problem right now? Is there anything we could do in our code as workaround or do you need to fix it in Corona itself? [import]uid: 8111 topic_id: 2030 reply_id: 6305[/import]

Hi again and sorry for not getting back to you sooner. We’re working on better sample code to demo how to use the volume number returned by the API, but in the meantime here is a little more information.

The volume number is the mean square value of the sample values in the sample buffer using sample values scaled to be in the range [-1, 1]. You could convert this value to something more useful like this:

local r = media.newRecording()  
 ... yadda yadda ...  
local v = r:getTunerVolume()  
local vdb = 10\*math.log( v )   

This should give you a more interesting range of values to work with.

Alix
[import]uid: 6787 topic_id: 2030 reply_id: 6759[/import]

Hello,

Please, could you tell me why I get “-inf” when i try to print the return value from getTunerVolume?

Here is the code:

...  
 local v = gravacion:getTunerVolume()  
 local vdb = 10 \* math.log( v )  
 local texto = tostring( vdb )  
 print("Volume en dB: "..texto)  
...  

I read several post about getTunerVolume(), ones says it works and others says it doesn’t work.

TIA [import]uid: 44013 topic_id: 2030 reply_id: 81308[/import]