I’ve seen some other threads about getTunerVolume() but I wanted to start a new one because I hope the information here is new and useful to Ansca and to other developers.
I have a VU meter on my app that always seems pegged at the top with any amount of sustained sound. I decided to set up a test app that records the values from getTunerVolume() and play into the mic white noise that starts silent and gets gradually louder. Here is the code for the test app.[code]local displayGroup = display.newGroup()
local r = media.newRecording()
local decibelText = display.newText( displayGroup, “00.000”, 180, 100, native.systemFontBold, 56 )
local updateStatus = function()
local v = r:getTunerVolume()
local t = system.getTimer()
local vdb = 10 * math.log( v )
decibelText.text = tostring( vdb )
local listFilePath = system.pathForFile( “volume.csv”, system.DocumentsDirectory )
local listFile = io.open( listFilePath, “a+” )
if listFile then
listFile:write( v … “,” )
io.close( listFile )
end
local listFilePath = system.pathForFile( “time.csv”, system.DocumentsDirectory )
local listFile = io.open( listFilePath, “a+” )
if listFile then
listFile:write( t … “,” )
io.close( listFile )
end
end
– Main function
local function main()
r:startTuner()
r:startRecording()
Runtime:addEventListener( “enterFrame”, updateStatus )
return true
end
–Get things moving
main()[/code]
I put the saved volume info into excel and created a scatter plot. Here’s what I got.
Now, to me, that doesn’t look like what I expected to come from a gradual rise in volume. The documentation on getTunerVolume() says it returns the mean squared value scaled to be in the range [-1…1], yet it doesn’t look like it is full range. It looks like it slams up to 0.58 and stays there.
What’s going on?
[import]uid: 55576 topic_id: 13385 reply_id: 313385[/import]