HomeForumsOpenEarspocketsphinxAudioDeviceMeteringLevel fails in release not in debug

This topic has 2 voices, contains 6 replies, and was last updated by  hartsteins 135 days ago.

Viewing 7 posts - 1 through 7 (of 7 total)
Author Posts
Author Posts
December 30, 2011 at 8:08 pm #8346

hartsteins

it seems that pocketsphinxAudioDeviceMeteringLevel gives a different result if compiled with a Xcode scheme debug vs release. Though this was discovered in my own app, I went back and compiled the sample project for both schemes and the problem exists there as well.

Tracing it back to the ContinuousAudioUnit class …. audioDriver->pocketsphinxDecibelLevel seems to return a float of 50.75 in release mode vs proper decibel readout in debug.

Any ideas?

thanks

December 30, 2011 at 8:31 pm #8347

Halle

Can you let me know the Xcode version, iOS version target and device you’re seeing the behavior on? It would also be helpful if you’d turn on OPENEARSLOGGING and look and see if there are errors or warnings when it doesn’t work.

December 30, 2011 at 9:11 pm #8348

hartsteins

I am testing on iPad 2 & iphone 4S both running 5.0.1

There is no error reported in OPENEARSLOGGING since there is error checking before the fact in the ContinuousAudioUnit code. Below is the method…. (I added the OpenEarsLog to see what was happening). Since in release the audio driver returns 50+ this method sends 0 and no errors appear. In debug (even in untouched sample code) this returns proper values.

Float32 pocketsphinxAudioDeviceMeteringLevel(pocketsphinxAudioDevice * audioDriver) { // Function which returns the metering level of the AudioUnit input.

OpenEarsLog(@”audioDriver->pocketsphinxDecibelLevel %f”,audioDriver->pocketsphinxDecibelLevel );

if(audioDriver != NULL && audioDriver->pocketsphinxDecibelLevel && audioDriver->pocketsphinxDecibelLevel > -161 && audioDriver->pocketsphinxDecibelLevel pocketsphinxDecibelLevel;
}
return 0.0;
}

December 30, 2011 at 9:12 pm #8349

hartsteins

Also targeting 5.0 btw

thanks for your help

December 30, 2011 at 9:39 pm #8350

hartsteins

Xcode 4.2.1 on Lion if that helps at all

continued thanks

January 2, 2012 at 2:37 pm #8355

Halle

Hi,

OK, I have replicated this and tracked it down. I don’t actually know the underlying cause that relates to the scheme selection yet because Xcode 4.2 makes it pretty non-obvious how to make a direct comparison of all of the build settings between configurations, however the actual bug is on my part since it’s due to relying on undefined behavior. Thanks for letting me know about it. You can fix it immediately by changing this line in the function getDecibels in the class ContinuousAudioUnit.mm:

	Float32 currentFilteredValueOfSampleAmplitude, previousFilteredValueOfSampleAmplitude; // We'll need these in the low-pass filter

to this:

	Float32 currentFilteredValueOfSampleAmplitude; // We'll need these in the low-pass filter
    Float32 previousFilteredValueOfSampleAmplitude = 0.0;
January 4, 2012 at 12:40 am #8359

hartsteins

Yay it works!
Glad I could help out in any way.

Thank you for all your work on this fantastic library.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.