[Nexus 5 Android Development] chdloc:
I'd be happy to share the sources for my camcorder audio mod but I'm sure it won't be accepted in its current form by AOSP (or CM) for the reasons outlined below. Although I wouldn't mind somebody else (AOSP, ideally) maintaining this fix across future versions of Android...;)

the most fundamental change to improve the audio quality for services that use the "CAMCORDER" device is to modify the acdb identifier (from now on called acdb_id) of the SND_DEVICE_IN_CAMCORDER_MIC from 61 (stock) to ACDB_ID_VOICE_DMIC_EF_TMUS (which is 89). Why 89? No idea. Only those with proper documentation of the acdb interface will ever be able to find out. Maybe the CAF guys do know?

When acdb_id=61, overly aggressive noise suppression is applied to the microphone signal. Via trial and error I found that when acdb_id=89, noise suppression and a suspect (buggy?) high-pass filter are disabled. This is not a true fix, but a blind workaround that could break with the next iteration of Android. This acdb_id modification is in essence the "simple" version of my fix. BTW, I believe the suspect high-pass filter is the culprit as to why the Nexus 5 and some other Qualcomm-based devices are unable to record even only moderately loud (especially low-frequency) sounds without distortion. I think the microphone/ADC combination itself is quite capable of recording sound pressure levels all the way up to between 120 dB and 130 dB.

the "advanced" version of my fix is even more of a hack. The microphones used in our Nexus 5's are pretty noisy, offering only 58 dB of SNR. By comparison, I believe the microphones used in the iPhone or other flagship Android devices offer close to 70 dB of SNR. The difference is a huge. Due to the high noise floor, I do understand why Google and/or LG enabled noise suppression (after people had been complaining about hiss, i.e. white noise) in one of the KitKat updates. However, Google went too far with the noise suppression crank.

Completely disabling noise suppression may not be the best solution, either. In pursuit of finding a better solution I hacked the invocation of webRTC noise suppression algorithm (external/webrtc) into the audioflinger service (Threads.cpp and Effects.cpp) for cases where an (any) app requests the "Noise Suppression" effect. In order to keep the impact on libaudioflinger as low as possible I decided to have Threads.cpp communicate necessary data to Effects.cpp via (gasp!) global variables. Very ugly and against any coding standard on this planet.

Also, at this point, this scheme only works for 48 kHz sampling rate as I did not want to introduce additional buffering.

48 kHz is the standard sampling rate for camcorder recordings and many good audio-only recording apps (like "Easy Voice Recorder Pro") can be adjusted in their settings to support this sampling rate. This is good enough for me. However, there may be some apps that are choking on this restriction. I personally have not seen any, but I'm guessing that "Cyberion Voice Commander" as mentioned by someone in a previous post may be having problems because of the current sampling rate restriction.

All of this could certainly be improved relatively easily by a seasoned developer like yourself.

Let me know how you would like to proceed.