superpoweredSDK / SuperpoweredLatency

This application measures round-trip audio latency on an iOS or Android device. Low round-trip audio latency is a strong indicator of how well any mobile device is optimized for professional audio. Lower latency confers significant benefits to users of all sorts of apps like games, augmented hearing apps, VOIP and other interactive apps. Read more: http://superpowered.com/latency
GNU General Public License v2.0
214 stars 71 forks source link

The input should be configured to use VOICE_RECOGNITION for minimum latency #1

Closed dturner closed 9 years ago

dturner commented 9 years ago

Some Android devices include signal processing by default on the MIC input, this increases latency and should be switched off.

For example, the new Nexus 6P has Dynamic Range Compression enabled by default which results in better quality audio input at the cost of increased latency. To switch this off you need to configure the MIC input to use the VOICE_RECOGNITION preset.

I have forked and updated the latency test to include this here: https://github.com/dturner/SuperpoweredLatency/commit/9b9408dfb073df3a80f0ca4a6570916b761228a8

superpoweredSDK commented 9 years ago

Thank you very much for your contribution. We will release the new version very soon with this included.

Please note, you need to check if the interface is available, otherwise your code will crash on devices with no such configuration support. So we did this:

// Configure the voice recognition preset which has no signal processing for lower latency.
SLAndroidConfigurationItf inputConfiguration;
if ((*inputBufferQueue)->GetInterface(inputBufferQueue, SL_IID_ANDROIDCONFIGURATION, &inputConfiguration) == SL_RESULT_SUCCESS) {
    SLuint32 presetValue = SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION;
    (*inputConfiguration)->SetConfiguration(inputConfiguration, SL_ANDROID_KEY_RECORDING_PRESET,
                                            &presetValue, sizeof(SLuint32));
    (*inputBufferQueue)->Realize(inputBufferQueue, SL_BOOLEAN_FALSE);
};
dturner commented 9 years ago

Thanks for this. One thing: shouldn't (*inputBufferQueue)->Realize(inputBufferQueue, SL_BOOLEAN_FALSE); be outside the last parenthesis so that the input buffer queue is realized regardless of whether the VOICE_RECOGNITION preset is set?

dturner commented 9 years ago

Also, out of interest, which devices don't have this configuration support? Obviously non-Android devices but are there any Android devices you've tested which don't have this?

superpoweredSDK commented 9 years ago

You are absolutely right, realize was on a wrong place. Fortunately, the media server initializes audio input still somehow. Will fix asap. The Samsung Note 3 crashed without checking for the interface.

dturner commented 9 years ago

Great, thanks for the info.